+2005-06-07 Raja R Harinath <rharinath@novell.com>
+
+ Ensure that partial classes are registered in their enclosing
+ namespace. Initial part of fix of #75160.
+ * tree.cs (Tree.RecordDecl): Add new namespace argument.
+ Register declspace with namespace here, not in
+ DeclSpace.RecordDecl.
+ * cs-parser.jay: Pass namespace to RecordDecl.
+ * class.cs (PartialContainer.Create): Likewise.
+ (ClassPart.DefineType): New sanity-check. Throws an exception if
+ called.
+ * decl.cs (Declspace.RecordDecl): Remove.
+ * namespace.cs (NamespaceEntry.DefineName): Remove.
+
2005-06-06 Marek Safar <marek.safar@seznam.cz>
* rootcontext.cs: Reset TargetExt as well.
parent = ((ClassPart) parent).PartialContainer;
pc = new PartialContainer (ns.NS, parent, member_name, mod_flags, kind, loc);
- RootContext.Tree.RecordDecl (member_name, pc);
+ RootContext.Tree.RecordDecl (ns.NS, member_name, pc);
if (kind == Kind.Interface)
parent.AddInterface (pc);
return PartialContainer.BaseCache;
}
}
+
+ public override TypeBuilder DefineType ()
+ {
+ throw new InternalErrorException ("Should not get here");
+ }
+
}
public abstract class ClassOrStruct : TypeContainer {
current_container.AddClassOrStruct (current_class);
current_container = current_class;
- RootContext.Tree.RecordDecl (name, current_class);
+ RootContext.Tree.RecordDecl (current_namespace.NS, name, current_class);
}
}
opt_class_base
current_container.AddInterface (current_class);
current_container = current_class;
- RootContext.Tree.RecordDecl (name, current_class);
+ RootContext.Tree.RecordDecl (current_namespace.NS, name, current_class);
}
}
opt_class_base
}
current_container.AddEnum (e);
- RootContext.Tree.RecordDecl (name, e);
+ RootContext.Tree.RecordDecl (current_namespace.NS, name, e);
$$ = e;
}
}
current_container.AddDelegate (del);
- RootContext.Tree.RecordDecl (name, del);
+ RootContext.Tree.RecordDecl (current_namespace.NS, name, del);
current_delegate = del;
}
current_container.AddClassOrStruct (current_class);
current_container = current_class;
- RootContext.Tree.RecordDecl (name, current_class);
+ RootContext.Tree.RecordDecl (current_namespace.NS, name, current_class);
}
}
opt_class_base
return false;
}
- public void RecordDecl ()
- {
- if ((NamespaceEntry != null) && (Parent == RootContext.Tree.Types))
- NamespaceEntry.DefineName (MemberName.Basename, this);
- }
-
/// <summary>
/// Returns the MemberCore associated with a given name in the declaration
/// space. It doesn't return method based symbols !!
}
}
- public void DefineName (string name, IAlias o)
- {
- ns.DefineName (name, o);
- }
-
/// <summary>
/// Records a new namespace for resolving name references
/// </summary>
decls = new Hashtable ();
}
- public void RecordDecl (MemberName name, DeclSpace ds)
+ public void RecordDecl (Namespace ns, MemberName name, DeclSpace ds)
{
DeclSpace other = (DeclSpace) decls [name];
if (other != null){
+ Report.SymbolRelatedToPreviousError (other);
+
PartialContainer other_pc = other as PartialContainer;
- if ((ds is TypeContainer) && (other_pc != null)) {
+ if (ds is TypeContainer && other_pc != null)
Report.Error (
260, ds.Location, "Missing partial modifier " +
- "on declaration of type `{0}'; another " +
+ "on declaration of type '{0}'; another " +
"partial implementation of this type exists",
name);
-
- Report.LocationOfPreviousError (other.Location);
- return;
- }
-
- Report.SymbolRelatedToPreviousError (
- other.Location, other.GetSignatureForError ());
-
- Report.Error (
- 101, ds.Location,
- "There is already a definition for `" + name + "'");
+ else
+ Report.Error (
+ 101, ds.Location,
+ "There is already a definition for '{0}'", name);
return;
}
- ds.RecordDecl ();
-
decls.Add (name, ds);
+
+ if (ds.Parent == Types)
+ ns.DefineName (name.Basename, ds);
}
//