mirror of
https://github.com/apple/swift.git
synced 2025-12-14 20:36:38 +01:00
This allows script mode to pick up the current version of macOS instead of defaulting to 10.9, making it unnecessary to write #available. A -target flag can still override this if you're trying to write a portable script. The logic is a little tortured to avoid having to actually link to Foundation.framework or libobjc. Finishes rdar://problem/29433205.
17 lines
801 B
Swift
17 lines
801 B
Swift
// Note: This deliberately uses the script interpreter rather than build/run.
|
|
// RUN: %swift_driver -import-objc-header %S/Inputs/availability_host_os.h -DFAIL -Xfrontend -verify %s
|
|
// RUN: %swift_driver -import-objc-header %S/Inputs/availability_host_os.h %s | %FileCheck %s
|
|
// RUN: not %swift -typecheck -import-objc-header %S/Inputs/availability_host_os.h %s 2>&1 | %FileCheck -check-prefix=CHECK-NOT-INFERRED %s
|
|
|
|
// REQUIRES: OS=macosx
|
|
// REQUIRES: executable_test
|
|
|
|
print(mavericks()) // CHECK: {{^9$}}
|
|
print(yosemite()) // CHECK-NEXT: {{^10$}}
|
|
// CHECK-NOT-INFERRED: 'yosemite()' is only available on OS X 10.10 or newer
|
|
|
|
#if FAIL
|
|
print(todosSantos()) // expected-error {{'todosSantos()' is only available on OS X 10.99 or newer}}
|
|
// expected-note@-1 {{add 'if #available' version check}}
|
|
#endif
|