Skip to content

Commit 5ec5820

Browse files
committed
[IRGen] Fix placeholder logic for emission of conditionally inverted protocols
rdar://153681688 Instead fo counting the actual conformances, the logic took the size of the bit field, i.e. used the highest set bit, so when a type had a conditional conformance only on ~Escapable, but not on ~Copyable, it would still add 2 placeholders, but only fill one.
1 parent 09dc092 commit 5ec5820

File tree

2 files changed

+12
-3
lines changed

2 files changed

+12
-3
lines changed

lib/IRGen/GenMeta.cpp

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1393,12 +1393,13 @@ namespace {
13931393

13941394
// Create placeholders for the counts of the conditional requirements
13951395
// for each conditional conformance to a supressible protocol.
1396-
unsigned numProtocols = countBitsUsed(protocols.rawBits());
1396+
unsigned numProtocols = 0;
13971397
using PlaceholderPosition =
13981398
ConstantAggregateBuilderBase::PlaceholderPosition;
13991399
SmallVector<PlaceholderPosition, 2> countPlaceholders;
1400-
for (unsigned i : range(0, numProtocols)) {
1401-
(void)i;
1400+
for (auto kind : protocols) {
1401+
(void)kind;
1402+
numProtocols++;
14021403
countPlaceholders.push_back(
14031404
B.addPlaceholderWithSize(IGM.Int16Ty));
14041405
}
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
// RUN: %target-swift-frontend %s -target %target-swift-5.9-abi-triple -emit-ir
2+
3+
public enum Enum<T : ~Escapable> : ~Escapable {
4+
case none
5+
case some(T)
6+
}
7+
8+
extension Enum: Escapable where T: Escapable {}

0 commit comments

Comments
 (0)