Skip to content

Commit 6f6a46f

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
1 parent 736faac commit 6f6a46f

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
@@ -4201,6 +4201,12 @@ void ASTMangler::appendAnyProtocolConformance(
42014201
conformance.getRequirement()->isMarkerProtocol())
42024202
return;
42034203

4204+
// While all invertible protocols are marker protocols, do not mangle them for
4205+
// compatability reasons. See equivalent hack in `conformanceRequirementIndex`
4206+
// where only invertible protocols are unconditionally skipped.
4207+
if (conformance.getRequirement()->getInvertibleProtocolKind())
4208+
return;
4209+
42044210
if (conformingType->isTypeParameter()) {
42054211
assert(genericSig && "Need a generic signature to resolve conformance");
42064212
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)