[Mono.CSharp] Fix bug where overwriting variables cleared the wrong value
[mono.git] / mcs / mcs / class.cs
index d91c433484940e0968fbaf4b4e4538b182997bd6..943db46deabceb0b05b664c0a6372b029a967052 100644 (file)
@@ -1026,6 +1026,9 @@ namespace Mono.CSharp {
                                TypeBuilder = Parent.TypeBuilder.DefineNestedType (Basename, TypeAttr, null, type_size);
                        }
 
+                       if (DeclaringAssembly.Importer != null)
+                               DeclaringAssembly.Importer.AddCompiledType (TypeBuilder, spec);
+
                        spec.SetMetaInfo (TypeBuilder);
                        spec.MemberCache = new MemberCache (this);
                        spec.DeclaringType = Parent.CurrentType;
@@ -1348,7 +1351,20 @@ namespace Mono.CSharp {
                //
                public void SetPredefinedSpec (BuildinTypeSpec spec)
                {
+                       // When compiling build-in types we start with two
+                       // version of same type. One is of BuildinTypeSpec and
+                       // second one is ordinary TypeSpec. The unification
+                       // happens at later stage when we know which type
+                       // really matches the buildin type signature. However
+                       // that means TypeSpec create during CreateType of this
+                       // type has to be replaced with buildin one
+                       // 
+                       spec.SetMetaInfo (TypeBuilder);
+                       spec.MemberCache = this.spec.MemberCache;
+                       spec.DeclaringType = this.spec.DeclaringType;
+
                        this.spec = spec;
+                       current_type = null;
                }
 
                void UpdateTypeParameterConstraints (TypeContainer part)
@@ -1571,6 +1587,10 @@ namespace Mono.CSharp {
                        ComputeIndexerName();
                        CheckEqualsAndGetHashCode();
 
+                       if (Kind == MemberKind.Interface && iface_exprs != null) {
+                               MemberCache.RemoveHiddenMembers (spec);
+                       }
+
                        return true;
                }
 
@@ -1634,7 +1654,7 @@ namespace Mono.CSharp {
                                !pa.ResolveConstructor (Location, TypeManager.string_type))
                                return;
 
-                       var encoder = new AttributeEncoder (false);
+                       var encoder = new AttributeEncoder ();
                        encoder.Encode (GetAttributeDefaultMember ());
                        encoder.EncodeEmptyNamedArguments ();