@@ -1154,6 +1154,27 @@ void IRGenerator::emitLazyDefinitions() {
1154
1154
!LazyFieldTypes.empty () ||
1155
1155
!LazyWitnessTables.empty ()) {
1156
1156
1157
+ while (!LazyFieldTypes.empty ()) {
1158
+ auto info = LazyFieldTypes.pop_back_val ();
1159
+ auto &IGM = *info.IGM ;
1160
+
1161
+ for (auto fieldType : info.fieldTypes ) {
1162
+ if (fieldType->hasArchetype ())
1163
+ continue ;
1164
+
1165
+ // All of the required attributes are going to be preserved
1166
+ // by field reflection metadata in the mangled name, so
1167
+ // there is no need to worry about ownership semantics here.
1168
+ if (auto refStorTy = dyn_cast<ReferenceStorageType>(fieldType))
1169
+ fieldType = refStorTy.getReferentType ();
1170
+
1171
+ // Make sure that all of the field type metadata is forced,
1172
+ // otherwise there might be a problem when fields are accessed
1173
+ // through reflection.
1174
+ (void )irgen::getOrCreateTypeMetadataAccessFunction (IGM, fieldType);
1175
+ }
1176
+ }
1177
+
1157
1178
// Emit any lazy type metadata we require.
1158
1179
while (!LazyMetadata.empty ()) {
1159
1180
NominalTypeDecl *Nominal = LazyMetadata.pop_back_val ();
@@ -1171,21 +1192,6 @@ void IRGenerator::emitLazyDefinitions() {
1171
1192
emitLazyTypeContextDescriptor (*IGM.get (), Nominal);
1172
1193
}
1173
1194
}
1174
- while (!LazyFieldTypes.empty ()) {
1175
- auto info = LazyFieldTypes.pop_back_val ();
1176
- auto &IGM = *info.IGM ;
1177
-
1178
- for (auto fieldType : info.fieldTypes ) {
1179
- if (fieldType->isAnyExistentialType ())
1180
- continue ;
1181
-
1182
- // Ensure that all of the foreign metadata is forced, otherwise
1183
- // there might be a problem when fields are accessed through
1184
- // reflection.
1185
- if (IGM.requiresForeignTypeMetadata (fieldType))
1186
- (void )IGM.getAddrOfForeignTypeMetadataCandidate (fieldType);
1187
- }
1188
- }
1189
1195
while (!LazyWitnessTables.empty ()) {
1190
1196
SILWitnessTable *wt = LazyWitnessTables.pop_back_val ();
1191
1197
CurrentIGMPtr IGM = getGenModule (wt->getConformance ()->getDeclContext ());
0 commit comments