Files
swift-mirror/test/SILGen/availability_query_disabled.swift
Allan Shortlidge 4a76c04cf5 SILGen: Fix if #unavailable mis-compile for zippered libraries.
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.
2025-07-02 11:23:42 -07:00

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) {}
}