mirror of
https://github.com/apple/swift.git
synced 2025-12-14 20:36:38 +01:00
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.
17 lines
520 B
Swift
17 lines
520 B
Swift
// RUN: %target-swift-emit-silgen -disable-availability-checking %s -verify
|
|
// RUN: %target-swift-emit-silgen -disable-availability-checking %s | %FileCheck %s
|
|
|
|
// CHECK-LABEL: // available()
|
|
func available() {
|
|
// CHECK: [[TRUE:%.*]] = integer_literal $Builtin.Int1, -1
|
|
// CHECK: cond_br [[TRUE]]
|
|
if #available(macOS 10.15, *) {}
|
|
}
|
|
|
|
// CHECK-LABEL: // unavailable()
|
|
func unavailable() {
|
|
// CHECK: [[FALSE:%.*]] = integer_literal $Builtin.Int1, 0
|
|
// CHECK: cond_br [[FALSE]]
|
|
if #unavailable(macOS 10.15) {}
|
|
}
|