Skip to content

Commit 395a05c

Browse files
committed
ASTMangler: sink fix to be more safe
My previous fix in `6f6a46f` was the correct fix in theory, but in practice it could accidentally change the mangling of something I haven't considered, which would break ABI with Swift 6.0 I've narrowed that fix here to only affect dependent conformances specifically for Copyable/Escapable. The existing code in `appendDependentProtocolConformance` would always reach a trap because we're mangling a conformance path that ends with Copyable/Escapable. We can assume no such symbol has been successfully been mangled before, thanks to the pre-existing skip in `conformanceRequirementIndex`, so there's no risk of ABI change. rdar://135310019 (cherry picked from commit 793b46f)
1 parent 968f350 commit 395a05c

File tree

1 file changed

+13
-5
lines changed

1 file changed

+13
-5
lines changed

lib/AST/ASTMangler.cpp

Lines changed: 13 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -4196,18 +4196,26 @@ void ASTMangler::appendAnyProtocolConformance(
41964196
conformance.getRequirement()->isMarkerProtocol())
41974197
return;
41984198

4199-
// While all invertible protocols are marker protocols, do not mangle them for
4200-
// compatability reasons. See equivalent hack in `conformanceRequirementIndex`
4201-
// where only invertible protocols are unconditionally skipped.
4202-
if (conformance.getRequirement()->getInvertibleProtocolKind())
4203-
return;
4199+
// While all invertible protocols are marker protocols, do not mangle them
4200+
// as a dependent conformance. See `conformanceRequirementIndex` which skips
4201+
// these, too. In theory, invertible conformances should never be mangled,
4202+
// but we *might* have let that slip by for the other cases below, so the
4203+
// early-exits are highly conservative.
4204+
const bool forInvertible =
4205+
conformance.getRequirement()->getInvertibleProtocolKind().has_value();
42044206

42054207
if (conformingType->isTypeParameter()) {
42064208
assert(genericSig && "Need a generic signature to resolve conformance");
4209+
if (forInvertible)
4210+
return;
4211+
42074212
auto path = genericSig->getConformancePath(conformingType,
42084213
conformance.getAbstract());
42094214
appendDependentProtocolConformance(path, genericSig);
42104215
} else if (auto opaqueType = conformingType->getAs<OpaqueTypeArchetypeType>()) {
4216+
if (forInvertible)
4217+
return;
4218+
42114219
GenericSignature opaqueSignature =
42124220
opaqueType->getDecl()->getOpaqueInterfaceGenericSignature();
42134221
ConformancePath conformancePath =

0 commit comments

Comments
 (0)