11// RUN: %empty-directory(%t)
22
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
44// RUN: %FileCheck -input-file %t/ObjCConcurrency.printed.txt %s
55
66// REQUIRES: objc_interop
@@ -11,42 +11,52 @@ import _Concurrency
1111
1212// CHECK: @completionHandlerAsync("doSomethingSlow(_:)", completionHandleIndex: 1)
1313// CHECK-NEXT: func doSomethingSlow(_ operation: String, completionHandler handler: @escaping (Int) -> Void)
14+ // CHECK-NEXT: @discardableResult
1415// CHECK-NEXT: func doSomethingSlow(_ operation: String) async -> Int
1516
1617// CHECK: @completionHandlerAsync("doSomethingDangerous(_:)", completionHandleIndex: 1)
1718// CHECK-NEXT: func doSomethingDangerous(_ operation: String, completionHandler handler: ((String?, Error?) -> Void)? = nil)
19+ // CHECK-NEXT: @discardableResult
1820// CHECK-NEXT: func doSomethingDangerous(_ operation: String) async throws -> String
1921
2022// CHECK: @completionHandlerAsync("checkAvailability()", completionHandleIndex: 0)
2123// CHECK-NEXT: func checkAvailability(completionHandler: @escaping (Bool) -> Void)
24+ // CHECK-NEXT: @discardableResult
2225// CHECK-NEXT: func checkAvailability() async -> Bool
2326
2427// CHECK: @completionHandlerAsync("anotherExample()", completionHandleIndex: 0)
2528// CHECK-NEXT: func anotherExample(completionBlock block: @escaping (String) -> Void)
29+ // CHECK-NEXT: @discardableResult
2630// CHECK-NEXT: func anotherExample() async -> String
2731
2832// CHECK: @completionHandlerAsync("finalExample()", completionHandleIndex: 0)
2933// CHECK-NEXT: func finalExampleWithReply(to block: @escaping (String) -> Void)
34+ // CHECK-NEXT: @discardableResult
3035// CHECK-NEXT: func finalExample() async -> String
3136
3237// CHECK: @completionHandlerAsync("replyingOperation(_:)", completionHandleIndex: 1)
3338// CHECK-NEXT: func replyingOperation(_ operation: String, replyTo block: @escaping (String) -> Void)
39+ // CHECK-NEXT: @discardableResult
3440// CHECK-NEXT: func replyingOperation(_ operation: String) async -> String
3541
3642// CHECK: @completionHandlerAsync("findAnswer()", completionHandleIndex: 0)
3743// CHECK-NEXT: func findAnswer(completionHandler handler: @escaping (String?, Error?) -> Void)
44+ // CHECK-NEXT: @discardableResult
3845// CHECK-NEXT: func findAnswer() async throws -> String
3946
4047// CHECK: @completionHandlerAsync("findAnswerFailingly()", completionHandleIndex: 0)
4148// CHECK-NEXT: func findAnswerFailingly(completionHandler handler: @escaping (String?, Error?) -> Void) throws
49+ // CHECK-NEXT: @discardableResult
4250// CHECK-NEXT: func findAnswerFailingly() async throws -> String
4351
4452// CHECK: @completionHandlerAsync("findQAndA()", completionHandleIndex: 0)
4553// CHECK-NEXT: func findQAndA(completionHandler handler: @escaping (String?, String?, Error?) -> Void)
54+ // CHECK-NEXT: @discardableResult
4655// CHECK-NEXT: func findQAndA() async throws -> (String?, String)
4756
4857// CHECK: @completionHandlerAsync("findQuestionableAnswers()", completionHandleIndex: 0)
4958// CHECK-NEXT: func findQuestionableAnswers(completionHandler handler: @escaping CompletionHandler)
59+ // CHECK-NEXT: @discardableResult
5060// CHECK-NEXT: func findQuestionableAnswers() async throws -> (String, String?)
5161
5262// CHECK: @completionHandlerAsync("doSomethingFun(_:)", completionHandleIndex: 1)
@@ -55,18 +65,22 @@ import _Concurrency
5565
5666// CHECK: @completionHandlerAsync("doSomethingConflicted(_:)", completionHandleIndex: 1)
5767// CHECK-NEXT: func doSomethingConflicted(_ operation: String, completionHandler handler: @escaping (Int) -> Void)
68+ // CHECK-NEXT: @discardableResult
5869// CHECK-NEXT: func doSomethingConflicted(_ operation: String) async -> Int
70+ // CHECK-NEXT: @discardableResult
5971// CHECK-NEXT: func doSomethingConflicted(_ operation: String) -> Int
6072
6173// CHECK: func dance(_ step: String) async -> String
6274// CHECK: func __leap(_ height: Int) async -> String
6375
6476// CHECK: @completionHandlerAsync("runOnMainThread()", completionHandleIndex: 0)
6577// CHECK-NEXT: func runOnMainThread(completionHandler completion: (@MainActor (String) -> Void)? = nil)
78+ // CHECK-NEXT: @discardableResult
6679// CHECK-NEXT: func runOnMainThread() async -> String
6780
6881// CHECK: @completionHandlerAsync("asyncImportSame(_:)", completionHandleIndex: 1)
6982// CHECK-NEXT: func asyncImportSame(_ operation: String, completionHandler handler: @escaping (Int) -> Void)
83+ // CHECK-NEXT: @discardableResult
7084// CHECK-NEXT: func asyncImportSame(_ operation: String) async -> Int
7185// CHECK-NEXT: func asyncImportSame(_ operation: String, replyTo handler: @escaping (Int) -> Void)
7286// CHECK-NOT: func asyncImportSame(_ operation: String) async -> Int
@@ -76,20 +90,21 @@ import _Concurrency
7690// CHECK-LABEL: protocol RefrigeratorDelegate
7791// CHECK-NEXT: func someoneDidOpenRefrigerator(_ fridge: Any)
7892// 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
8297// CHECK-NEXT: {{^[}]$}}
8398
8499// CHECK-LABEL: protocol ProtocolWithSwiftAttributes {
85100// CHECK-NEXT: @actorIndependent func independentMethod()
86101// 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()
90105// CHECK-NEXT: {{^[}]$}}
91106
92- // CHECK: {{^}}var MAGIC_NUMBER: Int32 { get }
107+ // CHECK: {{^}}@actorIndependent(unsafe) var MAGIC_NUMBER: Int32 { get }
93108
94109// CHECK: func doSomethingConcurrently(_ block: @Sendable () -> Void)
95110
0 commit comments