Files
swift-mirror/test/Sema/availability_script_mode.swift
Ben Langmuir fd1875dcfb [test] Move availability tests to later fake OS versions
10.50 was once greater than any real macOS version, but now it compares
less than real released versions, which makes these tests depend on the
deployment target unnecessarily. Update these tests to use even larger
numbers to hopefully keep them independent a little longer.
2024-08-21 11:38:54 -07:00

35 lines
1.2 KiB
Swift

// RUN: %target-typecheck-verify-swift -target %target-cpu-apple-macosx50
// REQUIRES: OS=macosx
struct AlwaysAvailable {}
@available(macOS, introduced: 50)
struct Available50 {}
@available(macOS, introduced: 51)
struct Available51 {}
@available(macOS, unavailable)
struct UnavailableOnMacOS {}
@available(*, unavailable)
struct UnavailableUnconditionally {}
var alwaysAvailableVar: AlwaysAvailable = .init() // Ok
@available(macOS, introduced: 50)
var availableOn50Var: Available50 = .init() // Ok
// Script-mode globals have eagerly executed initializers so it isn't safe for
// them to be unavailable.
@available(macOS, introduced: 51) // expected-error {{global variable cannot be marked potentially unavailable with '@available' in script mode}}
var potentiallyUnavailableVar: Available51 = .init()
@available(macOS, unavailable) // expected-error {{global variable cannot be marked unavailable with '@available' in script mode}}
var unavailableOnMacOSVar: UnavailableOnMacOS = .init()
@available(*, unavailable) // expected-error {{global variable cannot be marked unavailable with '@available' in script mode}}
var unconditionallyUnavailableVar: UnavailableUnconditionally = .init()