1
- // RUN: %target-typecheck-verify-swift -target %target-swift-5.1-abi-triple
1
+ // RUN: %swift -typecheck %s -verify -parse-stdlib -module-name Swift -target x86_64-apple-macosx10.15 -verify-additional-prefix macos-
2
+ // RUN: %swift -typecheck %s -verify -parse-stdlib -module-name Swift -target arm64-apple-ios13 -verify-additional-prefix ios-
3
+ // RUN: %swift -typecheck %s -verify -parse-stdlib -module-name Swift -target arm64-apple-watchos6 -verify-additional-prefix watchos-
4
+ // RUN: %swift -typecheck %s -verify -parse-stdlib -module-name Swift -target arm64-apple-tvos13 -verify-additional-prefix tvos-
5
+ // RUN: %swift -typecheck %s -verify -parse-stdlib -module-name Swift -target arm64-apple-xros1 -verify-additional-prefix visionos-
2
6
3
7
@available ( OSX 10 . 16 , * )
4
8
func introducedOnMacOS10_16( ) { }
@@ -12,7 +16,59 @@ func introducedInVersionsMappingTo26_0() { }
12
16
@available ( macOS 26 . 0 , iOS 26 . 0 , watchOS 26 . 0 , tvOS 26 . 0 , visionOS 26 . 0 , * )
13
17
func introducedIn26_0( ) { }
14
18
19
+ @available ( macOS 17 . 0 , iOS 20 . 0 , watchOS 13 . 0 , tvOS 20 . 0 , visionOS 4 . 0 , * )
20
+ // expected-warning@-1 {{'17.0' is not a valid version number for macOS}}
21
+ // expected-warning@-2 {{'20.0' is not a valid version number for iOS}}
22
+ // expected-warning@-3 {{'13.0' is not a valid version number for watchOS}}
23
+ // expected-warning@-4 {{'20.0' is not a valid version number for tvOS}}
24
+ // expected-warning@-5 {{'4.0' is not a valid version number for visionOS}}
25
+ func introducedInVersionsMappingTo27_0( ) { }
26
+
27
+ @available ( macOS 27 . 0 , iOS 27 . 0 , watchOS 27 . 0 , tvOS 27 . 0 , visionOS 27 . 0 , * )
28
+ func introducedIn27_0( ) { }
29
+
15
30
func useUnderPoundAvailable( ) {
31
+ // expected-note@-1 * {{add '@available' attribute to enclosing global function}}
32
+ introducedOnMacOS10_16 ( )
33
+ // expected-macos-error@-1 {{'introducedOnMacOS10_16()' is only available in macOS 11.0 or newer}}
34
+ // expected-macos-note@-2 {{add 'if #available' version check}}
35
+
36
+ introducedOnMacOS11_0 ( )
37
+ // expected-macos-error@-1 {{'introducedOnMacOS11_0()' is only available in macOS 11.0 or newer}}
38
+ // expected-macos-note@-2 {{add 'if #available' version check}}
39
+
40
+ introducedInVersionsMappingTo26_0 ( )
41
+ // expected-macos-error@-1 {{'introducedInVersionsMappingTo26_0()' is only available in macOS 26.0 or newer}}
42
+ // expected-ios-error@-2 {{'introducedInVersionsMappingTo26_0()' is only available in iOS 26.0 or newer}}
43
+ // expected-watchos-error@-3 {{'introducedInVersionsMappingTo26_0()' is only available in watchOS 26.0 or newer}}
44
+ // expected-tvos-error@-4 {{'introducedInVersionsMappingTo26_0()' is only available in tvOS 26.0 or newer}}
45
+ // expected-visionos-error@-5 {{'introducedInVersionsMappingTo26_0()' is only available in visionOS 26.0 or newer}}
46
+ // expected-note@-6 {{add 'if #available' version check}}
47
+
48
+ introducedIn26_0 ( )
49
+ // expected-macos-error@-1 {{'introducedIn26_0()' is only available in macOS 26.0 or newer}}
50
+ // expected-ios-error@-2 {{'introducedIn26_0()' is only available in iOS 26.0 or newer}}
51
+ // expected-watchos-error@-3 {{'introducedIn26_0()' is only available in watchOS 26.0 or newer}}
52
+ // expected-tvos-error@-4 {{'introducedIn26_0()' is only available in tvOS 26.0 or newer}}
53
+ // expected-visionos-error@-5 {{'introducedIn26_0()' is only available in visionOS 26.0 or newer}}
54
+ // expected-note@-6 {{add 'if #available' version check}}
55
+
56
+ introducedInVersionsMappingTo27_0 ( )
57
+ // expected-macos-error@-1 {{'introducedInVersionsMappingTo27_0()' is only available in macOS 27.0 or newer}}
58
+ // expected-ios-error@-2 {{'introducedInVersionsMappingTo27_0()' is only available in iOS 27.0 or newer}}
59
+ // expected-watchos-error@-3 {{'introducedInVersionsMappingTo27_0()' is only available in watchOS 27.0 or newer}}
60
+ // expected-tvos-error@-4 {{'introducedInVersionsMappingTo27_0()' is only available in tvOS 27.0 or newer}}
61
+ // expected-visionos-error@-5 {{'introducedInVersionsMappingTo27_0()' is only available in visionOS 27.0 or newer}}
62
+ // expected-note@-6 {{add 'if #available' version check}}
63
+
64
+ introducedIn27_0 ( )
65
+ // expected-macos-error@-1 {{'introducedIn27_0()' is only available in macOS 27.0 or newer}}
66
+ // expected-ios-error@-2 {{'introducedIn27_0()' is only available in iOS 27.0 or newer}}
67
+ // expected-watchos-error@-3 {{'introducedIn27_0()' is only available in watchOS 27.0 or newer}}
68
+ // expected-tvos-error@-4 {{'introducedIn27_0()' is only available in tvOS 27.0 or newer}}
69
+ // expected-visionos-error@-5 {{'introducedIn27_0()' is only available in visionOS 27.0 or newer}}
70
+ // expected-note@-6 {{add 'if #available' version check}}
71
+
16
72
if #available( OSX 10 . 16 , * ) {
17
73
introducedOnMacOS10_16 ( )
18
74
introducedOnMacOS11_0 ( )
@@ -21,5 +77,24 @@ func useUnderPoundAvailable() {
21
77
if #available( macOS 16 . 0 , iOS 19 . 0 , watchOS 12 . 0 , tvOS 19 . 0 , visionOS 3 . 0 , * ) {
22
78
introducedInVersionsMappingTo26_0 ( )
23
79
introducedIn26_0 ( )
80
+ introducedInVersionsMappingTo27_0 ( )
81
+ // expected-macos-error@-1 {{'introducedInVersionsMappingTo27_0()' is only available in macOS 27.0 or newer}}
82
+ // expected-ios-error@-2 {{'introducedInVersionsMappingTo27_0()' is only available in iOS 27.0 or newer}}
83
+ // expected-watchos-error@-3 {{'introducedInVersionsMappingTo27_0()' is only available in watchOS 27.0 or newer}}
84
+ // expected-tvos-error@-4 {{'introducedInVersionsMappingTo27_0()' is only available in tvOS 27.0 or newer}}
85
+ // expected-visionos-error@-5 {{'introducedInVersionsMappingTo27_0()' is only available in visionOS 27.0 or newer}}
86
+ // expected-note@-6 {{add 'if #available' version check}}
87
+ introducedIn27_0 ( )
88
+ // expected-macos-error@-1 {{'introducedIn27_0()' is only available in macOS 27.0 or newer}}
89
+ // expected-ios-error@-2 {{'introducedIn27_0()' is only available in iOS 27.0 or newer}}
90
+ // expected-watchos-error@-3 {{'introducedIn27_0()' is only available in watchOS 27.0 or newer}}
91
+ // expected-tvos-error@-4 {{'introducedIn27_0()' is only available in tvOS 27.0 or newer}}
92
+ // expected-visionos-error@-5 {{'introducedIn27_0()' is only available in visionOS 27.0 or newer}}
93
+ // expected-note@-6 {{add 'if #available' version check}}
94
+ }
95
+
96
+ if #available( macOS 17 . 0 , iOS 20 . 0 , watchOS 13 . 0 , tvOS 20 . 0 , visionOS 4 . 0 , * ) {
97
+ introducedInVersionsMappingTo27_0 ( )
98
+ introducedIn27_0 ( )
24
99
}
25
100
}
0 commit comments