@@ -321,9 +321,21 @@ namespace {
321
321
const ClassLayout *abstractLayout) {
322
322
for (VarDecl *var : theClass->getStoredProperties ()) {
323
323
SILType type = classType.getFieldType (var, IGM.getSILModule ());
324
- auto &eltType = IGM.getTypeInfo (type);
324
+ auto &eltTypeForAccess = IGM.getTypeInfo (type);
325
325
326
- if (!eltType.isFixedSize ()) {
326
+ // For now, the Objective-C runtime cannot support dynamic layout of
327
+ // classes that contain resilient value types, so we just look through
328
+ // the resilience boundary and assume fragile layout for class ivars
329
+ // instead.
330
+ Optional<CompletelyFragileScope> generateStaticLayoutRAII;
331
+
332
+ if (!IGM.IRGen .Opts .EnableClassResilience &&
333
+ !isa<FixedTypeInfo>(eltTypeForAccess))
334
+ generateStaticLayoutRAII.emplace (IGM);
335
+
336
+ auto &eltTypeForLayout = IGM.getTypeInfo (type);
337
+
338
+ if (!eltTypeForLayout.isFixedSize ()) {
327
339
ClassMetadataRequiresDynamicInitialization = true ;
328
340
ClassHasFixedSize = false ;
329
341
@@ -335,7 +347,8 @@ namespace {
335
347
assert (!abstractLayout ||
336
348
abstractLayout->getFieldIndex (var) == fieldIndex);
337
349
338
- Elements.push_back (ElementLayout::getIncomplete (eltType, eltType));
350
+ Elements.push_back (ElementLayout::getIncomplete (eltTypeForLayout,
351
+ eltTypeForAccess));
339
352
AllStoredProperties.push_back (var);
340
353
AllFieldAccesses.push_back (getFieldAccess (abstractLayout, fieldIndex));
341
354
}
0 commit comments