@@ -24,16 +24,76 @@ public struct TopLevelStruct {
24
24
public var backDeployedComputedProperty : Int { 98 }
25
25
}
26
26
27
+ // OK: final function decls in a non-final class
27
28
public class TopLevelClass {
28
29
@available ( macOS 11 . 0 , * )
29
30
@_backDeploy ( macOS 12 . 0 )
30
31
final public func backDeployedFinalMethod( ) { }
31
32
33
+ @available ( macOS 11 . 0 , * )
34
+ @_backDeploy ( macOS 12 . 0 )
35
+ final public var backDeployedFinalComputedProperty : Int { 98 }
36
+
37
+ @available ( macOS 11 . 0 , * )
38
+ @_backDeploy ( macOS 12 . 0 )
39
+ public static func backDeployedStaticMethod( ) { }
40
+
41
+ @available ( macOS 11 . 0 , * )
42
+ @_backDeploy ( macOS 12 . 0 )
43
+ public final class func backDeployedClassMethod( ) { }
44
+ }
45
+
46
+ // OK: function decls in a final class
47
+ final public class FinalTopLevelClass {
48
+ @available ( macOS 11 . 0 , * )
49
+ @_backDeploy ( macOS 12 . 0 )
50
+ public func backDeployedMethod( ) { }
51
+
32
52
@available ( macOS 11 . 0 , * )
33
53
@_backDeploy ( macOS 12 . 0 )
34
54
public var backDeployedComputedProperty : Int { 98 }
35
55
}
36
56
57
+ // OK: final function decls on an actor
58
+ @available ( macOS 11 . 0 , * )
59
+ public actor TopLevelActor {
60
+ @available ( macOS 11 . 0 , * )
61
+ @_backDeploy ( macOS 12 . 0 )
62
+ final public func finalActorMethod( ) { }
63
+
64
+ // OK: actor methods are effectively final
65
+ @available ( macOS 11 . 0 , * )
66
+ @_backDeploy ( macOS 12 . 0 )
67
+ public func actorMethod( ) { }
68
+ }
69
+
70
+ // OK: function decls in extension on public types
71
+ extension TopLevelStruct {
72
+ @available ( macOS 11 . 0 , * )
73
+ @_backDeploy ( macOS 12 . 0 )
74
+ public func backDeployedExtensionMethod( ) { }
75
+ }
76
+
77
+ extension TopLevelClass {
78
+ @available ( macOS 11 . 0 , * )
79
+ @_backDeploy ( macOS 12 . 0 )
80
+ final public func backDeployedExtensionMethod( ) { }
81
+ }
82
+
83
+ extension FinalTopLevelClass {
84
+ @available ( macOS 11 . 0 , * )
85
+ @_backDeploy ( macOS 12 . 0 )
86
+ public func backDeployedExtensionMethod( ) { }
87
+ }
88
+
89
+ public protocol TopLevelProtocol { }
90
+
91
+ extension TopLevelProtocol {
92
+ @available ( macOS 11 . 0 , * )
93
+ @_backDeploy ( macOS 12 . 0 )
94
+ public func backDeployedExtensionMethod( ) { }
95
+ }
96
+
37
97
// MARK: - Unsupported declaration types
38
98
39
99
@_backDeploy ( macOS 12 . 0 ) // expected-error {{'@_backDeploy' attribute cannot be applied to this declaration}}
@@ -60,6 +120,13 @@ public var cannotBackDeployTopLevelVar = 79
60
120
@_backDeploy ( macOS 12 . 0 ) // expected-error {{'@_backDeploy' attribute cannot be applied to this declaration}}
61
121
extension TopLevelStruct { }
62
122
123
+ @_backDeploy ( macOS 12 . 0 ) // expected-error {{'@_backDeploy' attribute cannot be applied to this declaration}}
124
+ protocol CannotBackDeployProtocol { }
125
+
126
+ @available ( macOS 11 . 0 , * )
127
+ @_backDeploy ( macOS 12 . 0 ) // expected-error {{'@_backDeploy' attribute cannot be applied to this declaration}}
128
+ public actor CannotBackDeployActor { }
129
+
63
130
// MARK: - Incompatible declarations
64
131
65
132
@_backDeploy ( macOS 12 . 0 ) // expected-error {{'@_backDeploy' may not be used on fileprivate declarations}}
@@ -71,11 +138,22 @@ private func privateFunc() {}
71
138
@_backDeploy ( macOS 12 . 0 ) // expected-error {{'@_backDeploy' may not be used on internal declarations}}
72
139
internal func internalFunc( ) { }
73
140
74
- // FIXME(backDeploy): back deployed methods must be final
141
+ private struct PrivateTopLevelStruct {
142
+ @_backDeploy ( macOS 12 . 0 ) // expected-error {{'@_backDeploy' may not be used on private declarations}}
143
+ public func effectivelyPrivateFunc( ) { }
144
+ }
145
+
75
146
public class TopLevelClass2 {
147
+ @_backDeploy ( macOS 12 . 0 ) // expected-error {{'@_backDeploy' cannot be applied to a non-final instance method}}
148
+ public func nonFinalMethod( ) { }
149
+
76
150
@available ( macOS 11 . 0 , * )
77
151
@_backDeploy ( macOS 12 . 0 )
78
- public func backDeployedNonFinalMethod( ) { }
152
+ @objc // expected-error {{'@objc' cannot be applied to a back deployed instance method}}
153
+ final public func objcMethod( ) { }
154
+
155
+ @_backDeploy ( macOS 12 . 0 ) // expected-error {{'@_backDeploy' cannot be applied to a non-final class method}}
156
+ public class func nonFinalClassMethod( ) { }
79
157
}
80
158
81
159
@_backDeploy ( macOS 12 . 0 ) // expected-error {{'@_backDeploy' requires that 'missingAllAvailabilityFunc()' have explicit availability for macOS}}
@@ -104,17 +182,17 @@ public func duplicatePlatformsFunc2() {}
104
182
105
183
@available ( macOS 11 . 0 , * )
106
184
@_backDeploy ( macOS 12 . 0 )
107
- @_alwaysEmitIntoClient // expected-error {{'@_alwaysEmitIntoClient' cannot be applied to back deployed declarations }}
185
+ @_alwaysEmitIntoClient // expected-error {{'@_alwaysEmitIntoClient' cannot be applied to a back deployed global function }}
108
186
public func alwaysEmitIntoClientFunc( ) { }
109
187
110
188
@available ( macOS 11 . 0 , * )
111
189
@_backDeploy ( macOS 12 . 0 )
112
- @inlinable // expected-error {{'@inlinable' cannot be applied to back deployed declarations }}
190
+ @inlinable // expected-error {{'@inlinable' cannot be applied to a back deployed global function }}
113
191
public func inlinableFunc( ) { }
114
192
115
193
@available ( macOS 11 . 0 , * )
116
194
@_backDeploy ( macOS 12 . 0 )
117
- @_transparent // expected-error {{'@_transparent' cannot be applied to back deployed declarations }}
195
+ @_transparent // expected-error {{'@_transparent' cannot be applied to a back deployed global function }}
118
196
public func transparentFunc( ) { }
119
197
120
198
// MARK: - Attribute parsing
0 commit comments