@@ -216,8 +216,7 @@ class UnavailabilityReason {
216216 bool requiresDeploymentTargetOrEarlier (ASTContext &Ctx) const ;
217217};
218218
219- // / Represents everything that a particular chunk of code may assume about its
220- // / runtime environment.
219+ // / Represents a version range in which something is available.
221220// /
222221// / The AvailabilityContext structure forms a [lattice][], which allows it to
223222// / have meaningful union and intersection operations ("join" and "meet"),
@@ -229,11 +228,10 @@ class UnavailabilityReason {
229228// / NOTE: Generally you should use the utilities on \c AvailabilityInference
230229// / to create an \c AvailabilityContext, rather than creating one directly.
231230class AvailabilityContext {
232- VersionRange OSVersion ;
231+ VersionRange Range ;
233232
234233public:
235- // / Creates a context that requires certain versions of the target OS.
236- explicit AvailabilityContext (VersionRange OSVersion) : OSVersion(OSVersion) {}
234+ explicit AvailabilityContext (VersionRange Range) : Range(Range) {}
237235
238236 // / Creates a context that imposes the constraints of the ASTContext's
239237 // / deployment target.
@@ -261,21 +259,21 @@ class AvailabilityContext {
261259 return AvailabilityContext (VersionRange::empty ());
262260 }
263261
264- // / Returns the range of possible OS versions required by this context.
265- VersionRange getOSVersion () const { return OSVersion ; }
262+ // / Returns the range of possible versions required by this context.
263+ VersionRange getVersionRange () const { return Range ; }
266264
267265 // / Returns true if \p other makes stronger guarantees than this context.
268266 // /
269267 // / That is, `a.isContainedIn(b)` implies `a.union(b) == b`.
270268 bool isContainedIn (const AvailabilityContext &other) const {
271- return OSVersion .isContainedIn (other.OSVersion );
269+ return Range .isContainedIn (other.Range );
272270 }
273271
274272 // / Returns true if \p other is a strict subset of this context.
275273 // /
276274 // / That is, `a.isSupersetOf(b)` implies `a != b` and `a.union(b) == a`.
277275 bool isSupersetOf (const AvailabilityContext &other) const {
278- return OSVersion .isSupersetOf (other.OSVersion );
276+ return Range .isSupersetOf (other.Range );
279277 }
280278
281279 // / Returns true if this context has constraints that make it impossible to
@@ -284,13 +282,13 @@ class AvailabilityContext {
284282 // / For example, the else branch of a `#available` check for iOS 8.0 when the
285283 // / containing function already requires iOS 9.
286284 bool isKnownUnreachable () const {
287- return OSVersion .isEmpty ();
285+ return Range .isEmpty ();
288286 }
289287
290288 // / Returns true if there are no constraints on this context; that is,
291289 // / nothing can be assumed.
292290 bool isAlwaysAvailable () const {
293- return OSVersion .isAll ();
291+ return Range .isAll ();
294292 }
295293
296294 // / Produces an under-approximation of the intersection of the two
@@ -303,7 +301,7 @@ class AvailabilityContext {
303301 // / As an example, this is used when figuring out the required availability
304302 // / for a type that references multiple nominal decls.
305303 void intersectWith (const AvailabilityContext &other) {
306- OSVersion .intersectWith (other.getOSVersion () );
304+ Range .intersectWith (other.Range );
307305 }
308306
309307 // / Produces an over-approximation of the intersection of the two
@@ -314,7 +312,7 @@ class AvailabilityContext {
314312 // /
315313 // / As an example, this is used for the true branch of `#available`.
316314 void constrainWith (const AvailabilityContext &other) {
317- OSVersion .constrainWith (other.getOSVersion () );
315+ Range .constrainWith (other.Range );
318316 }
319317
320318 // / Produces an over-approximation of the union of two availability contexts.
@@ -326,12 +324,12 @@ class AvailabilityContext {
326324 // / As an example, this is used for the else branch of a conditional with
327325 // / multiple `#available` checks.
328326 void unionWith (const AvailabilityContext &other) {
329- OSVersion .unionWith (other.getOSVersion () );
327+ Range .unionWith (other.Range );
330328 }
331329
332330 // / Returns a representation of this range as a string for debugging purposes.
333331 std::string getAsString () const {
334- return " AvailabilityContext(" + OSVersion .getAsString () + " )" ;
332+ return " AvailabilityContext(" + Range .getAsString () + " )" ;
335333 }
336334};
337335
0 commit comments