Skip to content

Commit aaa632c

Browse files
authored
Merge pull request swiftlang#76411 from kavon/release/6.0-ncgenerics-opaque-dependent-conformance-mangling
[release/6.0] ASTMangler: skip mangling Copyable dependents
2 parents 6dedb72 + 395a05c commit aaa632c

File tree

2 files changed

+43
-0
lines changed

2 files changed

+43
-0
lines changed

lib/AST/ASTMangler.cpp

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

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();
4206+
41994207
if (conformingType->isTypeParameter()) {
42004208
assert(genericSig && "Need a generic signature to resolve conformance");
4209+
if (forInvertible)
4210+
return;
4211+
42014212
auto path = genericSig->getConformancePath(conformingType,
42024213
conformance.getAbstract());
42034214
appendDependentProtocolConformance(path, genericSig);
42044215
} else if (auto opaqueType = conformingType->getAs<OpaqueTypeArchetypeType>()) {
4216+
if (forInvertible)
4217+
return;
4218+
42054219
GenericSignature opaqueSignature =
42064220
opaqueType->getDecl()->getOpaqueInterfaceGenericSignature();
42074221
ConformancePath conformancePath =
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)