Inflate custom site container delegates correctly.
[mono.git] / mcs / mcs / attribute.cs
index 288ecd6b526d37046152b591f13fb78d569b81f4..8330f5000763fa5d98ef0641cd9d210cf3aa5a0c 100644 (file)
@@ -308,7 +308,7 @@ namespace Mono.CSharp {
 
                public bool HasSecurityAttribute {
                        get {
-                               PredefinedAttribute pa = PredefinedAttributes.Get.Security;
+                               PredefinedAttribute pa = context.Compiler.PredefinedAttributes.Security;
                                return pa.IsDefined && TypeSpec.IsBaseClass (type, pa.Type, false);
                        }
                }
@@ -337,7 +337,7 @@ namespace Mono.CSharp {
 
                void ApplyModuleCharSet (ResolveContext rc)
                {
-                       if (Type != PredefinedAttributes.Get.DllImport)
+                       if (Type != context.Compiler.PredefinedAttributes.DllImport)
                                return;
 
                        if (!RootContext.ToplevelTypes.HasDefaultCharSet)
@@ -353,7 +353,7 @@ namespace Mono.CSharp {
                                }
                        }
 
-                       var char_set = Import.ImportType (typeof (CharSet));
+                       var char_set = rc.Compiler.MetaImporter.ImportType (typeof (CharSet));  // TODO: typeof
                        NamedArguments.Add (new NamedArgument (CharSetEnumMember, loc,
                                Constant.CreateConstant (rc, char_set, RootContext.ToplevelTypes.DefaultCharSet, Location)));
                }
@@ -443,10 +443,10 @@ namespace Mono.CSharp {
 
                                a.Resolve (ec);
 
-                               Expression member = Expression.MemberLookup (ec, ec.CurrentType, Type, name, 0, false, loc);
+                               Expression member = Expression.MemberLookup (ec, ec.CurrentType, Type, name, 0, MemberLookupRestrictions.ExactArity, loc);
 
                                if (member == null) {
-                                       member = Expression.MemberLookup (null, ec.CurrentType, Type, name, 0, false, loc);
+                                       member = Expression.MemberLookup (null, ec.CurrentType, Type, name, 0, MemberLookupRestrictions.ExactArity, loc);
 
                                        if (member != null) {
                                                // TODO: ec.Report.SymbolRelatedToPreviousError (member);
@@ -483,6 +483,7 @@ namespace Mono.CSharp {
                                        }
 
                                        obsolete_attr = pi.GetAttributeObsolete ();
+                                       pi.MemberDefinition.SetIsAssigned ();
                                } else {
                                        var fi = ((FieldExpr) member).Spec;
 
@@ -498,6 +499,7 @@ namespace Mono.CSharp {
                                        }
 
                                        obsolete_attr = fi.GetAttributeObsolete ();
+                                       fi.MemberDefinition.SetIsAssigned ();
                                }
 
                                if (obsolete_attr != null && !context.IsObsolete)
@@ -520,7 +522,7 @@ namespace Mono.CSharp {
                public string GetValidTargets ()
                {
                        StringBuilder sb = new StringBuilder ();
-                       AttributeTargets targets = Type.GetAttributeUsage (PredefinedAttributes.Get.AttributeUsage).ValidOn;
+                       AttributeTargets targets = Type.GetAttributeUsage (context.Compiler.PredefinedAttributes.AttributeUsage).ValidOn;
 
                        if ((targets & AttributeTargets.Assembly) != 0)
                                sb.Append ("assembly, ");
@@ -991,7 +993,7 @@ namespace Mono.CSharp {
 
                public bool IsInternalMethodImplAttribute {
                        get {
-                               if (Type != PredefinedAttributes.Get.MethodImpl)
+                               if (Type != context.Compiler.PredefinedAttributes.MethodImpl)
                                        return false;
 
                                MethodImplOptions options;
@@ -1046,7 +1048,9 @@ namespace Mono.CSharp {
                        if (ctor == null)
                                return;
 
-                       AttributeUsageAttribute usage_attr = Type.GetAttributeUsage (PredefinedAttributes.Get.AttributeUsage);
+                       var predefined = context.Compiler.PredefinedAttributes;
+
+                       AttributeUsageAttribute usage_attr = Type.GetAttributeUsage (predefined.AttributeUsage);
                        if ((usage_attr.ValidOn & Target) == 0) {
                                Report.Error (592, Location, "The attribute `{0}' is not valid on this declaration type. " +
                                              "It is valid on `{1}' declarations only",
@@ -1054,8 +1058,6 @@ namespace Mono.CSharp {
                                return;
                        }
 
-                       var predefined = PredefinedAttributes.Get;
-
                        AttributeEncoder encoder = new AttributeEncoder (false);
 
                        if (PosArguments != null) {
@@ -1558,7 +1560,7 @@ namespace Mono.CSharp {
 
                public static void VerifyModulesClsCompliance (CompilerContext ctx)
                {
-                       Module[] modules = GlobalRootNamespace.Instance.Modules;
+                       Module[] modules = ctx.GlobalRootNamespace.Modules;
                        if (modules == null)
                                return;
 
@@ -1657,9 +1659,7 @@ namespace Mono.CSharp {
                public readonly PredefinedAttribute StructLayout;
                public readonly PredefinedAttribute FieldOffset;
 
-               public static PredefinedAttributes Get = new PredefinedAttributes ();
-
-               private PredefinedAttributes ()
+               public PredefinedAttributes ()
                {
                        ParamArray = new PredefinedAttribute ("System", "ParamArrayAttribute");
                        Out = new PredefinedAttribute ("System.Runtime.InteropServices", "OutAttribute");
@@ -1711,11 +1711,6 @@ namespace Mono.CSharp {
                                ((PredefinedAttribute) fi.GetValue (this)).Initialize (ctx, true);
                        }
                }
-
-               public static void Reset ()
-               {
-                       Get = new PredefinedAttributes ();
-               }
        }
 
        public class PredefinedAttribute