@@ -24,16 +24,76 @@ public struct TopLevelStruct {
2424 public var backDeployedComputedProperty : Int { 98 }
2525}
2626
27+ // OK: final function decls in a non-final class
2728public class TopLevelClass {
2829 @available ( macOS 11 . 0 , * )
2930 @_backDeploy ( macOS 12 . 0 )
3031 final public func backDeployedFinalMethod( ) { }
3132
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+
3252 @available ( macOS 11 . 0 , * )
3353 @_backDeploy ( macOS 12 . 0 )
3454 public var backDeployedComputedProperty : Int { 98 }
3555}
3656
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+
3797// MARK: - Unsupported declaration types
3898
3999@_backDeploy ( macOS 12 . 0 ) // expected-error {{'@_backDeploy' attribute cannot be applied to this declaration}}
@@ -60,6 +120,13 @@ public var cannotBackDeployTopLevelVar = 79
60120@_backDeploy ( macOS 12 . 0 ) // expected-error {{'@_backDeploy' attribute cannot be applied to this declaration}}
61121extension TopLevelStruct { }
62122
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+
63130// MARK: - Incompatible declarations
64131
65132@_backDeploy ( macOS 12 . 0 ) // expected-error {{'@_backDeploy' may not be used on fileprivate declarations}}
@@ -71,11 +138,22 @@ private func privateFunc() {}
71138@_backDeploy ( macOS 12 . 0 ) // expected-error {{'@_backDeploy' may not be used on internal declarations}}
72139internal func internalFunc( ) { }
73140
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+
75146public class TopLevelClass2 {
147+ @_backDeploy ( macOS 12 . 0 ) // expected-error {{'@_backDeploy' cannot be applied to a non-final instance method}}
148+ public func nonFinalMethod( ) { }
149+
76150 @available ( macOS 11 . 0 , * )
77151 @_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( ) { }
79157}
80158
81159@_backDeploy ( macOS 12 . 0 ) // expected-error {{'@_backDeploy' requires that 'missingAllAvailabilityFunc()' have explicit availability for macOS}}
@@ -104,17 +182,17 @@ public func duplicatePlatformsFunc2() {}
104182
105183@available ( macOS 11 . 0 , * )
106184@_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 }}
108186public func alwaysEmitIntoClientFunc( ) { }
109187
110188@available ( macOS 11 . 0 , * )
111189@_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 }}
113191public func inlinableFunc( ) { }
114192
115193@available ( macOS 11 . 0 , * )
116194@_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 }}
118196public func transparentFunc( ) { }
119197
120198// MARK: - Attribute parsing
0 commit comments