Author: zoltan
Date: 2005-04-28 10:06:32 -0400 (Thu, 28 Apr 2005)
New Revision: 43724

Modified:
   trunk/mono/mono/metadata/ChangeLog
   trunk/mono/mono/metadata/class.c
Log:
2005-04-28  Zoltan Varga  <[EMAIL PROTECTED]>

        * class.c (mono_class_init): Applied patch from Ankit Jain 
        ([EMAIL PROTECTED]). Avoid pending init errors when a field refers
        to a nested class using a typeref. Fixes #74734.


Modified: trunk/mono/mono/metadata/ChangeLog
===================================================================
--- trunk/mono/mono/metadata/ChangeLog  2005-04-28 13:44:08 UTC (rev 43723)
+++ trunk/mono/mono/metadata/ChangeLog  2005-04-28 14:06:32 UTC (rev 43724)
@@ -1,5 +1,9 @@
 2005-04-28  Zoltan Varga  <[EMAIL PROTECTED]>
 
+       * class.c (mono_class_init): Applied patch from Ankit Jain 
+       ([EMAIL PROTECTED]). Avoid pending init errors when a field refers
+       to a nested class using a typeref. Fixes #74734.
+
        * icall.c (ves_icall_System_Reflection_Assembly_GetModulesInternal): Fix
        this for dynamic modules.
 

Modified: trunk/mono/mono/metadata/class.c
===================================================================
--- trunk/mono/mono/metadata/class.c    2005-04-28 13:44:08 UTC (rev 43723)
+++ trunk/mono/mono/metadata/class.c    2005-04-28 14:06:32 UTC (rev 43724)
@@ -1654,6 +1654,15 @@
        }
 
        if (class->init_pending) {
+               /*
+                * We might be called recursively from mono_class_from_typeref 
if
+                * one of our fields has a type which is a nested type of this 
class,
+                * and the compiler encodes it as a typeref, like older 
versions of
+                * MS ilasm do.
+                */
+               if (class->size_inited)
+                       return;
+
                /* this indicates a cyclic dependency */
                g_error ("pending init %s.%s\n", class->name_space, 
class->name);
        }
@@ -1736,6 +1745,19 @@
        if (class->parent && !class->parent->inited)
                mono_class_init (class->parent);
 
+       if (!class->generic_class) {
+               i = mono_metadata_nesting_typedef (class->image, 
class->type_token, 1);
+               while (i) {
+                       MonoClass* nclass;
+                       guint32 cols [MONO_NESTED_CLASS_SIZE];
+                       mono_metadata_decode_row (&class->image->tables 
[MONO_TABLE_NESTEDCLASS], i - 1, cols, MONO_NESTED_CLASS_SIZE);
+                       nclass = mono_class_create_from_typedef (class->image, 
MONO_TOKEN_TYPE_DEF | cols [MONO_NESTED_CLASS_NESTED]);
+                       class->nested_classes = g_list_prepend 
(class->nested_classes, nclass);
+
+                       i = mono_metadata_nesting_typedef (class->image, 
class->type_token, i + 1);
+               }
+       }
+
        /*
         * Computes the size used by the fields, and their locations
         */
@@ -1780,19 +1802,6 @@
                }
        }
 
-       if (!class->generic_class) {
-               i = mono_metadata_nesting_typedef (class->image, 
class->type_token, 1);
-               while (i) {
-                       MonoClass* nclass;
-                       guint32 cols [MONO_NESTED_CLASS_SIZE];
-                       mono_metadata_decode_row (&class->image->tables 
[MONO_TABLE_NESTEDCLASS], i - 1, cols, MONO_NESTED_CLASS_SIZE);
-                       nclass = mono_class_create_from_typedef (class->image, 
MONO_TOKEN_TYPE_DEF | cols [MONO_NESTED_CLASS_NESTED]);
-                       class->nested_classes = g_list_prepend 
(class->nested_classes, nclass);
-
-                       i = mono_metadata_nesting_typedef (class->image, 
class->type_token, i + 1);
-               }
-       }
-
        mono_class_setup_supertypes (class);
 
        if (MONO_CLASS_IS_INTERFACE (class)) {

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

Reply via email to