Skip to content

Conversation

@tshortli
Copy link
Contributor

@tshortli tshortli commented Sep 1, 2024

For the purposes of availability calculations, direct use of llvm::VersionTuple and VersionRange is discouraged, since these fundamental version representations are divorced from their context. For example, comparing an iOS platform version to a visionOS platform version is invalid since the versioning systems of the two platforms differ. Although visionOS inherits avialability from iOS, an iOS version must be converted to a visionOS version prior to comparison. In the future, AvailabilityContext can be enriched to carry the information necessary to verify that its algebraic operations are being performed on compatible values.

Other notable changes:

  • Remove IsSPI from AvailabilityContext. It only existed to make Decl::isAvailableAsSPI() convenient to implement, which wasn't very good justification.
  • Remove 'OS' from AvailabilityContext member names. In the future, AvailabilityContexts may represent version ranges that are not tied to OS platforms.
  • Remove the UnavailabilityReason class. It did not live up to its name because it only modeled potential unavailability due to an unmet OS version requirement but something can be unavailable for many other reasons, like explicit unavailability, language mode requirements, obsoletion, etc.

It only existed to make `Decl::isAvailableAsSPI()` convenient to implement.

NFC.
An `AvailabilityContext` represents an abstract version range in which
something is available. In the future, these version ranges may not necessarily
always correspond to operating system version ranges.

NFC.
`UnavailabilityReason` does not live up to its name because it only models
potential unavailability due to an unmet OS version requirement. It does not
model unavailability caused by explicit annotation, language mode requirements,
obsoletion, etc. `AvailabilityContext` already models an OS version
requirement, so use it instead.

NFC.
@tshortli tshortli force-pushed the availability-context-cleanup branch from 9294594 to 64711a3 Compare September 2, 2024 23:48
@tshortli tshortli changed the title AvailabilityContext cleanup AST: Clean up AvailabilityContext and uses Sep 2, 2024
For the purposes of availability calculations, direct use of
`llvm::VersionTuple` and `VersionRange` is discouraged, since these fundamental
version representations are divorced from their context. For example, comparing
an iOS platform version to a visionOS platform version is invalid since the
versioning systems of the two platforms differ. Although visionOS inherits
avialability from iOS, an iOS version must be converted to a visionOS version
prior to comparison. In the future, `AvailabilityContext` can be enriched to
carry the information necessary to verify that its algebraic operations are
being performed on compatible values.

NFC.
@tshortli tshortli force-pushed the availability-context-cleanup branch from ae7ec19 to 89ea92d Compare September 3, 2024 01:26
@tshortli
Copy link
Contributor Author

tshortli commented Sep 3, 2024

@swift-ci please test

@tshortli tshortli marked this pull request as ready for review September 3, 2024 01:26
@tshortli tshortli merged commit 3f626f5 into swiftlang:main Sep 3, 2024
@tshortli tshortli deleted the availability-context-cleanup branch September 3, 2024 16:42
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant