Skip to content

Commit 034dab8

Browse files
authored
Merge pull request #76293 from kavon/ncgenerics-opaque-dependent-conformance-mangling
ASTMangler: skip mangling Copyable dependents
2 parents 60f049d + 6f6a46f commit 034dab8

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
@@ -4215,6 +4215,12 @@ void ASTMangler::appendAnyProtocolConformance(
42154215
conformance.getRequirement()->isMarkerProtocol())
42164216
return;
42174217

4218+
// While all invertible protocols are marker protocols, do not mangle them for
4219+
// compatability reasons. See equivalent hack in `conformanceRequirementIndex`
4220+
// where only invertible protocols are unconditionally skipped.
4221+
if (conformance.getRequirement()->getInvertibleProtocolKind())
4222+
return;
4223+
42184224
if (conformingType->isTypeParameter()) {
42194225
assert(genericSig && "Need a generic signature to resolve conformance");
42204226
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)