From bc04d6dcf78b2f574a5615c60142703760cd329c Mon Sep 17 00:00:00 2001 From: Alejandro Alonso Date: Wed, 15 Oct 2025 10:57:52 -0700 Subject: [PATCH] Don't check suppressed protocols when the extended existential is metatype constrained --- stdlib/public/runtime/ProtocolConformance.cpp | 8 ++++++++ test/Interpreter/extended_existential.swift | 18 ++++++++++++++++++ 2 files changed, 26 insertions(+) diff --git a/stdlib/public/runtime/ProtocolConformance.cpp b/stdlib/public/runtime/ProtocolConformance.cpp index 6163a68003bff..aeaa383b16590 100644 --- a/stdlib/public/runtime/ProtocolConformance.cpp +++ b/stdlib/public/runtime/ProtocolConformance.cpp @@ -2229,6 +2229,14 @@ checkInvertibleRequirementsStructural(const Metadata *type, case MetadataKind::ExtendedExistential: { auto existential = cast(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 reqs( shape.getReqSigRequirements(), shape.getNumReqSigRequirements()); // Look for any suppressed protocol requirements. If the existential diff --git a/test/Interpreter/extended_existential.swift b/test/Interpreter/extended_existential.swift index 8098db72d8341..080b330443079 100644 --- a/test/Interpreter/extended_existential.swift +++ b/test/Interpreter/extended_existential.swift @@ -49,3 +49,21 @@ print(h) let i: Any = (any A & B & ~Copyable).self // CHECK: any A & B print(i) + +@inline(never) +func test() -> Bool { + return [].first == nil +} + +// CHECK: true +print(test()) + +let j: [any (~Copyable & ~Escapable).Type] = [] + +// CHECK: Array.Type> +print(type(of: j)) + +let k: [(any ~Copyable & ~Escapable).Type] = [] + +// CHECK: Array<(any Any).Type> +print(type(of: k))