Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 8 additions & 0 deletions stdlib/public/runtime/ProtocolConformance.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
18 changes: 18 additions & 0 deletions test/Interpreter/extended_existential.swift
Original file line number Diff line number Diff line change
Expand Up @@ -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))