diff --git a/mcs/errors/CS0101-7-2.cs b/mcs/errors/CS0101-7-2.cs new file mode 100644 index 0000000000000..90cf116b98789 --- /dev/null +++ b/mcs/errors/CS0101-7-2.cs @@ -0,0 +1,5 @@ +// CS0101: The namespace `global::' already contains a definition for `Test' +// Line: 5 +// Compiler options: CS0101-7-2.cs + +class Test {} diff --git a/mcs/errors/cs0101-7.cs b/mcs/errors/cs0101-7.cs new file mode 100644 index 0000000000000..90cf116b98789 --- /dev/null +++ b/mcs/errors/cs0101-7.cs @@ -0,0 +1,5 @@ +// CS0101: The namespace `global::' already contains a definition for `Test' +// Line: 5 +// Compiler options: CS0101-7-2.cs + +class Test {} diff --git a/mcs/mcs/class.cs b/mcs/mcs/class.cs index 2ea5321014f63..dc173d7a3ac12 100644 --- a/mcs/mcs/class.cs +++ b/mcs/mcs/class.cs @@ -70,6 +70,12 @@ public TypeContainer (TypeContainer parent, MemberName name, Attributes attrs, M } } + public Dictionary DefinedNames { + get { + return defined_names; + } + } + public TypeDefinition PartialContainer { get { return main_container; diff --git a/mcs/mcs/namespace.cs b/mcs/mcs/namespace.cs index 02f1f2159eaa6..c26fc0a3c87ad 100644 --- a/mcs/mcs/namespace.cs +++ b/mcs/mcs/namespace.cs @@ -799,8 +799,10 @@ public override void AddTypeContainer (TypeContainer tc) name = mn.Name; } + var names_container = Parent == null ? Module : (TypeContainer) this; + MemberCore mc; - if (defined_names.TryGetValue (name, out mc)) { + if (names_container.DefinedNames.TryGetValue (name, out mc)) { if (tc is NamespaceContainer && mc is NamespaceContainer) { containers.Add (tc); return; @@ -814,7 +816,7 @@ public override void AddTypeContainer (TypeContainer tc) GetSignatureForError (), mn.GetSignatureForError ()); } } else { - defined_names.Add (name, tc); + names_container.DefinedNames.Add (name, tc); } base.AddTypeContainer (tc);