2005-08-01 Marek Safar <marek.safar@seznam.cz>
[mono.git] / mcs / mcs / tree.cs
index a5b2ba8c2f01a5ccbf574db3e7ad69aea011bc88..50b4dfd57738c04b3a2a2e8bdf2df4def39e5a7a 100644 (file)
@@ -45,30 +45,12 @@ namespace Mono.CSharp
                        decls = new Hashtable ();
                }
 
-               // TODO: Move this check to current_container.Add..... method
-               // I guess we can save cpu&mem
                public void RecordDecl (Namespace ns, MemberName name, DeclSpace ds)
                {
-                       DeclSpace other = (DeclSpace) decls [name];
-                       if (other != null){
-                               Report.SymbolRelatedToPreviousError (other);
+                       // This is recorded for tracking inner partial classes only
+                       decls [name] = ds;
 
-                               PartialContainer other_pc = other as PartialContainer;
-                               if (ds is TypeContainer && other_pc != null) {
-                                       Report.SymbolRelatedToPreviousError (other);
-                                       Report.Error (260, ds.Location,
-                                               "Missing partial modifier on declaration of type `{0}'. Another partial declaration of this type exists",
-                                               name);
-                               }
-                               else
-                                       Report.Error (101, ds.Location, 
-                                               "The namespace `{0}' already contains a definition for `{1}'", ns.GetSignatureForError (), name.Name);
-                               return;
-                       }
-
-                       decls.Add (name, ds);
-
-                       if (ds.Parent == Types)
+                       if (ds.Parent == root_types)
                                ns.AddDeclSpace (name.Basename, ds);
                }
                
@@ -89,7 +71,7 @@ namespace Mono.CSharp
                }
        }
 
-       public class RootTypes : TypeContainer
+       public sealed class RootTypes : TypeContainer
        {
                public RootTypes ()
                        : base (null, null, MemberName.Null, null, Kind.Root,
@@ -113,6 +95,9 @@ namespace Mono.CSharp
                        return "";
                }
 
-
+               protected override bool AddToTypeContainer (DeclSpace ds)
+               {
+                       return AddToContainer (ds, ds.Name);
+               }
        }
 }