@@ -1082,6 +1082,7 @@ void IRGenerator::emitTypeMetadataRecords() {
10821082void IRGenerator::emitLazyDefinitions () {
10831083 while (!LazyTypeMetadata.empty () ||
10841084 !LazyTypeContextDescriptors.empty () ||
1085+ !LazyOpaqueTypeDescriptors.empty () ||
10851086 !LazyFieldDescriptors.empty () ||
10861087 !LazyFunctionDefinitions.empty () ||
10871088 !LazyWitnessTables.empty ()) {
@@ -1106,6 +1107,15 @@ void IRGenerator::emitLazyDefinitions() {
11061107 emitLazyTypeContextDescriptor (*IGM.get (), type,
11071108 RequireMetadata_t (entry.IsMetadataUsed ));
11081109 }
1110+ while (!LazyOpaqueTypeDescriptors.empty ()) {
1111+ OpaqueTypeDecl *type = LazyOpaqueTypeDescriptors.pop_back_val ();
1112+ auto &entry = LazyOpaqueTypes.find (type)->second ;
1113+ assert (hasLazyMetadata (type));
1114+ assert (entry.IsDescriptorUsed && !entry.IsDescriptorEmitted );
1115+ entry.IsDescriptorEmitted = true ;
1116+ CurrentIGMPtr IGM = getGenModule (type->getDeclContext ());
1117+ IGM->emitOpaqueTypeDecl (type);
1118+ }
11091119 while (!LazyFieldDescriptors.empty ()) {
11101120 NominalTypeDecl *type = LazyFieldDescriptors.pop_back_val ();
11111121 CurrentIGMPtr IGM = getGenModule (type->getDeclContext ());
@@ -1266,7 +1276,10 @@ void IRGenerator::noteUseOfFieldDescriptor(NominalTypeDecl *type) {
12661276void IRGenerator::noteUseOfOpaqueTypeDescriptor (OpaqueTypeDecl *opaque) {
12671277 if (!opaque)
12681278 return ;
1269-
1279+
1280+ if (!hasLazyMetadata (opaque))
1281+ return ;
1282+
12701283 auto insertResult = LazyOpaqueTypes.try_emplace (opaque);
12711284 auto &entry = insertResult.first ->second ;
12721285
0 commit comments