**** Merged r45574 from MCS ****
authorMartin Baulig <martin@novell.com>
Thu, 23 Jun 2005 13:54:51 +0000 (13:54 -0000)
committerMartin Baulig <martin@novell.com>
Thu, 23 Jun 2005 13:54:51 +0000 (13:54 -0000)
svn path=/trunk/mcs/; revision=46426

mcs/gmcs/ChangeLog
mcs/gmcs/class.cs
mcs/gmcs/cs-parser.jay
mcs/gmcs/decl.cs
mcs/gmcs/namespace.cs
mcs/gmcs/tree.cs

index d9fffcdfee879efec75af2ce80ac76a014f50fdf..27b780b45f3e68539661ed5acd165e835d33228d 100644 (file)
@@ -1,3 +1,17 @@
+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.
index a3519e0ae9ee0da812d42c16dd944a3f6ad367f8..992f9acf102fa6360ee720903b7e7d6a61d55141 100644 (file)
@@ -2720,7 +2720,7 @@ namespace Mono.CSharp {
                                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);
@@ -2904,6 +2904,12 @@ namespace Mono.CSharp {
                                return PartialContainer.BaseCache;
                        }
                }
+
+               public override TypeBuilder DefineType ()
+               {
+                       throw new InternalErrorException ("Should not get here");
+               }
+
        }
 
        public abstract class ClassOrStruct : TypeContainer {
index 06a28d3720836dc77878610a274d24e38e913586..e0d6e29e01b11c97156afc9630531a873477c05f 100644 (file)
@@ -777,7 +777,7 @@ struct_declaration
 
                        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
@@ -1499,7 +1499,7 @@ interface_declaration
 
                        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
@@ -2440,7 +2440,7 @@ enum_declaration
                }
 
                current_container.AddEnum (e);
-               RootContext.Tree.RecordDecl (name, e);
+               RootContext.Tree.RecordDecl (current_namespace.NS, name, e);
                $$ = e;
 
          }
@@ -2544,7 +2544,7 @@ delegate_declaration
                }
 
                current_container.AddDelegate (del);
-               RootContext.Tree.RecordDecl (name, del);
+               RootContext.Tree.RecordDecl (current_namespace.NS, name, del);
 
                current_delegate = del;
          }
@@ -3715,7 +3715,7 @@ class_declaration
 
                        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
index 01501cfef6a24d1870bf7e660be8b7ce5c7449a0..f7ee83350ed0b6d3ba7af5055fdec28c8fb9f6f0 100644 (file)
@@ -701,12 +701,6 @@ namespace Mono.CSharp {
                        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 !!
index b97dfaae2edafe553dcb0e793eedcb94d1c64337..7da33b062d6b0f6a2af10d3490e8b29ccfea62fc 100644 (file)
@@ -398,11 +398,6 @@ namespace Mono.CSharp {
                        }
                }
 
-               public void DefineName (string name, IAlias o)
-               {
-                       ns.DefineName (name, o);
-               }
-
                /// <summary>
                ///   Records a new namespace for resolving name references
                /// </summary>
index b21fa4137948e6f5b681d5050a6bfd5850034932..e0453caf977b4ae6bd6d6b6b28de5dcf676e4424 100644 (file)
@@ -45,34 +45,30 @@ namespace Mono.CSharp
                        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);
                }
                
                //