mirror of
https://github.com/apple/swift.git
synced 2025-12-21 12:14:44 +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: {
|
case MetadataKind::ExtendedExistential: {
|
||||||
auto existential = cast<ExtendedExistentialTypeMetadata>(type);
|
auto existential = cast<ExtendedExistentialTypeMetadata>(type);
|
||||||
auto &shape = *existential->Shape;
|
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(
|
llvm::ArrayRef<GenericRequirementDescriptor> reqs(
|
||||||
shape.getReqSigRequirements(), shape.getNumReqSigRequirements());
|
shape.getReqSigRequirements(), shape.getNumReqSigRequirements());
|
||||||
// Look for any suppressed protocol requirements. If the existential
|
// Look for any suppressed protocol requirements. If the existential
|
||||||
|
|||||||
@@ -49,3 +49,21 @@ print(h)
|
|||||||
let i: Any = (any A & B & ~Copyable).self
|
let i: Any = (any A & B & ~Copyable).self
|
||||||
// CHECK: any A & B<Self: ~Swift.Copyable>
|
// CHECK: any A & B<Self: ~Swift.Copyable>
|
||||||
print(i)
|
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