@@ -553,11 +553,12 @@ class alignas(1 << DeclAlignInBits) Decl : public ASTAllocated<Decl> {
553553 // / Whether the existential of this protocol conforms to itself.
554554 ExistentialConformsToSelf : 1 ,
555555
556- // / Whether the \c ExistentialRequiresAny bit is valid.
557- ExistentialRequiresAnyValid : 1 ,
556+ // / Whether the \c HasSelfOrAssociatedTypeRequirements bit is valid.
557+ HasSelfOrAssociatedTypeRequirementsValid : 1 ,
558558
559- // / Whether the existential of this protocol must be spelled with \c any.
560- ExistentialRequiresAny : 1 ,
559+ // / Whether this protocol has \c Self or associated type requirements.
560+ // / See \c hasSelfOrAssociatedTypeRequirements() for clarification.
561+ HasSelfOrAssociatedTypeRequirements : 1 ,
561562
562563 // / True if the protocol has requirements that cannot be satisfied (e.g.
563564 // / because they could not be imported from Objective-C).
@@ -4756,19 +4757,19 @@ class ProtocolDecl final : public NominalTypeDecl {
47564757 Bits.ProtocolDecl .ExistentialConformsToSelf = result;
47574758 }
47584759
4759- // / Returns the cached result of \c existentialRequiresAny or \c None if it
4760- // / hasn't yet been computed.
4761- Optional<bool > getCachedExistentialRequiresAny () {
4762- if (Bits.ProtocolDecl .ExistentialRequiresAnyValid )
4763- return Bits.ProtocolDecl .ExistentialRequiresAny ;
4760+ // / Returns the cached result of \c hasSelfOrAssociatedTypeRequirements or
4761+ // / \c None if it hasn't yet been computed.
4762+ Optional<bool > getCachedHasSelfOrAssociatedTypeRequirements () {
4763+ if (Bits.ProtocolDecl .HasSelfOrAssociatedTypeRequirementsValid )
4764+ return Bits.ProtocolDecl .HasSelfOrAssociatedTypeRequirements ;
47644765
47654766 return None;
47664767 }
47674768
4768- // / Caches the result of \c existentialRequiresAny
4769- void setCachedExistentialRequiresAny (bool requiresAny ) {
4770- Bits.ProtocolDecl .ExistentialRequiresAnyValid = true ;
4771- Bits.ProtocolDecl .ExistentialRequiresAny = requiresAny ;
4769+ // / Caches the result of \c hasSelfOrAssociatedTypeRequirements
4770+ void setCachedHasSelfOrAssociatedTypeRequirements (bool value ) {
4771+ Bits.ProtocolDecl .HasSelfOrAssociatedTypeRequirementsValid = true ;
4772+ Bits.ProtocolDecl .HasSelfOrAssociatedTypeRequirements = value ;
47724773 }
47734774
47744775 bool hasLazyRequirementSignature () const {
@@ -4789,7 +4790,7 @@ class ProtocolDecl final : public NominalTypeDecl {
47894790 friend class RequirementSignatureRequestGSB ;
47904791 friend class ProtocolRequiresClassRequest ;
47914792 friend class ExistentialConformsToSelfRequest ;
4792- friend class ExistentialRequiresAnyRequest ;
4793+ friend class HasSelfOrAssociatedTypeRequirementsRequest ;
47934794 friend class InheritedProtocolsRequest ;
47944795 friend class PrimaryAssociatedTypesRequest ;
47954796 friend class ProtocolRequirementsRequest ;
@@ -4888,15 +4889,20 @@ class ProtocolDecl final : public NominalTypeDecl {
48884889 // / Does this protocol require a self-conformance witness table?
48894890 bool requiresSelfConformanceWitnessTable () const ;
48904891
4891- // / Determine whether an existential type must be explicitly prefixed
4892- // / with \c any. \c any is required if one of the following conditions is met
4893- // / for this protocol or an inherited protocol:
4892+ // / Determine whether this protocol has `Self` or associated type
4893+ // / requirements.
4894+ // /
4895+ // / This is true if one of the following conditions is met for this protocol
4896+ // / or an inherited protocol:
48944897 // / - The protocol has an associated type requirement.
48954898 // / - `Self` appears in non-covariant position in the type signature of a
48964899 // / value requirement.
4900+ bool hasSelfOrAssociatedTypeRequirements () const ;
4901+
4902+ // / Determine whether an existential type constrained by this protocol must
4903+ // / be written using `any` syntax.
48974904 // /
4898- // / @Note This method does not take the state of language features into
4899- // / account.
4905+ // / \Note This method takes language feature state into account.
49004906 bool existentialRequiresAny () const ;
49014907
49024908 // / Returns a list of protocol requirements that must be assessed to
0 commit comments