mirror of
https://github.com/apple/swift.git
synced 2025-12-14 20:36:38 +01:00
[Serialization] Drop overridden relationship in constructors when safe
Deserialization recovery lead the compiler to drop public constructors overridding internal constructors. This limits the logic to dropping the overriding relationship instead of the whole constructor. This applies when the overriden constructor fails to deserialize and only when the overriding relationship was marked as not affecting ABI. rdar://104704832
This commit is contained in:
@@ -3535,7 +3535,8 @@ class Serializer::DeclSerializer : public DeclVisitor<DeclSerializer> {
|
||||
// its overrides after they've been compiled: if the declaration is '@objc'
|
||||
// and 'dynamic'. In that case, all accesses to the method or property will
|
||||
// go through the Objective-C method tables anyway.
|
||||
if (overridden->hasClangNode() || overridden->shouldUseObjCDispatch())
|
||||
if (!isa<ConstructorDecl>(override) &&
|
||||
(overridden->hasClangNode() || overridden->shouldUseObjCDispatch()))
|
||||
return false;
|
||||
|
||||
// In a public-override-internal case, the override doesn't have ABI
|
||||
@@ -4499,9 +4500,12 @@ public:
|
||||
uint8_t rawAccessLevel = getRawStableAccessLevel(ctor->getFormalAccess());
|
||||
|
||||
bool firstTimeRequired = ctor->isRequired();
|
||||
if (auto *overridden = ctor->getOverriddenDecl())
|
||||
auto *overridden = ctor->getOverriddenDecl();
|
||||
if (overridden) {
|
||||
if (firstTimeRequired && overridden->isRequired())
|
||||
firstTimeRequired = false;
|
||||
}
|
||||
bool overriddenAffectsABI = overriddenDeclAffectsABI(ctor, overridden);
|
||||
|
||||
unsigned abbrCode = S.DeclTypeAbbrCodes[ConstructorLayout::Code];
|
||||
ConstructorLayout::emitRecord(S.Out, S.ScratchRecord, abbrCode,
|
||||
@@ -4517,7 +4521,8 @@ public:
|
||||
ctor->getInitKind()),
|
||||
S.addGenericSignatureRef(
|
||||
ctor->getGenericSignature()),
|
||||
S.addDeclRef(ctor->getOverriddenDecl()),
|
||||
S.addDeclRef(overridden),
|
||||
overriddenAffectsABI,
|
||||
rawAccessLevel,
|
||||
ctor->needsNewVTableEntry(),
|
||||
firstTimeRequired,
|
||||
|
||||
Reference in New Issue
Block a user