Skip to content

Commit a867ff8

Browse files
authored
Merge pull request #84921 from Azoy/fix-existential-thing-idk
[Runtime] Don't check suppressed protocols when the extended existential is metatype constrained
2 parents 5d480ef + bc04d6d commit a867ff8

File tree

2 files changed

+26
-0
lines changed

2 files changed

+26
-0
lines changed

stdlib/public/runtime/ProtocolConformance.cpp

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2229,6 +2229,14 @@ checkInvertibleRequirementsStructural(const Metadata *type,
22292229
case MetadataKind::ExtendedExistential: {
22302230
auto existential = cast<ExtendedExistentialTypeMetadata>(type);
22312231
auto &shape = *existential->Shape;
2232+
2233+
// If this is an extended existential metatype, then just allow it. Metatypes
2234+
// are always copyable and escapable so there can't possibly be a
2235+
// suppression issue.
2236+
if (shape.Flags.isMetatypeConstrained()) {
2237+
return std::nullopt;
2238+
}
2239+
22322240
llvm::ArrayRef<GenericRequirementDescriptor> reqs(
22332241
shape.getReqSigRequirements(), shape.getNumReqSigRequirements());
22342242
// Look for any suppressed protocol requirements. If the existential

test/Interpreter/extended_existential.swift

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -49,3 +49,21 @@ print(h)
4949
let i: Any = (any A & B & ~Copyable).self
5050
// CHECK: any A & B<Self: ~Swift.Copyable>
5151
print(i)
52+
53+
@inline(never)
54+
func test() -> Bool {
55+
return [].first == nil
56+
}
57+
58+
// CHECK: true
59+
print(test())
60+
61+
let j: [any (~Copyable & ~Escapable).Type] = []
62+
63+
// CHECK: Array<any Any<Self: ~Swift.Copyable, Self: ~Swift.Escapable>.Type>
64+
print(type(of: j))
65+
66+
let k: [(any ~Copyable & ~Escapable).Type] = []
67+
68+
// CHECK: Array<(any Any<Self: ~Swift.Copyable, Self: ~Swift.Escapable>).Type>
69+
print(type(of: k))

0 commit comments

Comments
 (0)