mirror of
https://github.com/apple/swift.git
synced 2025-12-14 20:36:38 +01:00
IRGen: Perform completely fragile layout for all classes, not just @objc ancestry
Otherwise, Objective C categories don't work for classes with resilient fields, such as the value types defined in the Foundation overlay. Fixes <rdar://problem/40819319>, <https://bugs.swift.org/browse/SR-7882>.
This commit is contained in:
@@ -141,9 +141,9 @@ namespace {
|
||||
|
||||
unsigned NumInherited = 0;
|
||||
|
||||
// If the class has @objc ancestry, we lay out resiliently-typed fields
|
||||
// as if they were fragile.
|
||||
bool CompletelyFragileLayout = false;
|
||||
// For now we always lay out resiliently-typed fields as if they
|
||||
// were fragile.
|
||||
bool CompletelyFragileLayout;
|
||||
|
||||
// Does the class metadata require dynamic initialization above and
|
||||
// beyond what the runtime can automatically achieve?
|
||||
@@ -171,6 +171,11 @@ namespace {
|
||||
ReferenceCounting refcounting)
|
||||
: StructLayoutBuilder(IGM)
|
||||
{
|
||||
// Perform fragile layout if Objective-C interop is enabled.
|
||||
CompletelyFragileLayout =
|
||||
(IGM.Context.LangOpts.EnableObjCInterop &&
|
||||
!IGM.IRGen.Opts.EnableClassResilience);
|
||||
|
||||
// Start by adding a heap header.
|
||||
switch (refcounting) {
|
||||
case ReferenceCounting::Native:
|
||||
@@ -249,10 +254,6 @@ namespace {
|
||||
}
|
||||
|
||||
if (superclass->hasClangNode()) {
|
||||
// Perform fragile layout if the class has @objc ancestry.
|
||||
if (!IGM.IRGen.Opts.EnableClassResilience)
|
||||
CompletelyFragileLayout = true;
|
||||
|
||||
// If the superclass was imported from Objective-C, its size is
|
||||
// not known at compile time. However, since the field offset
|
||||
// vector only stores offsets of stored properties defined in
|
||||
|
||||
Reference in New Issue
Block a user