Fix crash on cs0657-17.cs.
* codegen.cs (CommonAssemblyModulClass.GetClsCompliantAttribute):
Use RootContext.Tree.Types, not 'new RootTypes ()'.
* attribute.cs (GlobalAttribute.CheckAttributeType): Narrow down
the case where the NamespaceEntry gets overwritten.
svn path=/trunk/mcs/; revision=37179
+2004-12-06 Raja R Harinath <rharinath@novell.com>
+
+ Fix crash on cs0657-17.cs.
+ * codegen.cs (CommonAssemblyModulClass.GetClsCompliantAttribute):
+ Use RootContext.Tree.Types, not 'new RootTypes ()'.
+ * attribute.cs (GlobalAttribute.CheckAttributeType): Narrow down
+ the case where the NamespaceEntry gets overwritten.
+
2004-12-06 Marek Safar <marek.safar@seznam.cz>
Fixed #69195, #56821
protected override Type CheckAttributeType (EmitContext ec)
{
- NamespaceEntry old = ec.DeclSpace.NamespaceEntry;
- if (old == null || old.NS == null || old.NS == Namespace.Root)
+ // RootContext.Tree.Types has a single NamespaceEntry which gets overwritten
+ // each time a new file is parsed. However, we need to use the NamespaceEntry
+ // in effect where the attribute was used. Since code elsewhere cannot assume
+ // that the NamespaceEntry is right, just overwrite it.
+ //
+ // FIXME: Check every place the NamespaceEntry of RootContext.Tree.Types is used
+ // to ensure the right one is used.
+ if (ec.DeclSpace == RootContext.Tree.Types)
ec.DeclSpace.NamespaceEntry = ns;
+
return base.CheckAttributeType (ec);
}
}
if (OptAttributes == null)
return null;
- EmitContext temp_ec = new EmitContext (new RootTypes (), Mono.CSharp.Location.Null, null, null, 0, false);
+ EmitContext temp_ec = new EmitContext (RootContext.Tree.Types, Mono.CSharp.Location.Null, null, null, 0, false);
Attribute a = OptAttributes.Search (TypeManager.cls_compliant_attribute_type, temp_ec);
if (a != null) {
a.Resolve (temp_ec);