Skip to content

Commit 69571db

Browse files
authored
Merge pull request #77570 from tshortli/back-deployed-objc-tests
Tests: Expand tests for @backDeployed diagnostics on Obj-C compatible decls
2 parents 184058e + e52a150 commit 69571db

File tree

2 files changed

+86
-8
lines changed

2 files changed

+86
-8
lines changed
+86
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,86 @@
1+
// RUN: %target-swift-frontend(mock-sdk: %clang-importer-sdk) -typecheck -parse-as-library -verify %s
2+
3+
// REQUIRES: OS=macosx
4+
5+
import Foundation
6+
7+
public class SwiftClass {
8+
@backDeployed(before: macOS 12.0) // expected-error {{'@backDeployed' must not be used on an '@objc' instance method}}
9+
@objc final public func objCMethod() {}
10+
}
11+
12+
public class ObjCClass: NSObject {
13+
@backDeployed(before: macOS 12.0) // expected-error {{'@backDeployed' cannot be applied to a non-final instance method}}
14+
public func method() {}
15+
16+
@backDeployed(before: macOS 12.0) // expected-error {{'@backDeployed' must not be used on an '@objc' instance method}}
17+
@objc public func objcMethod() {}
18+
19+
@backDeployed(before: macOS 12.0) // expected-error {{'@backDeployed' must not be used on an '@objc' instance method}}
20+
@objc final public func finalObjcMethod() {}
21+
22+
@backDeployed(before: macOS 12.0)
23+
final public func finalMethod() {}
24+
25+
@backDeployed(before: macOS 12.0) // expected-error {{'@backDeployed' cannot be applied to a non-final instance method}}
26+
@nonobjc public func nonObjCMethod() {}
27+
28+
@backDeployed(before: macOS 12.0)
29+
@nonobjc final public func finalNonObjCMethod() {}
30+
31+
@backDeployed(before: macOS 12.0) // expected-error {{'@backDeployed' cannot be applied to a non-final property}}
32+
public var property: [Int] { [1] }
33+
34+
@backDeployed(before: macOS 12.0) // expected-error {{'@backDeployed' must not be used on an '@objc' property}}
35+
@objc public var objCProperty: [Int] { [1] }
36+
37+
@backDeployed(before: macOS 12.0) // expected-error {{'@backDeployed' must not be used on an '@objc' property}}
38+
@objc public final var finalObjCProperty: [Int] { [1] }
39+
40+
@backDeployed(before: macOS 12.0)
41+
public final var finalProperty: [Int] { [1] }
42+
43+
@backDeployed(before: macOS 12.0) // expected-error {{'@backDeployed' cannot be applied to a non-final property}}
44+
@nonobjc public var nonObjCProperty: [Int] { [1] }
45+
46+
@backDeployed(before: macOS 12.0)
47+
@nonobjc public final var finalNonObjCProperty: [Int] { [1] }
48+
}
49+
50+
extension DummyClass {
51+
@backDeployed(before: macOS 12.0) // expected-error {{'@backDeployed' cannot be applied to a non-final instance method}}
52+
public func method() {}
53+
54+
@backDeployed(before: macOS 12.0) // expected-error {{'@backDeployed' must not be used on an '@objc' instance method}}
55+
@objc public func objcMethod() {}
56+
57+
@backDeployed(before: macOS 12.0) // expected-error {{'@backDeployed' must not be used on an '@objc' instance method}}
58+
@objc final public func finalObjcMethod() {}
59+
60+
@backDeployed(before: macOS 12.0)
61+
final public func finalMethod() {}
62+
63+
@backDeployed(before: macOS 12.0) // expected-error {{'@backDeployed' cannot be applied to a non-final instance method}}
64+
@nonobjc public func nonObjCMethod() {}
65+
66+
@backDeployed(before: macOS 12.0)
67+
@nonobjc final public func finalNonObjCMethod() {}
68+
69+
@backDeployed(before: macOS 12.0) // expected-error {{'@backDeployed' cannot be applied to a non-final property}}
70+
public var property: [Int] { [1] }
71+
72+
@backDeployed(before: macOS 12.0) // expected-error {{'@backDeployed' must not be used on an '@objc' property}}
73+
@objc public var objCProperty: [Int] { [1] }
74+
75+
@backDeployed(before: macOS 12.0) // expected-error {{'@backDeployed' must not be used on an '@objc' property}}
76+
@objc public final var finalObjCProperty: [Int] { [1] }
77+
78+
@backDeployed(before: macOS 12.0)
79+
public final var finalProperty: [Int] { [1] }
80+
81+
@backDeployed(before: macOS 12.0) // expected-error {{'@backDeployed' cannot be applied to a non-final property}}
82+
@nonobjc public var nonObjCProperty: [Int] { [1] }
83+
84+
@backDeployed(before: macOS 12.0)
85+
@nonobjc public final var finalNonObjCProperty: [Int] { [1] }
86+
}

test/attr/attr_objc.swift

-8
Original file line numberDiff line numberDiff line change
@@ -2696,11 +2696,3 @@ class issue55246 {
26962696
subscript<T>(foo : [T]) -> Int { return 0 }
26972697
// access-note-adjust{{@objc}} expected-error@-1 {{subscript cannot be marked @objc because it has generic parameters}}
26982698
}
2699-
2700-
// @backDeployed
2701-
2702-
public class BackDeployClass {
2703-
@backDeployed(before: macOS 12.0) // expected-error {{'@backDeployed' must not be used on an '@objc' instance method}}
2704-
@objc
2705-
final public func objcMethod() {}
2706-
}

0 commit comments

Comments
 (0)