@@ -50,6 +50,8 @@ internal static ClassBase GetClass(Type type)
5050 }
5151 cb = CreateClass ( type ) ;
5252 cache . Add ( type , cb ) ;
53+ // Initialize the object later, as this might call this GetClass method recursivly (for example when a nested class inherits its declaring class...)
54+ InitClassBase ( type , cb ) ;
5355 return cb ;
5456 }
5557
@@ -62,12 +64,6 @@ internal static ClassBase GetClass(Type type)
6264
6365 private static ClassBase CreateClass ( Type type )
6466 {
65- // First, we introspect the managed type and build some class
66- // information, including generating the member descriptors
67- // that we'll be putting in the Python class __dict__.
68-
69- ClassInfo info = GetClassInfo ( type ) ;
70-
7167 // Next, select the appropriate managed implementation class.
7268 // Different kinds of types, such as array types or interface
7369 // types, want to vary certain implementation details to make
@@ -115,6 +111,18 @@ private static ClassBase CreateClass(Type type)
115111 impl = new ClassObject ( type ) ;
116112 }
117113
114+
115+ return impl ;
116+ }
117+
118+ private static void InitClassBase ( Type type , ClassBase impl )
119+ {
120+ // First, we introspect the managed type and build some class
121+ // information, including generating the member descriptors
122+ // that we'll be putting in the Python class __dict__.
123+
124+ ClassInfo info = GetClassInfo ( type ) ;
125+
118126 impl . indexer = info . indexer ;
119127
120128 // Now we allocate the Python type object to reflect the given
@@ -182,10 +190,8 @@ private static ClassBase CreateClass(Type type)
182190 }
183191 }
184192
185- return impl ;
186193 }
187194
188-
189195 private static ClassInfo GetClassInfo ( Type type )
190196 {
191197 ClassInfo ci = new ClassInfo ( type ) ;
@@ -353,6 +359,7 @@ private static ClassInfo GetClassInfo(Type type)
353359 if ( ! ( tp . IsNestedPublic || tp . IsNestedFamily ||
354360 tp . IsNestedFamORAssem ) )
355361 continue ;
362+ // Note the given instance might be uninitialized
356363 ob = ClassManager . GetClass ( tp ) ;
357364 ci . members [ mi . Name ] = ob ;
358365 continue ;
0 commit comments