diff --git a/lib/Reader/readerir.cpp b/lib/Reader/readerir.cpp index 5ecd477..93abfdc 100644 --- a/lib/Reader/readerir.cpp +++ b/lib/Reader/readerir.cpp @@ -1305,7 +1305,7 @@ Type *GenIR::getClassType(CORINFO_CLASS_HANDLE ClassHandle, bool IsRefClass, // causes trouble with certain recursive type graphs, for example: // // class A { B b; } - // class B : extends A { int c }; + // class B : extends A { int c; } // // We need to know the size of A before we can finish B. So we can't // ask for B's details while filling out A. @@ -1405,6 +1405,15 @@ Type *GenIR::getClassType(CORINFO_CLASS_HANDLE ClassHandle, bool IsRefClass, } } + // It's possible that while adding the fields to this struct we already + // completed the struct. For example: + // class A { B b; } + // struct B { A a; } + // In that case we are already done. + if (!StructTy->isOpaque()) { + return ResultTy; + } + // Install the field list (even if empty) to complete the struct. // Since padding is explicit, this is an LLVM packed struct. StructTy->setBody(Fields, true /* isPacked */);