mirror of
https://github.com/apple/swift.git
synced 2025-12-14 20:36:38 +01:00
Don't check suppressed protocols when the extended existential is metatype constrained
This commit is contained in:
@@ -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
|
||||
|
||||
@@ -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))
|
||||
|
||||
Reference in New Issue
Block a user