11// RUN: %target-typecheck-verify-swift \
2- // RUN: -define-availability "_iOS8Aligned :macOS 10.10 , iOS 8 .0" \
3- // RUN: -define-availability "_iOS9Aligned :macOS 10.11 , iOS 9 .0" \
4- // RUN: -define-availability "_iOS9 :iOS 9 .0" \
5- // RUN: -define-availability "_macOS10_11 :macOS 10.11 " \
6- // RUN: -define-availability "_myProject 1.0:macOS 10.11 " \
7- // RUN: -define-availability "_myProject 2.5:macOS 10.12 "
2+ // RUN: -define-availability "_iOS13Aligned :macOS 10.15 , iOS 13 .0" \
3+ // RUN: -define-availability "_iOS14Aligned :macOS 11.0 , iOS 14 .0" \
4+ // RUN: -define-availability "_iOS14 :iOS 14 .0" \
5+ // RUN: -define-availability "_macOS11_0 :macOS 11.0 " \
6+ // RUN: -define-availability "_myProject 1.0:macOS 11.0 " \
7+ // RUN: -define-availability "_myProject 2.5:macOS 12.5 "
88// REQUIRES: OS=macosx
99
10- @available ( _iOS8Aligned , * )
11- public func onMacOS10_10 ( ) { }
10+ @available ( _iOS13Aligned , * )
11+ public func onMacOS10_15 ( ) { }
1212
13- @available ( _iOS9Aligned , * )
14- public func onMacOS10_11 ( ) { }
13+ @available ( _iOS14Aligned , * )
14+ public func onMacOS11_0 ( ) { }
1515
16- @available ( _iOS9 , _macOS10_11 , tvOS 11 . 0 , * )
16+ @available ( _iOS14 , _macOS11_0 , tvOS 14 . 0 , * )
1717public func composed( ) { }
1818
19- @available ( _iOS8Aligned , * )
20- @available ( macOS, deprecated: 10.10 )
19+ @available ( _iOS13Aligned , * )
20+ @available ( macOS, deprecated: 10.15 )
2121public func onMacOSDeprecated( ) { }
2222
2323@available ( _myProject, * ) // expected-error {{expected declaration}}
@@ -42,25 +42,25 @@ public func brokenVersion() {}
4242// expected-error @-1 {{expected 'available' option such as 'unavailable', 'introduced', 'deprecated', 'obsoleted', 'message', or 'renamed'}}
4343public func unknownMacro( ) { }
4444
45- @available ( _iOS9 ) // expected-error {{must handle potential future platforms with '*'}}
45+ @available ( _iOS14 ) // expected-error {{must handle potential future platforms with '*'}}
4646public func noOtherOSes( ) { }
4747
48- @available ( _iOS8Aligned , * )
48+ @available ( _iOS13Aligned , * )
4949func client( ) {
50- onMacOS10_10 ( )
51- onMacOS10_11 ( ) // expected-error {{is only available in macOS 10.11 or newer}}
50+ onMacOS10_15 ( )
51+ onMacOS11_0 ( ) // expected-error {{is only available in macOS 11.0 or newer}}
5252 // expected-note @-1 {{add 'if #available' version check}}
5353 onMacOSDeprecated ( )
5454
55- if #available( _iOS9Aligned , * ) {
56- onMacOS10_11 ( )
55+ if #available( _iOS14Aligned , * ) {
56+ onMacOS11_0 ( )
5757 }
5858
59- if #unavailable( _iOS9Aligned ) {
60- onMacOS10_11 ( ) // expected-error {{is only available in macOS 10.11 or newer}}
59+ if #unavailable( _iOS14Aligned ) {
60+ onMacOS11_0 ( ) // expected-error {{is only available in macOS 11.0 or newer}}
6161 // expected-note @-1 {{add 'if #available' version check}}
6262 } else {
63- onMacOS10_11 ( )
63+ onMacOS11_0 ( )
6464 }
6565
6666 if #available( _unknownMacro, * ) { } // expected-error {{expected version number}}
@@ -72,39 +72,40 @@ public func doIt(_ closure: () -> ()) {
7272
7373@inlinable
7474public func forbidMacrosInInlinableCode( ) {
75- if #available( _iOS9Aligned , * ) { } // expected-error {{availability macro cannot be used in an '@inlinable' function}}
76- if #available( _iOS9 , _macOS10_11 , * ) { } // expected-error {{availability macro cannot be used in an '@inlinable' function}}
77- if #available( iOS 9 . 0 , _macOS10_11 , tvOS 9 . 0 , * ) { } // expected-error {{availability macro cannot be used in an '@inlinable' function}}
78- if #unavailable( _iOS9Aligned ) { } // expected-error {{availability macro cannot be used in an '@inlinable' function}}
79- if #unavailable( _iOS9 , _macOS10_11 ) { } // expected-error {{availability macro cannot be used in an '@inlinable' function}}
80- if #unavailable( iOS 9 . 0 , _macOS10_11 , tvOS 9 . 0 ) { } // expected-error {{availability macro cannot be used in an '@inlinable' function}}
75+ if #available( _iOS14Aligned , * ) { } // expected-error {{availability macro cannot be used in an '@inlinable' function}}
76+ if #available( _iOS14 , _macOS11_0 , * ) { } // expected-error {{availability macro cannot be used in an '@inlinable' function}}
77+ if #available( iOS 14 . 0 , _macOS11_0 , tvOS 14 . 0 , * ) { } // expected-error {{availability macro cannot be used in an '@inlinable' function}}
78+ if #unavailable( _iOS14Aligned ) { } // expected-error {{availability macro cannot be used in an '@inlinable' function}}
79+ if #unavailable( _iOS14 , _macOS11_0 ) { } // expected-error {{availability macro cannot be used in an '@inlinable' function}}
80+ if #unavailable( iOS 14 . 0 , _macOS11_0 , tvOS 14 . 0 ) { } // expected-error {{availability macro cannot be used in an '@inlinable' function}}
8181 doIt {
82- if #available( _iOS9Aligned , * ) { } // expected-error {{availability macro cannot be used in an '@inlinable' function}}
82+ if #available( _iOS14Aligned , * ) { } // expected-error {{availability macro cannot be used in an '@inlinable' function}}
8383 }
8484}
8585
8686@_alwaysEmitIntoClient
8787public func forbidMacrosInInlinableCode1( ) {
88- if #available( _iOS9Aligned , * ) { } // expected-error {{availability macro cannot be used in an '@_alwaysEmitIntoClient' function}}
89- if #available( _iOS9 , _macOS10_11 , * ) { } // expected-error {{availability macro cannot be used in an '@_alwaysEmitIntoClient' function}}
90- if #available( iOS 9 . 0 , _macOS10_11 , tvOS 9 . 0 , * ) { } // expected-error {{availability macro cannot be used in an '@_alwaysEmitIntoClient' function}}
91- if #unavailable( _iOS9Aligned ) { } // expected-error {{availability macro cannot be used in an '@_alwaysEmitIntoClient' function}}
92- if #unavailable( _iOS9 , _macOS10_11 ) { } // expected-error {{availability macro cannot be used in an '@_alwaysEmitIntoClient' function}}
93- if #unavailable( iOS 9 . 0 , _macOS10_11 , tvOS 9 . 0 ) { } // expected-error {{availability macro cannot be used in an '@_alwaysEmitIntoClient' function}}
88+ if #available( _iOS14Aligned , * ) { } // expected-error {{availability macro cannot be used in an '@_alwaysEmitIntoClient' function}}
89+ if #available( _iOS14 , _macOS11_0 , * ) { } // expected-error {{availability macro cannot be used in an '@_alwaysEmitIntoClient' function}}
90+ if #available( iOS 14 . 0 , _macOS11_0 , tvOS 14 . 0 , * ) { } // expected-error {{availability macro cannot be used in an '@_alwaysEmitIntoClient' function}}
91+ if #unavailable( _iOS14Aligned ) { } // expected-error {{availability macro cannot be used in an '@_alwaysEmitIntoClient' function}}
92+ if #unavailable( _iOS14 , _macOS11_0 ) { } // expected-error {{availability macro cannot be used in an '@_alwaysEmitIntoClient' function}}
93+ if #unavailable( iOS 14 . 0 , _macOS11_0 , tvOS 14 . 0 ) { } // expected-error {{availability macro cannot be used in an '@_alwaysEmitIntoClient' function}}
9494 doIt {
95- if #available( _iOS9Aligned , * ) { } // expected-error {{availability macro cannot be used in an '@_alwaysEmitIntoClient' function}}
95+ if #available( _iOS14Aligned , * ) { } // expected-error {{availability macro cannot be used in an '@_alwaysEmitIntoClient' function}}
9696 }
9797}
9898
99- @backDeployed ( before: _iOS9Aligned)
99+ @available ( _iOS13Aligned, * )
100+ @backDeployed ( before: _iOS14Aligned)
100101public func forbidMacrosInInlinableCode2( ) {
101- if #available( _iOS9Aligned , * ) { } // expected-error {{availability macro cannot be used in a '@backDeployed' function}}
102- if #available( _iOS9 , _macOS10_11 , * ) { } // expected-error {{availability macro cannot be used in a '@backDeployed' function}}
103- if #available( iOS 9 . 0 , _macOS10_11 , tvOS 9 . 0 , * ) { } // expected-error {{availability macro cannot be used in a '@backDeployed' function}}
104- if #unavailable( _iOS9Aligned ) { } // expected-error {{availability macro cannot be used in a '@backDeployed' function}}
105- if #unavailable( _iOS9 , _macOS10_11 ) { } // expected-error {{availability macro cannot be used in a '@backDeployed' function}}
106- if #unavailable( iOS 9 . 0 , _macOS10_11 , tvOS 9 . 0 ) { } // expected-error {{availability macro cannot be used in a '@backDeployed' function}}
102+ if #available( _iOS14Aligned , * ) { } // expected-error {{availability macro cannot be used in a '@backDeployed' function}}
103+ if #available( _iOS14 , _macOS11_0 , * ) { } // expected-error {{availability macro cannot be used in a '@backDeployed' function}}
104+ if #available( iOS 14 . 0 , _macOS11_0 , tvOS 14 . 0 , * ) { } // expected-error {{availability macro cannot be used in a '@backDeployed' function}}
105+ if #unavailable( _iOS14Aligned ) { } // expected-error {{availability macro cannot be used in a '@backDeployed' function}}
106+ if #unavailable( _iOS14 , _macOS11_0 ) { } // expected-error {{availability macro cannot be used in a '@backDeployed' function}}
107+ if #unavailable( iOS 14 . 0 , _macOS11_0 , tvOS 14 . 0 ) { } // expected-error {{availability macro cannot be used in a '@backDeployed' function}}
107108 doIt {
108- if #available( _iOS9Aligned , * ) { } // expected-error {{availability macro cannot be used in a '@backDeployed' function}}
109+ if #available( _iOS14Aligned , * ) { } // expected-error {{availability macro cannot be used in a '@backDeployed' function}}
109110 }
110111}
0 commit comments