Define internal attribute in case we missed the global initialization.
authorMarek Safar <marek.safar@gmail.com>
Wed, 8 May 2013 15:47:36 +0000 (17:47 +0200)
committerMarek Safar <marek.safar@gmail.com>
Thu, 9 May 2013 08:09:32 +0000 (10:09 +0200)
mcs/mcs/attribute.cs
mcs/mcs/typemanager.cs

index 6bbdb09b174f134d5a5cdf8f9af6df50e95a9d79..ae7e4b37363e5c57da533cc5b4252aec3c5d84a5 100644 (file)
@@ -1820,7 +1820,7 @@ namespace Mono.CSharp {
                        //
                        // Handle all parameter-less attributes as optional
                        //
-                       if (!IsDefined)
+                       if (!Define ())
                                return false;
 
                        ctor = (MethodSpec) MemberCache.FindMember (type, MemberFilter.Constructor (ParametersCompiled.EmptyReadOnlyParameters), BindingRestriction.DeclaredOnly);
index cefb322eeb540cbdc3d483c22ebd8ccc1a0b32b6..6eb7648ce537b162b61e8a9727d995a32d49d8d7 100644 (file)
@@ -691,6 +691,7 @@ namespace Mono.CSharp
                readonly MemberKind kind;
                protected readonly ModuleContainer module;
                protected TypeSpec type;
+               bool defined;
 
                public PredefinedType (ModuleContainer module, MemberKind kind, string ns, string name, int arity)
                        : this (module, kind, ns, name)
@@ -753,7 +754,11 @@ namespace Mono.CSharp
                        if (type != null)
                                return true;
 
-                       type = Resolve (module, kind, ns, name, arity, false, false);
+                       if (!defined) {
+                               defined = true;
+                               type = Resolve (module, kind, ns, name, arity, false, false);
+                       }
+
                        return type != null;
                }
 
@@ -771,12 +776,13 @@ namespace Mono.CSharp
                        // fake namespaces when type is optional and does not exist (e.g. System.Linq).
                        //
                        Namespace type_ns = module.GlobalRootNamespace.GetNamespace (ns, required);
+
                        IList<TypeSpec> found = null;
                        if (type_ns != null)
                                found = type_ns.GetAllTypes (name);
 
                        if (found == null) {
-                               if (reportErrors )
+                               if (reportErrors)
                                        module.Compiler.Report.Error (518, "The predefined type `{0}.{1}' is not defined or imported", ns, name);
 
                                return null;