Author: raja
Date: 2006-10-06 04:57:12 -0400 (Fri, 06 Oct 2006)
New Revision: 66334

Added:
   trunk/mcs/errors/cs0146-5.cs
Modified:
   trunk/mcs/errors/ChangeLog
   trunk/mcs/mcs/ChangeLog
   trunk/mcs/mcs/class.cs
Log:
Fix #79584
* 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.


Modified: trunk/mcs/errors/ChangeLog
===================================================================
--- trunk/mcs/errors/ChangeLog  2006-10-06 05:42:14 UTC (rev 66333)
+++ trunk/mcs/errors/ChangeLog  2006-10-06 08:57:12 UTC (rev 66334)
@@ -1,3 +1,7 @@
+2006-10-06  Raja R Harinath  <[EMAIL PROTECTED]>
+
+       * cs0146-5.cs: New test from #79584.
+
 2006-10-04  Martin Baulig  <[EMAIL PROTECTED]>
 
        * known-issues-mcs, known-issues-gmcs: Update; the anonymous

Added: trunk/mcs/errors/cs0146-5.cs
===================================================================
--- trunk/mcs/errors/cs0146-5.cs        2006-10-06 05:42:14 UTC (rev 66333)
+++ trunk/mcs/errors/cs0146-5.cs        2006-10-06 08:57:12 UTC (rev 66334)
@@ -0,0 +1,4 @@
+// cs0146-5.cs: Circular base class dependency involving `A' and `A'
+// Line: 4
+
+class A : A {}


Property changes on: trunk/mcs/errors/cs0146-5.cs
___________________________________________________________________
Name: svn:mime-type
   + text/cpp
Name: svn:eol-style
   + native

Modified: trunk/mcs/mcs/ChangeLog
===================================================================
--- trunk/mcs/mcs/ChangeLog     2006-10-06 05:42:14 UTC (rev 66333)
+++ trunk/mcs/mcs/ChangeLog     2006-10-06 08:57:12 UTC (rev 66334)
@@ -1,3 +1,12 @@
+2006-10-06  Raja R Harinath  <[EMAIL PROTECTED]>
+
+       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  <[EMAIL PROTECTED]>
 
        Merged the Anonymous Methods patch.

Modified: trunk/mcs/mcs/class.cs
===================================================================
--- trunk/mcs/mcs/class.cs      2006-10-06 05:42:14 UTC (rev 66333)
+++ trunk/mcs/mcs/class.cs      2006-10-06 08:57:12 UTC (rev 66334)
@@ -1226,33 +1226,29 @@
                        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 @@
                                                        oa, 
ie.GetSignatureForError (), Location);
                                }
 
-                               if (!CheckGenericInterfaces (ifaces)) {
+                               if (!CheckGenericInterfaces (ifaces))
                                        return false;
-                               }
 
                                TypeManager.RegisterBuilder (TypeBuilder, 
ifaces);
                        }
@@ -1544,8 +1539,8 @@
 
                        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;

_______________________________________________
Mono-patches maillist  -  [email protected]
http://lists.ximian.com/mailman/listinfo/mono-patches

Reply via email to