Skip to content

Commit 968f350

Browse files
committed
ASTMangler: skip mangling Copyable dependents
Typically, a conformance that is dependent on a conformance to a marker protocol never reaches this point in the compiler, where we're mangling the metadata for an opaque return type. But with the invertible protocols like Copyable, we do permit them, so we should avoid mangling Copyable as that's generally ABI incompatible with existing code. resolves rdar://135310019 (cherry picked from commit 6f6a46f)
1 parent 5bbf725 commit 968f350

File tree

2 files changed

+35
-0
lines changed

2 files changed

+35
-0
lines changed

lib/AST/ASTMangler.cpp

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4196,6 +4196,12 @@ 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;
4204+
41994205
if (conformingType->isTypeParameter()) {
42004206
assert(genericSig && "Need a generic signature to resolve conformance");
42014207
auto path = genericSig->getConformancePath(conformingType,
Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
// RUN: %target-run-simple-swift(-Xfrontend -disable-availability-checking) | %FileCheck %s
2+
// RUN: %target-run-simple-swift(-Xfrontend -disable-availability-checking -O) | %FileCheck %s
3+
4+
// REQUIRES: executable_test
5+
6+
// UNSUPPORTED: use_os_stdlib
7+
// UNSUPPORTED: back_deployment_runtime
8+
9+
protocol Marked {
10+
func announce()
11+
}
12+
extension Marked {
13+
func announce() { print("\(Self.self) is Marked") }
14+
}
15+
16+
struct ConcreteWrapper<Wrapped> {}
17+
extension ConcreteWrapper: Marked where Wrapped: Marked {}
18+
19+
struct Hello<T: ~Copyable> {}
20+
extension Hello: Marked {}
21+
22+
func makeWrapper<P>(wrapping _: P.Type) -> some Marked {
23+
ConcreteWrapper<Hello<P>>()
24+
}
25+
26+
do {
27+
let markedVal = makeWrapper(wrapping: String.self)
28+
markedVal.announce() // CHECK: ConcreteWrapper<Hello<String>> is Marked
29+
}

0 commit comments

Comments
 (0)