When emitting SIL for `if #available(Swift ..., *)` queries, call the new
`_isSwiftRuntimeVersionAtLeast()` function in the stdlib to check the
condition. To support back deployment, the implementation of
`_isSwiftRuntimeVersionAtLeast()` is `@_alwaysEmitIntoClient` and performs its
comparison against the result of `_SwiftStdlibVersion.current`, which is
pre-existing ABI that the stdlib exposes for querying the Swift runtime
version.
Resolves rdar://162726037.
Get rid of the boolean arguments for unavailability in AvailabilityQuery's
constructors and introduce a `asUnavailable()` modifier that can be used
instead in the contexts where unavailability is relevant.
Conditionally available opaque return types should support availability
conditions that are evaluated in any availability domain. Update
`ConditionallyAvailableSubstitutions` to model its conditions with
`AvailabilityQuery` instead of assuming that conditions are always a single
version query for the current platform.
Generalize SILGen for `if #available` checks by delegating the determination of
the query function and its arguments to `AvailabilityQuery`. Update SILGen for
`@backDeployed` thunks to use the same infrastructure.
NFC.
Inverted availability queries were mis-compiled for zippered libraries because
the code that emits calls to `isOSVersionAtLeastOrVariantVersionAtLeast()` was
not updated when the `if #unavailable` syntax was introduced (at that time
support for zippered libraries had not yet been upstreamed). The result of
these calls is now inverted when appropriate.
To make it easier to manage the growing complexity of supporting availability
queries, Sema now models the relevant information about an availability query
with the new `AvailabilityQuery` type. It encapsulates the domain for the
query, the result if it is known at compile time, and the version tuple
arguments to pass to a runtime invocation if applicable.
Resolves rdar://147929876.