Skip to content

Commit 346c3f7

Browse files
authored
Merge pull request #59103 from DougGregor/marker-protocol-retroactive-mangle-5.7
[AST Mangler] Don't mangle marker protocols in retroactive conformances.
2 parents a00d319 + 57d18f7 commit 346c3f7

File tree

2 files changed

+15
-0
lines changed

2 files changed

+15
-0
lines changed

lib/AST/ASTMangler.cpp

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1637,6 +1637,10 @@ static bool isRetroactiveConformance(const RootProtocolConformance *root) {
16371637
return false; // self-conformances are never retroactive. nor are builtin.
16381638
}
16391639

1640+
// Don't consider marker protocols at all.
1641+
if (conformance->getProtocol()->isMarkerProtocol())
1642+
return false;
1643+
16401644
return conformance->isRetroactive();
16411645
}
16421646

@@ -1682,6 +1686,12 @@ void ASTMangler::appendRetroactiveConformances(SubstitutionMap subMap,
16821686

16831687
unsigned numProtocolRequirements = 0;
16841688
for (auto conformance : subMap.getConformances()) {
1689+
if (conformance.isInvalid())
1690+
continue;
1691+
1692+
if (conformance.getRequirement()->isMarkerProtocol())
1693+
continue;
1694+
16851695
SWIFT_DEFER {
16861696
++numProtocolRequirements;
16871697
};

test/IRGen/marker_protocol.swift

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -57,9 +57,14 @@ public func markerInDictionary() -> Any {
5757
// CHECK: swiftcc void @"$s15marker_protocol7genericyyxAA1PRzlF"(%swift.opaque* noalias nocapture %0, %swift.type* %T)
5858
public func generic<T: P>(_: T) { }
5959

60+
public struct GenericType<T: Hashable & P> { }
61+
62+
// CHECK-LABEL: @"$s15marker_protocol11testGeneric1i5arrayySi_SaySiGtF"(
6063
public func testGeneric(i: Int, array: [Int]) {
6164
generic(i)
6265
generic(array)
66+
// CHECK: __swift_instantiateConcreteTypeFromMangledName{{.*}}$s15marker_protocol11GenericTypeVySaySiGGmMD
67+
print(GenericType<[Int]>.self)
6368
}
6469

6570
// Forming an existential involving a marker protocol would crash the compiler

0 commit comments

Comments
 (0)