1
1
// RUN: %empty-directory(%t)
2
2
3
- // RUN: %target-swift-ide-test(mock-sdk: %clang-importer-sdk) -print-module -source-filename %s -module-to-print=ObjCConcurrency -function-definitions=false -enable-experimental-concurrency > %t/ObjCConcurrency.printed.txt
3
+ // RUN: %target-swift-ide-test(mock-sdk: %clang-importer-sdk) -print-module -print-implicit-attrs - source-filename %s -module-to-print=ObjCConcurrency -function-definitions=false -enable-experimental-concurrency > %t/ObjCConcurrency.printed.txt
4
4
// RUN: %FileCheck -input-file %t/ObjCConcurrency.printed.txt %s
5
5
6
6
// REQUIRES: objc_interop
@@ -11,42 +11,52 @@ import _Concurrency
11
11
12
12
// CHECK: @completionHandlerAsync("doSomethingSlow(_:)", completionHandleIndex: 1)
13
13
// CHECK-NEXT: func doSomethingSlow(_ operation: String, completionHandler handler: @escaping (Int) -> Void)
14
+ // CHECK-NEXT: @discardableResult
14
15
// CHECK-NEXT: func doSomethingSlow(_ operation: String) async -> Int
15
16
16
17
// CHECK: @completionHandlerAsync("doSomethingDangerous(_:)", completionHandleIndex: 1)
17
18
// CHECK-NEXT: func doSomethingDangerous(_ operation: String, completionHandler handler: ((String?, Error?) -> Void)? = nil)
19
+ // CHECK-NEXT: @discardableResult
18
20
// CHECK-NEXT: func doSomethingDangerous(_ operation: String) async throws -> String
19
21
20
22
// CHECK: @completionHandlerAsync("checkAvailability()", completionHandleIndex: 0)
21
23
// CHECK-NEXT: func checkAvailability(completionHandler: @escaping (Bool) -> Void)
24
+ // CHECK-NEXT: @discardableResult
22
25
// CHECK-NEXT: func checkAvailability() async -> Bool
23
26
24
27
// CHECK: @completionHandlerAsync("anotherExample()", completionHandleIndex: 0)
25
28
// CHECK-NEXT: func anotherExample(completionBlock block: @escaping (String) -> Void)
29
+ // CHECK-NEXT: @discardableResult
26
30
// CHECK-NEXT: func anotherExample() async -> String
27
31
28
32
// CHECK: @completionHandlerAsync("finalExample()", completionHandleIndex: 0)
29
33
// CHECK-NEXT: func finalExampleWithReply(to block: @escaping (String) -> Void)
34
+ // CHECK-NEXT: @discardableResult
30
35
// CHECK-NEXT: func finalExample() async -> String
31
36
32
37
// CHECK: @completionHandlerAsync("replyingOperation(_:)", completionHandleIndex: 1)
33
38
// CHECK-NEXT: func replyingOperation(_ operation: String, replyTo block: @escaping (String) -> Void)
39
+ // CHECK-NEXT: @discardableResult
34
40
// CHECK-NEXT: func replyingOperation(_ operation: String) async -> String
35
41
36
42
// CHECK: @completionHandlerAsync("findAnswer()", completionHandleIndex: 0)
37
43
// CHECK-NEXT: func findAnswer(completionHandler handler: @escaping (String?, Error?) -> Void)
44
+ // CHECK-NEXT: @discardableResult
38
45
// CHECK-NEXT: func findAnswer() async throws -> String
39
46
40
47
// CHECK: @completionHandlerAsync("findAnswerFailingly()", completionHandleIndex: 0)
41
48
// CHECK-NEXT: func findAnswerFailingly(completionHandler handler: @escaping (String?, Error?) -> Void) throws
49
+ // CHECK-NEXT: @discardableResult
42
50
// CHECK-NEXT: func findAnswerFailingly() async throws -> String
43
51
44
52
// CHECK: @completionHandlerAsync("findQAndA()", completionHandleIndex: 0)
45
53
// CHECK-NEXT: func findQAndA(completionHandler handler: @escaping (String?, String?, Error?) -> Void)
54
+ // CHECK-NEXT: @discardableResult
46
55
// CHECK-NEXT: func findQAndA() async throws -> (String?, String)
47
56
48
57
// CHECK: @completionHandlerAsync("findQuestionableAnswers()", completionHandleIndex: 0)
49
58
// CHECK-NEXT: func findQuestionableAnswers(completionHandler handler: @escaping CompletionHandler)
59
+ // CHECK-NEXT: @discardableResult
50
60
// CHECK-NEXT: func findQuestionableAnswers() async throws -> (String, String?)
51
61
52
62
// CHECK: @completionHandlerAsync("doSomethingFun(_:)", completionHandleIndex: 1)
@@ -55,18 +65,22 @@ import _Concurrency
55
65
56
66
// CHECK: @completionHandlerAsync("doSomethingConflicted(_:)", completionHandleIndex: 1)
57
67
// CHECK-NEXT: func doSomethingConflicted(_ operation: String, completionHandler handler: @escaping (Int) -> Void)
68
+ // CHECK-NEXT: @discardableResult
58
69
// CHECK-NEXT: func doSomethingConflicted(_ operation: String) async -> Int
70
+ // CHECK-NEXT: @discardableResult
59
71
// CHECK-NEXT: func doSomethingConflicted(_ operation: String) -> Int
60
72
61
73
// CHECK: func dance(_ step: String) async -> String
62
74
// CHECK: func __leap(_ height: Int) async -> String
63
75
64
76
// CHECK: @completionHandlerAsync("runOnMainThread()", completionHandleIndex: 0)
65
77
// CHECK-NEXT: func runOnMainThread(completionHandler completion: (@MainActor (String) -> Void)? = nil)
78
+ // CHECK-NEXT: @discardableResult
66
79
// CHECK-NEXT: func runOnMainThread() async -> String
67
80
68
81
// CHECK: @completionHandlerAsync("asyncImportSame(_:)", completionHandleIndex: 1)
69
82
// CHECK-NEXT: func asyncImportSame(_ operation: String, completionHandler handler: @escaping (Int) -> Void)
83
+ // CHECK-NEXT: @discardableResult
70
84
// CHECK-NEXT: func asyncImportSame(_ operation: String) async -> Int
71
85
// CHECK-NEXT: func asyncImportSame(_ operation: String, replyTo handler: @escaping (Int) -> Void)
72
86
// CHECK-NOT: func asyncImportSame(_ operation: String) async -> Int
@@ -76,20 +90,21 @@ import _Concurrency
76
90
// CHECK-LABEL: protocol RefrigeratorDelegate
77
91
// CHECK-NEXT: func someoneDidOpenRefrigerator(_ fridge: Any)
78
92
// CHECK-NEXT: func refrigerator(_ fridge: Any, didGetFilledWithItems items: [Any])
79
- // CHECK-NEXT: {{^}} func refrigerator(_ fridge: Any, didGetFilledWithIntegers items: UnsafeMutablePointer<Int>, count: Int)
80
- // CHECK-NEXT: {{^}} func refrigerator(_ fridge: Any, willAddItem item: Any)
81
- // CHECK-NEXT: {{^}} func refrigerator(_ fridge: Any, didRemoveItem item: Any) -> Bool
93
+ // CHECK-NEXT: {{^}} @objc func refrigerator(_ fridge: Any, didGetFilledWithIntegers items: UnsafeMutablePointer<Int>, count: Int)
94
+ // CHECK-NEXT: {{^}} @objc func refrigerator(_ fridge: Any, willAddItem item: Any)
95
+ // CHECK-NEXT: @discardableResult
96
+ // CHECK-NEXT: {{^}} @objc func refrigerator(_ fridge: Any, didRemoveItem item: Any) -> Bool
82
97
// CHECK-NEXT: {{^[}]$}}
83
98
84
99
// CHECK-LABEL: protocol ProtocolWithSwiftAttributes {
85
100
// CHECK-NEXT: @actorIndependent func independentMethod()
86
101
// CHECK-NEXT: func asyncHandlerMethod()
87
- // CHECK-NEXT: {{^}} @MainActor func mainActorMethod()
88
- // CHECK-NEXT: {{^}} @MainActor func uiActorMethod()
89
- // CHECK-NEXT: {{^}} optional func missingAtAttributeMethod()
102
+ // CHECK-NEXT: {{^}} @objc @MainActor func mainActorMethod()
103
+ // CHECK-NEXT: {{^}} @objc @MainActor func uiActorMethod()
104
+ // CHECK-NEXT: {{^}} @objc optional func missingAtAttributeMethod()
90
105
// CHECK-NEXT: {{^[}]$}}
91
106
92
- // CHECK: {{^}}var MAGIC_NUMBER: Int32 { get }
107
+ // CHECK: {{^}}@actorIndependent(unsafe) var MAGIC_NUMBER: Int32 { get }
93
108
94
109
// CHECK: func doSomethingConcurrently(_ block: @Sendable () -> Void)
95
110
0 commit comments