@@ -61,6 +61,16 @@ class AvailabilityConstraint {
61
61
IntroducedInLaterDynamicVersion,
62
62
};
63
63
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
+
64
74
private:
65
75
llvm::PointerIntPair<SemanticAvailableAttr, 2 , Reason> attrAndReason;
66
76
@@ -93,6 +103,26 @@ class AvailabilityConstraint {
93
103
return static_cast <SemanticAvailableAttr>(attrAndReason.getPointer ());
94
104
}
95
105
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
+
96
126
// / Returns the domain that the constraint applies to.
97
127
AvailabilityDomain getDomain () const { return getAttr ().getDomain (); }
98
128
@@ -105,10 +135,6 @@ class AvailabilityConstraint {
105
135
std::optional<AvailabilityRange>
106
136
getRequiredNewerAvailabilityRange (ASTContext &ctx) const ;
107
137
108
- // / Returns true if this unmet requirement can be satisfied by introducing an
109
- // / `if #available(...)` condition in source.
110
- bool isConditionallySatisfiable () const ;
111
-
112
138
// / Some availability constraints are active for type-checking but cannot
113
139
// / be translated directly into an `if #available(...)` runtime query.
114
140
bool isActiveForRuntimeQueries (ASTContext &ctx) const ;
0 commit comments