@@ -519,7 +519,7 @@ class alignas(1 << DeclAlignInBits) Decl : public ASTAllocated<Decl> {
519519 IsComputingSemanticMembers : 1
520520 );
521521
522- SWIFT_INLINE_BITFIELD_FULL (ProtocolDecl, NominalTypeDecl, 1 +1 +1 +1 +1 +1 +1 +1 +1 +8 +16 ,
522+ SWIFT_INLINE_BITFIELD_FULL (ProtocolDecl, NominalTypeDecl, 1 +1 +1 +1 +1 +1 +1 +1 +1 +1 + 1 + 8 +16 ,
523523 // / Whether the \c RequiresClass bit is valid.
524524 RequiresClassValid : 1 ,
525525
@@ -532,6 +532,12 @@ class alignas(1 << DeclAlignInBits) Decl : public ASTAllocated<Decl> {
532532 // / Whether the existential of this protocol conforms to itself.
533533 ExistentialConformsToSelf : 1 ,
534534
535+ // / Whether the \c ExistentialRequiresAny bit is valid.
536+ ExistentialRequiresAnyValid : 1 ,
537+
538+ // / Whether the existential of this protocol must be spelled with \c any.
539+ ExistentialRequiresAny : 1 ,
540+
535541 // / True if the protocol has requirements that cannot be satisfied (e.g.
536542 // / because they could not be imported from Objective-C).
537543 HasMissingRequirements : 1 ,
@@ -4224,6 +4230,21 @@ class ProtocolDecl final : public NominalTypeDecl {
42244230 Bits.ProtocolDecl .ExistentialConformsToSelf = result;
42254231 }
42264232
4233+ // / Returns the cached result of \c existentialRequiresAny or \c None if it
4234+ // / hasn't yet been computed.
4235+ Optional<bool > getCachedExistentialRequiresAny () {
4236+ if (Bits.ProtocolDecl .ExistentialRequiresAnyValid )
4237+ return Bits.ProtocolDecl .ExistentialRequiresAny ;
4238+
4239+ return None;
4240+ }
4241+
4242+ // / Caches the result of \c existentialRequiresAny
4243+ void setCachedExistentialRequiresAny (bool requiresAny) {
4244+ Bits.ProtocolDecl .ExistentialRequiresAnyValid = true ;
4245+ Bits.ProtocolDecl .ExistentialRequiresAny = requiresAny;
4246+ }
4247+
42274248 bool hasLazyRequirementSignature () const {
42284249 return Bits.ProtocolDecl .HasLazyRequirementSignature ;
42294250 }
@@ -4237,6 +4258,7 @@ class ProtocolDecl final : public NominalTypeDecl {
42374258 friend class RequirementSignatureRequestRQM ;
42384259 friend class ProtocolRequiresClassRequest ;
42394260 friend class ExistentialConformsToSelfRequest ;
4261+ friend class ExistentialRequiresAnyRequest ;
42404262 friend class InheritedProtocolsRequest ;
42414263
42424264public:
@@ -4325,6 +4347,11 @@ class ProtocolDecl final : public NominalTypeDecl {
43254347 // / contain 'Self' in 'parameter' or 'other' position.
43264348 bool isAvailableInExistential (const ValueDecl *decl) const ;
43274349
4350+ // / Determine whether an existential type must be explicitly prefixed
4351+ // / with \c any. \c any is required if any of the members contain
4352+ // / an associated type, or if \c Self appears in non-covariant position.
4353+ bool existentialRequiresAny () const ;
4354+
43284355 // / Returns a list of protocol requirements that must be assessed to
43294356 // / determine a concrete's conformance effect polymorphism kind.
43304357 PolymorphicEffectRequirementList getPolymorphicEffectRequirements (
0 commit comments