22
33// MARK: - Valid declarations
44
5+ // OK: top level functions
56@available ( macOS 11 . 0 , * )
67@_backDeploy ( macOS 12 . 0 )
78public func backDeployedTopLevelFunc( ) { }
89
9- // OK: @usableFromInline decls may be back deployed
10+ // OK: internal decls may be back deployed when @usableFromInline
1011@available ( macOS 11 . 0 , * )
1112@_backDeploy ( macOS 12 . 0 )
1213@usableFromInline
1314internal func backDeployedUsableFromInlineTopLevelFunc( ) { }
1415
15- // FIXME(backDeploy): Availability macros should be supported
16-
17- public class TopLevelClass {
16+ // OK: function decls in a struct
17+ public struct TopLevelStruct {
1818 @available ( macOS 11 . 0 , * )
1919 @_backDeploy ( macOS 12 . 0 )
20- final public func backDeployedFinalMethod ( ) { }
20+ public func backDeployedMethod ( ) { }
2121
22- // FIXME(backDeploy): Computed properties should be supported
2322 @available ( macOS 11 . 0 , * )
24- @_backDeploy ( macOS 12 . 0 ) // expected-error {{'@_backDeploy' attribute cannot be applied to this declaration}}
23+ @_backDeploy ( macOS 12 . 0 )
2524 public var backDeployedComputedProperty : Int { 98 }
25+ }
2626
27- // FIXME(backDeploy): Subscripts should be supported
27+ public class TopLevelClass {
2828 @available ( macOS 11 . 0 , * )
29- @_backDeploy ( macOS 12 . 0 ) // expected-error {{'@_backDeploy' attribute cannot be applied to this declaration}}
30- subscript( index: Int ) -> Int {
31- get { return 1 }
32- set ( newValue) { }
33- }
34- }
29+ @_backDeploy ( macOS 12 . 0 )
30+ final public func backDeployedFinalMethod( ) { }
3531
36- public struct TopLevelStruct {
3732 @available ( macOS 11 . 0 , * )
3833 @_backDeploy ( macOS 12 . 0 )
39- public func backDeployedMethod ( ) { }
34+ public var backDeployedComputedProperty : Int { 98 }
4035}
4136
4237// MARK: - Unsupported declaration types
4338
4439@available ( macOS 11 . 0 , * )
4540@_backDeploy ( macOS 12 . 0 ) // expected-error {{'@_backDeploy' attribute cannot be applied to this declaration}}
46- public class CannotBackDeployClass {
47- @available ( macOS 11 . 0 , * )
48- @_backDeploy ( macOS 12 . 0 ) // expected-error {{'@_backDeploy' attribute cannot be applied to this declaration}}
49- public var cannotBackDeploystoredProperty : Int = 83
50- }
41+ public class CannotBackDeployClass { }
5142
5243@available ( macOS 11 . 0 , * )
5344@_backDeploy ( macOS 12 . 0 ) // expected-error {{'@_backDeploy' attribute cannot be applied to this declaration}}
54- public struct CannotBackDeployStruct { }
45+ public struct CannotBackDeployStruct {
46+ @available ( macOS 11 . 0 , * )
47+ @_backDeploy ( macOS 12 . 0 ) // expected-error {{'@_backDeploy' must not be used on stored properties}}
48+ public var cannotBackDeployStoredProperty : Int = 83
49+
50+ @available ( macOS 11 . 0 , * )
51+ @_backDeploy ( macOS 12 . 0 ) // expected-error {{'@_backDeploy' must not be used on stored properties}}
52+ public lazy var cannotBackDeployLazyStoredProperty : Int = 15
53+ }
5554
5655@available ( macOS 11 . 0 , * )
5756@_backDeploy ( macOS 12 . 0 ) // expected-error {{'@_backDeploy' attribute cannot be applied to this declaration}}
@@ -62,7 +61,7 @@ public enum CannotBackDeployEnum {
6261}
6362
6463@available ( macOS 11 . 0 , * )
65- @_backDeploy ( macOS 12 . 0 ) // expected-error {{'@_backDeploy' attribute cannot be applied to this declaration }}
64+ @_backDeploy ( macOS 12 . 0 ) // expected-error {{'@_backDeploy' must not be used on stored properties }}
6665public var cannotBackDeployTopLevelVar = 79
6766
6867@available ( macOS 11 . 0 , * )
0 commit comments