Better error reporting for async delegates
[mono.git] / mcs / mcs / roottypes.cs
index 260259037c5f1bc1ef498821d224653b6d570767..b998806b8b94cb706314dce1d8ad6c42ec9aeb16 100644 (file)
@@ -63,27 +63,14 @@ namespace Mono.CSharp
                                        // DefineInitializedData because it creates public type,
                                        // and its name is not unique among modules
                                        //
-                                       size_type = new Struct (null, this, new MemberName ("$ArrayType=" + data.Length, Location), Modifiers.PRIVATE | Modifiers.COMPILER_GENERATED, null);
+                                       size_type = new Struct (null, this, new MemberName ("$ArrayType=" + data.Length, loc), Modifiers.PRIVATE | Modifiers.COMPILER_GENERATED, null);
                                        size_type.CreateType ();
                                        size_type.DefineType ();
 
                                        size_types.Add (data.Length, size_type);
-                                       var ctor = Module.PredefinedMembers.StructLayoutAttributeCtor.Resolve (Location);
-                                       if (ctor != null) {
-                                               var argsEncoded = new AttributeEncoder ();
-                                               argsEncoded.Encode ((short) LayoutKind.Explicit);
-
-                                               var field_size = Module.PredefinedMembers.StructLayoutSize.Resolve (Location);
-                                               var pack = Module.PredefinedMembers.StructLayoutPack.Resolve (Location);
-                                               if (field_size != null && pack != null) {
-                                                       argsEncoded.EncodeNamedArguments (
-                                                               new[] { field_size, pack },
-                                                               new[] { new IntConstant (Compiler.BuiltinTypes, (int) data.Length, Location), new IntConstant (Compiler.BuiltinTypes, 1, Location) }
-                                                       );
-
-                                                       size_type.TypeBuilder.SetCustomAttribute ((ConstructorInfo) ctor.GetMetaInfo (), argsEncoded.ToArray ());
-                                               }
-                                       }
+
+                                       // It has to work even if StructLayoutAttribute does not exist
+                                       size_type.TypeBuilder.__SetLayout (1, data.Length);
                                }
 
                                var name = "$field-" + fields.ToString ("X");
@@ -225,6 +212,10 @@ namespace Mono.CSharp
                        }
                }
 
+               public bool HasTypesFullyDefined {
+                       get; set;
+               }
+
                //
                // Returns module global:: namespace
                //
@@ -397,7 +388,10 @@ namespace Mono.CSharp
                public new void CreateType ()
                {
                        // Release cache used by parser only
-                       defined_type_containers = null;
+                       if (Evaluator == null)
+                               defined_type_containers = null;
+                       else
+                               defined_type_containers.Clear ();
 
                        foreach (TypeContainer tc in types)
                                tc.CreateType ();
@@ -418,6 +412,8 @@ namespace Mono.CSharp
                                        throw new InternalErrorException (tc, e);
                                }
                        }
+
+                       HasTypesFullyDefined = true;
                }
 
                public override void Emit ()
@@ -549,6 +545,7 @@ namespace Mono.CSharp
 
                protected override void RemoveMemberType (TypeContainer ds)
                {
+                       defined_type_containers.Remove (ds.MemberName);
                        ds.NamespaceEntry.NS.RemoveDeclSpace (ds.Basename);
                        base.RemoveMemberType (ds);
                }
@@ -611,7 +608,7 @@ namespace Mono.CSharp
                        return PartialContainer.IsClsComplianceRequired ();
                }
 
-               public override IList<MethodSpec> LookupExtensionMethod (TypeSpec extensionType, string name, int arity, ref NamespaceContainer scope)
+               public override ExtensionMethodCandidates LookupExtensionMethod (TypeSpec extensionType, string name, int arity)
                {
                        return null;
                }