Fix #79584
authorRaja R Harinath <harinath@hurrynot.org>
Fri, 6 Oct 2006 08:57:12 +0000 (08:57 -0000)
committerRaja R Harinath <harinath@hurrynot.org>
Fri, 6 Oct 2006 08:57:12 +0000 (08:57 -0000)
* mcs/class.cs (DefineTypeBuilder): Check circular dependencies before
setting the parent of the TypeBuilder.
(CheckRecursiveDefinition): Don't use 'BaseType', since
it may not be valid until after DefineTypeBuilder.  Use
'base_type' instead.
* errors/cs0146-5.cs: New test from #79584.

svn path=/trunk/mcs/; revision=66334

mcs/errors/ChangeLog
mcs/errors/cs0146-5.cs [new file with mode: 0644]
mcs/mcs/ChangeLog
mcs/mcs/class.cs

index c3cc5db9813aeaf4af16a59111336a52123aa4c0..a7dec6c772f3bde9734fa2d00057cefea887d041 100644 (file)
@@ -1,3 +1,7 @@
+2006-10-06  Raja R Harinath  <rharinath@novell.com>
+
+       * cs0146-5.cs: New test from #79584.
+
 2006-10-04  Martin Baulig  <martin@ximian.com>
 
        * known-issues-mcs, known-issues-gmcs: Update; the anonymous
diff --git a/mcs/errors/cs0146-5.cs b/mcs/errors/cs0146-5.cs
new file mode 100644 (file)
index 0000000..8c317fa
--- /dev/null
@@ -0,0 +1,4 @@
+// cs0146-5.cs: Circular base class dependency involving `A' and `A'
+// Line: 4
+
+class A : A {}
index 282a66ed206754551ae674c5ebba484132dc91e3..7f19dea741d887f6db5336338d8cf95b8e00d5ed 100644 (file)
@@ -1,3 +1,12 @@
+2006-10-06  Raja R Harinath  <rharinath@novell.com>
+
+       Fix #79584
+       * class.cs (DefineTypeBuilder): Check circular dependencies before
+       setting the parent of the TypeBuilder.
+       (CheckRecursiveDefinition): Don't use 'BaseType', since
+       it may not be valid until after DefineTypeBuilder.  Use
+       'base_type' instead.
+
 2006-10-04  Martin Baulig  <martin@ximian.com>
 
        Merged the Anonymous Methods patch.
index baf304f0d7a55ba95449aaf9ea1bc003a82b3906..790c6aa73f67560d289126919a08402382aa531b 100644 (file)
@@ -1226,33 +1226,29 @@ namespace Mono.CSharp {
                        if (!(this is CompilerGeneratedClass))
                                RootContext.RegisterOrder (this); 
 
-                       if (base_type != null) {
-                               if (IsGeneric && TypeManager.IsAttributeType (base_type.Type)) {
-                                       Report.Error (698, base_type.Location,
-                                                     "A generic type cannot derive from `{0}' " +
-                                                     "because it is an attribute class",
-                                                     base_type.Name);
-                                       return false;
-                               }
+                       if (IsGeneric && base_type != null && TypeManager.IsAttributeType (base_type.Type)) {
+                               Report.Error (698, base_type.Location,
+                                             "A generic type cannot derive from `{0}' because it is an attribute class",
+                                             base_type.Name);
+                               return false;
+                       }
+
+                       if (!CheckRecursiveDefinition (this))
+                               return false;
 
+                       if (base_type != null) {
                                TypeBuilder.SetParent (base_type.Type);
 
                                ObsoleteAttribute obsolete_attr = AttributeTester.GetObsoleteAttribute (base_type.Type);
-                               if (obsolete_attr != null && !IsInObsoleteScope) {
+                               if (obsolete_attr != null && !IsInObsoleteScope)
                                        AttributeTester.Report_ObsoleteMessage (obsolete_attr, base_type.GetSignatureForError (), Location);
-                               }
-                       }
-
-                       if (!CheckRecursiveDefinition (this)) {
-                               return false;
                        }
 
                        // add interfaces that were not added at type creation
                        if (iface_exprs != null) {
                                ifaces = TypeManager.ExpandInterfaces (iface_exprs);
-                               if (ifaces == null) {
+                               if (ifaces == null)
                                        return false;
-                               }
 
                                foreach (Type itype in ifaces)
                                        TypeBuilder.AddInterfaceImplementation (itype);
@@ -1264,9 +1260,8 @@ namespace Mono.CSharp {
                                                        oa, ie.GetSignatureForError (), Location);
                                }
 
-                               if (!CheckGenericInterfaces (ifaces)) {
+                               if (!CheckGenericInterfaces (ifaces))
                                        return false;
-                               }
 
                                TypeManager.RegisterBuilder (TypeBuilder, ifaces);
                        }
@@ -1544,8 +1539,8 @@ namespace Mono.CSharp {
 
                        InTransit = tc;
 
-                       if (BaseType != null) {
-                               Type t = TypeManager.DropGenericTypeArguments (BaseType);
+                       if (base_type != null) {
+                               Type t = TypeManager.DropGenericTypeArguments (base_type.Type);
                                TypeContainer ptc = TypeManager.LookupTypeContainer (t);
                                if ((ptc != null) && !ptc.CheckRecursiveDefinition (this))
                                        return false;