[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.
This commit is contained in:
Dario Rexin
2025-06-18 11:28:13 -07:00
parent 612f7b213c
commit ae8c455170
2 changed files with 12 additions and 3 deletions

View File

@@ -1394,12 +1394,13 @@ namespace {
// Create placeholders for the counts of the conditional requirements
// for each conditional conformance to a supressible protocol.
unsigned numProtocols = countBitsUsed(protocols.rawBits());
unsigned numProtocols = 0;
using PlaceholderPosition =
ConstantAggregateBuilderBase::PlaceholderPosition;
SmallVector<PlaceholderPosition, 2> countPlaceholders;
for (unsigned i : range(0, numProtocols)) {
(void)i;
for (auto kind : protocols) {
(void)kind;
numProtocols++;
countPlaceholders.push_back(
B.addPlaceholderWithSize(IGM.Int16Ty));
}

View File

@@ -0,0 +1,8 @@
// RUN: %target-swift-frontend %s -target %target-swift-5.9-abi-triple -emit-ir
public enum Enum<T : ~Escapable> : ~Escapable {
case none
case some(T)
}
extension Enum: Escapable where T: Escapable {}