Skip to content

Commit d67f774

Browse files
authored
Merge pull request #41671 from DougGregor/suppress-marker-protocols-in-existential-metadata
2 parents 941fc8d + 93703ef commit d67f774

File tree

2 files changed

+37
-2
lines changed

2 files changed

+37
-2
lines changed

lib/IRGen/MetadataRequest.cpp

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1681,8 +1681,12 @@ namespace {
16811681
}
16821682

16831683
auto layout = type.getExistentialLayout();
1684-
1685-
auto protocols = layout.getProtocols();
1684+
1685+
SmallVector<ProtocolType *, 4> protocols;
1686+
for (auto proto : layout.getProtocols()) {
1687+
if (!proto->getDecl()->isMarkerProtocol())
1688+
protocols.push_back(proto);
1689+
}
16861690

16871691
// Collect references to the protocol descriptors.
16881692
auto descriptorArrayTy
Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
// RUN: %target-swift-frontend -primary-file %s -target %target-cpu-apple-macosx10.15 -emit-ir -o - | %FileCheck %s
2+
3+
// Marker protocols should have no ABI impact at all, so this source file checks
4+
// for the absence of symbols related to marker protocols.
5+
6+
// CHECK-NOT: $s26marker_protocol_backdeploy1PP
7+
// CHECK-NOT: $s26marker_protocol_backdeploy1PMp
8+
9+
// REQUIRES: PTRSIZE=64
10+
// REQUIRES: OS=macosx
11+
12+
@_marker public protocol P { }
13+
public protocol Q: P { }
14+
protocol R { }
15+
16+
17+
// Suppress marker protocols when forming existentials at runtime
18+
public func takeAnyType<T>(_: T.Type) { }
19+
20+
// CHECK-LABEL: define {{.*}}@"$ss8Sendable_26marker_protocol_backdeploy1QAB1RpMa"
21+
// CHECK: ss8Sendable_26marker_protocol_backdeploy1QAB1RpML
22+
// CHECK-NOT: Sendable
23+
// CHECK: s26marker_protocol_backdeploy1QMp
24+
// CHECK-NOT: Sendable
25+
// CHECK: s26marker_protocol_backdeploy1RMp
26+
// CHECK-NOT: SENDABLE
27+
// CHECK: swift_getExistentialTypeMetadata
28+
public func passExistentialType() {
29+
typealias Fn = (Sendable & P & Q & R) async -> Void
30+
takeAnyType(Fn.self)
31+
}

0 commit comments

Comments
 (0)