mirror of
https://github.com/apple/swift.git
synced 2026-03-08 18:24:30 +01:00
In some cases, it's useful to allow an availability macro to expand to an empty availability specification list. Allow developers to express this using macros that are defined to exactly the string `*`, while continuing to reject `*` in availability macros that contain other entries.
75 lines
2.1 KiB
Swift
75 lines
2.1 KiB
Swift
// RUN: %empty-directory(%t)
|
|
|
|
// DEFINE: %{availability} = \
|
|
// DEFINE: -define-availability '_iOS53Aligned:macOS 50.0, iOS 53.0' \
|
|
// DEFINE: -define-availability '_iOS54Aligned:macOS 51.0, iOS 54.0' \
|
|
// DEFINE: -define-availability '_iOS54:iOS 54.0' \
|
|
// DEFINE: -define-availability '_macOS51_0:macOS 51.0' \
|
|
// DEFINE: -define-availability '_myProject 1.0:macOS 51.0' \
|
|
// DEFINE: -define-availability '_myProject 2.5:macOS 52.5' \
|
|
// DEFINE: -define-availability "_emptyMacro:*"
|
|
|
|
// RUN: %target-swift-frontend-dump-parse \
|
|
// RUN: %{availability} \
|
|
// RUN: -enable-experimental-feature ParserASTGen \
|
|
// RUN: | %sanitize-address > %t/astgen.ast
|
|
|
|
// RUN: %target-swift-frontend-dump-parse \
|
|
// RUN: %{availability} \
|
|
// RUN: | %sanitize-address > %t/cpp-parser.ast
|
|
|
|
// RUN: %diff -u %t/astgen.ast %t/cpp-parser.ast
|
|
|
|
// RUN: %target-typecheck-verify-swift \
|
|
// RUN: %{availability} \
|
|
// RUN: -enable-experimental-feature ParserASTGen
|
|
|
|
// REQUIRES: swift_feature_ParserASTGen
|
|
|
|
@available(swift 4)
|
|
func testSwift4OrLater() {}
|
|
|
|
@available(macOS 12, iOS 13.1, *)
|
|
func testShorthandMulti() {}
|
|
|
|
@available(macOS, unavailable)
|
|
func testUnavailableMacOS() {}
|
|
|
|
@available(macOS, deprecated: 12.0.5, message: "whatever")
|
|
func testDeprecaed12MacOS() {}
|
|
|
|
@available(_iOS53Aligned, *)
|
|
func testMacroNameOnly() {}
|
|
|
|
@available(_myProject 2.5, *)
|
|
func testMacroWithVersion() {}
|
|
|
|
@available(_emptyMacro, *)
|
|
func testEmptyMacro() {}
|
|
|
|
@_specialize(exported: true, availability: _iOS54Aligned, *; where T == Int)
|
|
func testSpecialize<T>(arg: T) -> T {}
|
|
|
|
@backDeployed(before: _iOS53Aligned)
|
|
public func testBackDeployed() {}
|
|
|
|
@available(macOS 10, iOS 12, *)
|
|
@_originallyDefinedIn(module: "OriginalModule", macOS 12.0, iOS 13.2)
|
|
public func testOriginallyDefinedIn() {}
|
|
|
|
|
|
func testPoundIf() {
|
|
if #available(_myProject 2.5, *) {
|
|
// pass
|
|
} else if #unavailable(macOS 80) {
|
|
// pass
|
|
} else if #_hasSymbol(Int.self) { // expected-warning {{struct 'Int' is not a weakly linked declaration}}
|
|
// pass
|
|
}
|
|
}
|
|
|
|
public class ClassWithMembers {
|
|
@_spi_available(macOS 10.15, *)
|
|
public func spiFunc() {}
|
|
}
|