Skip to content

Commit 20b454a

Browse files
committed
NFC: Flip the OS versions for the @available attribute and the @_backDeploy attribute. Declarations should be marked available starting in the first OS they can be back deployed to and the @_backDeploy attribute should indicate which OS version the declaration first became ABI in.
1 parent 9e4ba44 commit 20b454a

6 files changed

+66
-66
lines changed

test/ModuleInterface/back-deploy-attr.swift

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -14,25 +14,25 @@
1414
// RUN: %FileCheck %s --check-prefix FROMMODULE --check-prefix CHECK < %t/TestFromModule.swiftinterface
1515

1616
public struct TopLevelStruct {
17-
// CHECK: @_backDeploy(macOS 11.0)
17+
// CHECK: @_backDeploy(macOS 12.0)
1818
// FROMSOURCE: public func backDeployedFunc1_SinglePlatform() -> Swift.Int { return 42 }
1919
// FROMMODULE: public func backDeployedFunc1_SinglePlatform() -> Swift.Int
20-
@available(macOS 12.0, *)
21-
@_backDeploy(macOS 11.0)
20+
@available(macOS 11.0, *)
21+
@_backDeploy(macOS 12.0)
2222
public func backDeployedFunc1_SinglePlatform() -> Int { return 42 }
2323

24-
// CHECK: @_backDeploy(macOS 11.0)
25-
// CHECK: @_backDeploy(iOS 14.0)
24+
// CHECK: @_backDeploy(macOS 12.0)
25+
// CHECK: @_backDeploy(iOS 15.0)
2626
// FROMSOURCE: public func backDeployedFunc2_MultiPlatform() -> Swift.Int { return 43 }
2727
// FROMMODULE: public func backDeployedFunc2_MultiPlatform() -> Swift.Int
28-
@available(macOS 12.0, *)
29-
@_backDeploy(macOS 11.0, iOS 14.0)
28+
@available(macOS 11.0, *)
29+
@_backDeploy(macOS 12.0, iOS 15.0)
3030
public func backDeployedFunc2_MultiPlatform() -> Int { return 43 }
3131
}
3232

33-
// CHECK: @_backDeploy(macOS 11.0)
33+
// CHECK: @_backDeploy(macOS 12.0)
3434
// FROMSOURCE: public func backDeployTopLevelFunc() -> Swift.Int { return 44 }
3535
// FROMMODULE: public func backDeployTopLevelFunc() -> Swift.Int
36-
@available(macOS 12.0, *)
37-
@_backDeploy(macOS 11.0)
36+
@available(macOS 11.0, *)
37+
@_backDeploy(macOS 12.0)
3838
public func backDeployTopLevelFunc() -> Int { return 44 }

test/SILGen/back_deploy_attribute_func.swift

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@
3838
// -- Original definition of trivialFunc()
3939
// CHECK-LABEL: sil [serialized] [available 10.51] [ossa] @$s11back_deploy11trivialFuncyyF : $@convention(thin) () -> ()
4040
@available(macOS 10.51, *)
41-
@_backDeploy(macOS 10.50)
41+
@_backDeploy(macOS 10.52)
4242
public func trivialFunc() {}
4343

4444
// -- Fallback definition of isNumber(_:)
@@ -73,13 +73,13 @@ public func trivialFunc() {}
7373
// -- Original definition of isNumber(_:)
7474
// CHECK-LABEL: sil [serialized] [available 10.51] [ossa] @$s11back_deploy8isNumberySbSiF : $@convention(thin) (Int) -> Bool
7575
@available(macOS 10.51, *)
76-
@_backDeploy(macOS 10.50)
76+
@_backDeploy(macOS 10.52)
7777
public func isNumber(_ x: Int) -> Bool {
7878
return true
7979
}
8080

8181
// CHECK-LABEL: sil hidden [available 10.51] [ossa] @$s11back_deploy6calleryyF : $@convention(thin) () -> ()
82-
@available(macOS 10.51, *) // FIXME(backDeploy): remove once typechecking allows
82+
@available(macOS 10.51, *)
8383
func caller() {
8484
// -- Verify the thunk is called
8585
// CHECK: {{%.*}} = function_ref @$s11back_deploy11trivialFuncyyFTwb : $@convention(thin) () -> ()

test/SILGen/back_deploy_attribute_generic_func.swift

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -39,13 +39,13 @@
3939
// -- Original definition of genericFunc()
4040
// CHECK-LABEL: sil [serialized] [available 10.51] [ossa] @$s11back_deploy11genericFuncyxxlF : $@convention(thin) <T> (@in_guaranteed T) -> @out T
4141
@available(macOS 10.51, *)
42-
@_backDeploy(macOS 10.50)
42+
@_backDeploy(macOS 10.52)
4343
public func genericFunc<T>(_ t: T) -> T {
4444
return t
4545
}
4646

4747
// CHECK-LABEL: sil hidden [available 10.51] [ossa] @$s11back_deploy6calleryyF : $@convention(thin) () -> ()
48-
@available(macOS 10.51, *) // FIXME(backDeploy): remove once typechecking allows
48+
@available(macOS 10.51, *)
4949
func caller() {
5050
// -- Verify the thunk is called
5151
// CHECK: {{%.*}} = function_ref @$s11back_deploy11genericFuncyxxlFTwb : $@convention(thin) <τ_0_0> (@in_guaranteed τ_0_0) -> @out τ_0_0

test/SILGen/back_deploy_attribute_struct_method.swift

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -40,13 +40,13 @@ public struct TopLevelStruct {
4040
// -- Original definition of TopLevelStruct.trivialMethod()
4141
// CHECK-LABEL: sil [serialized] [available 10.51] [ossa] @$s11back_deploy14TopLevelStructV13trivialMethodyyF : $@convention(method) (TopLevelStruct) -> ()
4242
@available(macOS 10.51, *)
43-
@_backDeploy(macOS 10.50)
43+
@_backDeploy(macOS 10.52)
4444
public func trivialMethod() {}
4545
}
4646

4747
// CHECK-LABEL: sil hidden [available 10.51] [ossa] @$s11back_deploy6calleryyAA14TopLevelStructVF : $@convention(thin) (TopLevelStruct) -> ()
4848
// CHECK: bb0([[STRUCT_ARG:%.*]] : $TopLevelStruct):
49-
@available(macOS 10.51, *) // FIXME(backDeploy): remove once typechecking allows
49+
@available(macOS 10.51, *)
5050
func caller(_ s: TopLevelStruct) {
5151
// -- Verify the thunk is called
5252
// CHECK: {{%.*}} = function_ref @$s11back_deploy14TopLevelStructV13trivialMethodyyFTwb : $@convention(method) (TopLevelStruct) -> ()

test/SILGen/back_deploy_attribute_throwing_func.swift

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -51,11 +51,11 @@
5151
// -- Original definition of throwingFunc()
5252
// CHECK-LABEL: sil [serialized] [available 10.51] [ossa] @$s11back_deploy12throwingFuncyyKF : $@convention(thin) () -> @error Error
5353
@available(macOS 10.51, *)
54-
@_backDeploy(macOS 10.50)
54+
@_backDeploy(macOS 10.52)
5555
public func throwingFunc() throws {}
5656

5757
// CHECK-LABEL: sil hidden [available 10.51] [ossa] @$s11back_deploy6calleryyKF : $@convention(thin) () -> @error Error
58-
@available(macOS 10.51, *) // FIXME(backDeploy): remove once typechecking allows
58+
@available(macOS 10.51, *)
5959
func caller() throws {
6060
// -- Verify the thunk is called
6161
// CHECK: {{%.*}} = function_ref @$s11back_deploy12throwingFuncyyKFTwb : $@convention(thin) () -> @error Error

test/attr/backDeploy.swift renamed to test/attr/attr_backDeploy.swift

Lines changed: 47 additions & 47 deletions
Original file line numberDiff line numberDiff line change
@@ -2,25 +2,25 @@
22

33
// MARK: - Valid declarations
44

5-
@available(macOS 12.0, *)
6-
@_backDeploy(macOS 11.0)
5+
@available(macOS 11.0, *)
6+
@_backDeploy(macOS 12.0)
77
public func backDeployedTopLevelFunc() {}
88

99
// FIXME(backDeploy): Availability macros should be supported
1010

1111
public class TopLevelClass {
12-
@available(macOS 12.0, *)
13-
@_backDeploy(macOS 11.0)
12+
@available(macOS 11.0, *)
13+
@_backDeploy(macOS 12.0)
1414
public func backDeployedMemberFunc() {}
1515

1616
// FIXME(backDeploy): Computed properties should be supported
17-
@available(macOS 12.0, *)
18-
@_backDeploy(macOS 11.0) // expected-error {{'@_backDeploy' attribute cannot be applied to this declaration}}
17+
@available(macOS 11.0, *)
18+
@_backDeploy(macOS 12.0) // expected-error {{'@_backDeploy' attribute cannot be applied to this declaration}}
1919
public var backDeployedComputedProperty: Int { 98 }
2020

2121
// FIXME(backDeploy): Subscripts should be supported
22-
@available(macOS 12.0, *)
23-
@_backDeploy(macOS 11.0) // expected-error {{'@_backDeploy' attribute cannot be applied to this declaration}}
22+
@available(macOS 11.0, *)
23+
@_backDeploy(macOS 12.0) // expected-error {{'@_backDeploy' attribute cannot be applied to this declaration}}
2424
subscript(index: Int) -> Int {
2525
get { return 1 }
2626
set(newValue) {}
@@ -29,28 +29,28 @@ public class TopLevelClass {
2929

3030
// MARK: - Unsupported declaration types
3131

32-
@available(macOS 12.0, *)
33-
@_backDeploy(macOS 11.0) // expected-error {{'@_backDeploy' attribute cannot be applied to this declaration}}
32+
@available(macOS 11.0, *)
33+
@_backDeploy(macOS 12.0) // expected-error {{'@_backDeploy' attribute cannot be applied to this declaration}}
3434
public class CannotBackDeployClass {
35-
@available(macOS 12.0, *)
36-
@_backDeploy(macOS 11.0) // expected-error {{'@_backDeploy' attribute cannot be applied to this declaration}}
35+
@available(macOS 11.0, *)
36+
@_backDeploy(macOS 12.0) // expected-error {{'@_backDeploy' attribute cannot be applied to this declaration}}
3737
public var cannotBackDeploystoredProperty: Int = 83
3838
}
3939

40-
@available(macOS 12.0, *)
41-
@_backDeploy(macOS 11.0) // expected-error {{'@_backDeploy' attribute cannot be applied to this declaration}}
40+
@available(macOS 11.0, *)
41+
@_backDeploy(macOS 12.0) // expected-error {{'@_backDeploy' attribute cannot be applied to this declaration}}
4242
public struct CannotBackDeployStruct {}
4343

44-
@available(macOS 12.0, *)
45-
@_backDeploy(macOS 11.0) // expected-error {{'@_backDeploy' attribute cannot be applied to this declaration}}
44+
@available(macOS 11.0, *)
45+
@_backDeploy(macOS 12.0) // expected-error {{'@_backDeploy' attribute cannot be applied to this declaration}}
4646
public enum CannotBackDeployEnum {
47-
@available(macOS 12.0, *)
48-
@_backDeploy(macOS 11.0) // expected-error {{'@_backDeploy' attribute cannot be applied to this declaration}}
47+
@available(macOS 11.0, *)
48+
@_backDeploy(macOS 12.0) // expected-error {{'@_backDeploy' attribute cannot be applied to this declaration}}
4949
case cannotBackDeployEnumCase
5050
}
5151

52-
@available(macOS 12.0, *)
53-
@_backDeploy(macOS 11.0) // expected-error {{'@_backDeploy' attribute cannot be applied to this declaration}}
52+
@available(macOS 11.0, *)
53+
@_backDeploy(macOS 12.0) // expected-error {{'@_backDeploy' attribute cannot be applied to this declaration}}
5454
public var cannotBackDeployTopLevelVar = 79
5555

5656
// MARK: - Incompatible declarations
@@ -62,69 +62,69 @@ public var cannotBackDeployTopLevelVar = 79
6262

6363
// MARK: - Attribute parsing
6464

65-
@available(macOS 12.0, *)
66-
@_backDeploy(macOS 11.0, unknownOS 1.0) // expected-warning {{unknown platform 'unknownOS' for attribute '@_backDeploy'}}
65+
@available(macOS 11.0, *)
66+
@_backDeploy(macOS 12.0, unknownOS 1.0) // expected-warning {{unknown platform 'unknownOS' for attribute '@_backDeploy'}}
6767
public func unknownOSFunc() {}
6868

69-
@available(macOS 12.0, *)
69+
@available(macOS 11.0, *)
7070
@_backDeploy(@) // expected-error {{expected platform in '@_backDeploy' attribute}}
7171
public func badPlatformFunc1() {}
7272

73-
@available(macOS 12.0, *)
73+
@available(macOS 11.0, *)
7474
@_backDeploy(@ 12.0) // expected-error {{expected platform in '@_backDeploy' attribute}}
7575
public func badPlatformFunc2() {}
7676

77-
@available(macOS 12.0, *)
77+
@available(macOS 11.0, *)
7878
@_backDeploy(macOS) // expected-error {{expected version number in '@_backDeploy' attribute}}
7979
public func missingVersionFunc1() {}
8080

81-
@available(macOS 12.0, *)
82-
@_backDeploy(macOS 11.0, iOS) // expected-error {{expected version number in '@_backDeploy' attribute}}
81+
@available(macOS 11.0, *)
82+
@_backDeploy(macOS 12.0, iOS) // expected-error {{expected version number in '@_backDeploy' attribute}}
8383
public func missingVersionFunc2() {}
8484

85-
@available(macOS 12.0, *)
85+
@available(macOS 11.0, *)
8686
@_backDeploy(macOS, iOS) // expected-error 2{{expected version number in '@_backDeploy' attribute}}
8787
public func missingVersionFunc3() {}
8888

89-
@available(macOS 12.0, *)
90-
@_backDeploy(macOS 11.0, iOS 14.0,) // expected-error {{unexpected ',' separator}}
89+
@available(macOS 11.0, *)
90+
@_backDeploy(macOS 12.0, iOS 14.0,) // expected-error {{unexpected ',' separator}}
9191
public func unexpectedSeparatorFunc() {}
9292

93-
@available(macOS 12.0, *)
94-
@_backDeploy(macOS 11.0.1) // expected-warning {{'@_backDeploy' only uses major and minor version number}}
93+
@available(macOS 11.0, *)
94+
@_backDeploy(macOS 12.0.1) // expected-warning {{'@_backDeploy' only uses major and minor version number}}
9595
public func patchVersionFunc() {}
9696

97-
@available(macOS 12.0, *)
98-
@_backDeploy(macOS 11.0, * 9.0) // expected-warning {{* as platform name has no effect in '@_backDeploy' attribute}}
97+
@available(macOS 11.0, *)
98+
@_backDeploy(macOS 12.0, * 9.0) // expected-warning {{* as platform name has no effect in '@_backDeploy' attribute}}
9999
public func wildcardWithVersionFunc() {}
100100

101-
@available(macOS 12.0, *)
102-
@_backDeploy(macOS 11.0, *) // expected-warning {{* as platform name has no effect in '@_backDeploy' attribute}}
101+
@available(macOS 11.0, *)
102+
@_backDeploy(macOS 12.0, *) // expected-warning {{* as platform name has no effect in '@_backDeploy' attribute}}
103103
public func trailingWildcardFunc() {}
104104

105-
@available(macOS 12.0, *)
106-
@_backDeploy(macOS 11.0, *, iOS 14.0) // expected-warning {{* as platform name has no effect in '@_backDeploy' attribute}}
105+
@available(macOS 11.0, *)
106+
@_backDeploy(macOS 12.0, *, iOS 14.0) // expected-warning {{* as platform name has no effect in '@_backDeploy' attribute}}
107107
public func embeddedWildcardFunc() {}
108108

109109
// FIXME(backDeploy): Expect error for duplicate platforms in same attribute
110-
@available(macOS 12.0, *)
111-
@_backDeploy(macOS 11.0, macOS 10.0)
110+
@available(macOS 11.0, *)
111+
@_backDeploy(macOS 12.0, macOS 13.0)
112112
public func duplicatePlatformsFunc1() {}
113113

114114
// FIXME(backDeploy): Expect error for duplicate platforms accross multiple attributes
115-
@available(macOS 12.0, *)
116-
@_backDeploy(macOS 11.0)
117-
@_backDeploy(macOS 10.0)
115+
@available(macOS 11.0, *)
116+
@_backDeploy(macOS 12.0)
117+
@_backDeploy(macOS 13.0)
118118
public func duplicatePlatformsFunc2() {}
119119

120-
@available(macOS 12.0, *)
120+
@available(macOS 11.0, *)
121121
@_backDeploy() // expected-error {{expected at least one platform version in '@_backDeploy' attribute}}
122122
public func zeroPlatformVersionsFunc() {}
123123

124-
@available(macOS 12.0, *)
124+
@available(macOS 11.0, *)
125125
@_backDeploy // expected-error {{expected '(' in '_backDeploy' attribute}}
126126
public func expectedLeftParenFunc() {}
127127

128-
@available(macOS 12.0, *)
129-
@_backDeploy(macOS 11.0 // expected-note {{to match this opening '('}}
128+
@available(macOS 11.0, *)
129+
@_backDeploy(macOS 12.0 // expected-note {{to match this opening '('}}
130130
public func expectedRightParenFunc() {} // expected-error {{expected ')' in '@_backDeploy' argument list}}

0 commit comments

Comments
 (0)