Don't check suppressed protocols when the extended existential is metatype constrained

This commit is contained in:
Alejandro Alonso
2025-10-15 10:57:52 -07:00
parent a956308a07
commit bc04d6dcf7
2 changed files with 26 additions and 0 deletions

View File

@@ -2229,6 +2229,14 @@ checkInvertibleRequirementsStructural(const Metadata *type,
case MetadataKind::ExtendedExistential: {
auto existential = cast<ExtendedExistentialTypeMetadata>(type);
auto &shape = *existential->Shape;
// If this is an extended existential metatype, then just allow it. Metatypes
// are always copyable and escapable so there can't possibly be a
// suppression issue.
if (shape.Flags.isMetatypeConstrained()) {
return std::nullopt;
}
llvm::ArrayRef<GenericRequirementDescriptor> reqs(
shape.getReqSigRequirements(), shape.getNumReqSigRequirements());
// Look for any suppressed protocol requirements. If the existential

View File

@@ -49,3 +49,21 @@ print(h)
let i: Any = (any A & B & ~Copyable).self
// CHECK: any A & B<Self: ~Swift.Copyable>
print(i)
@inline(never)
func test() -> Bool {
return [].first == nil
}
// CHECK: true
print(test())
let j: [any (~Copyable & ~Escapable).Type] = []
// CHECK: Array<any Any<Self: ~Swift.Copyable, Self: ~Swift.Escapable>.Type>
print(type(of: j))
let k: [(any ~Copyable & ~Escapable).Type] = []
// CHECK: Array<(any Any<Self: ~Swift.Copyable, Self: ~Swift.Escapable>).Type>
print(type(of: k))