@@ -61,6 +61,16 @@ class AvailabilityConstraint {
6161 IntroducedInLaterDynamicVersion,
6262 };
6363
64+ // / Classifies constraints into different high level categories.
65+ enum class Kind {
66+ // / There are no contexts in which the declaration would be available.
67+ Unavailable,
68+
69+ // / There are some contexts in which the declaration would be available if
70+ // / additional constraints were added.
71+ PotentiallyAvailable,
72+ };
73+
6474private:
6575 llvm::PointerIntPair<SemanticAvailableAttr, 2 , Reason> attrAndReason;
6676
@@ -93,6 +103,26 @@ class AvailabilityConstraint {
93103 return static_cast <SemanticAvailableAttr>(attrAndReason.getPointer ());
94104 }
95105
106+ Kind getKind () const {
107+ switch (getReason ()) {
108+ case Reason::UnconditionallyUnavailable:
109+ case Reason::Obsoleted:
110+ case Reason::IntroducedInLaterVersion:
111+ return Kind::Unavailable;
112+ case Reason::IntroducedInLaterDynamicVersion:
113+ return Kind::PotentiallyAvailable;
114+ }
115+ }
116+
117+ // / Returns true if the constraint cannot be satisfied at runtime.
118+ bool isUnavailable () const { return getKind () == Kind::Unavailable; }
119+
120+ // / Returns true if the constraint is unsatisfied but could be satisfied at
121+ // / runtime in a more constrained context.
122+ bool isPotentiallyAvailable () const {
123+ return getKind () == Kind::PotentiallyAvailable;
124+ }
125+
96126 // / Returns the domain that the constraint applies to.
97127 AvailabilityDomain getDomain () const { return getAttr ().getDomain (); }
98128
@@ -105,10 +135,6 @@ class AvailabilityConstraint {
105135 std::optional<AvailabilityRange>
106136 getRequiredNewerAvailabilityRange (ASTContext &ctx) const ;
107137
108- // / Returns true if this unmet requirement can be satisfied by introducing an
109- // / `if #available(...)` condition in source.
110- bool isConditionallySatisfiable () const ;
111-
112138 // / Some availability constraints are active for type-checking but cannot
113139 // / be translated directly into an `if #available(...)` runtime query.
114140 bool isActiveForRuntimeQueries (ASTContext &ctx) const ;
0 commit comments