@@ -111,11 +111,18 @@ func errorOnly(completion: (Error?) -> Void) { }
111111// ASYNC-ERRORONLY-NEXT: }
112112// ASYNC-ERRORONLY: func errorOnly() async throws { }
113113
114- // RUN: %refactor-check-compiles -add-async-alternative -dump-text -source-filename %s -pos=%(line+1):1 | %FileCheck -check-prefix=ASYNC-ERRORNONOPTIONALRESULT %s
114+ // RUN: %refactor -add-async-alternative -dump-text -source-filename %s -pos=%(line+1):1 | %FileCheck -check-prefix=ASYNC-ERRORNONOPTIONALRESULT %s
115115func errorNonOptionalResult( completion: ( String , Error ? ) -> Void ) { }
116- // We cannot convert the deprecated non-async method to call the async method because we can't synthesize the non-optional completion param. Smoke check for some keywords that would indicate we rewrote the body.
117- // ASYNC-ERRORNONOPTIONALRESULT-NOT: detach
118- // ASYNC-ERRORNONOPTIONALRESULT-NOT: await
116+ // ASYNC-ERRORNONOPTIONALRESULT: {
117+ // ASYNC-ERRORNONOPTIONALRESULT-NEXT: async {
118+ // ASYNC-ERRORNONOPTIONALRESULT-NEXT: do {
119+ // ASYNC-ERRORNONOPTIONALRESULT-NEXT: let result = try await errorNonOptionalResult()
120+ // ASYNC-ERRORNONOPTIONALRESULT-NEXT: completion(result, nil)
121+ // ASYNC-ERRORNONOPTIONALRESULT-NEXT: } catch {
122+ // ASYNC-ERRORNONOPTIONALRESULT-NEXT: completion(<#String#>, error)
123+ // ASYNC-ERRORNONOPTIONALRESULT-NEXT: }
124+ // ASYNC-ERRORNONOPTIONALRESULT-NEXT: }
125+ // ASYNC-ERRORNONOPTIONALRESULT-NEXT: }
119126// ASYNC-ERRORNONOPTIONALRESULT: func errorNonOptionalResult() async throws -> String { }
120127
121128// RUN: %refactor-check-compiles -add-async-alternative -dump-text -source-filename %s -pos=%(line+1):1 | %FileCheck -check-prefix=ASYNC-CUSTOMERROR %s
@@ -244,9 +251,18 @@ func mixed(_ completion: (String?, Int) -> Void) { }
244251// MIXED-NEXT: }
245252// MIXED: func mixed() async -> (String?, Int) { }
246253
247- // RUN: %refactor-check-compiles -add-async-alternative -dump-text -source-filename %s -pos=%(line+1):1 | %FileCheck -check-prefix=MIXED-OPTIONAL-ERROR %s
254+ // RUN: %refactor -add-async-alternative -dump-text -source-filename %s -pos=%(line+1):1
248255func mixedOptionalError( _ completion: ( String ? , Int , Error ? ) -> Void ) { }
249- // MIXED-OPTIONAL-ERROR-NOT: async {
256+ // MIXED-OPTIONAL-ERROR: {
257+ // MIXED-OPTIONAL-ERROR-NEXT: async {
258+ // MIXED-OPTIONAL-ERROR-NEXT: do {
259+ // MIXED-OPTIONAL-ERROR-NEXT: let result = try await mixedOptionalError()
260+ // MIXED-OPTIONAL-ERROR-NEXT: completion(result.0, result.1, nil)
261+ // MIXED-OPTIONAL-ERROR-NEXT: } catch {
262+ // MIXED-OPTIONAL-ERROR-NEXT: completion(nil, <#Int#>, error)
263+ // MIXED-OPTIONAL-ERROR-NEXT: }
264+ // MIXED-OPTIONAL-ERROR-NEXT: }
265+ // MIXED-OPTIONAL-ERROR-NEXT: }
250266// MIXED-OPTIONAL-ERROR: func mixedOptionalError() async throws -> (String, Int) { }
251267
252268// RUN: %refactor-check-compiles -add-async-alternative -dump-text -source-filename %s -pos=%(line+1):1 | %FileCheck -check-prefix=MIXED-ERROR %s
@@ -450,9 +466,18 @@ func tooVoidProperAndErrorCompletion(completion: (Void?, String?, Error?) -> Voi
450466// VOID-PROPER-AND-ERROR-HANDLER-NEXT: }
451467// VOID-PROPER-AND-ERROR-HANDLER: func tooVoidProperAndErrorCompletion() async throws -> (Void, String) {}
452468
453- // RUN: %refactor -add-async-alternative -dump-text -source-filename %s -pos=%(line+1):1 | %FileCheck -check-prefix VOID-AND-ERROR-HANDLER %s
469+ // RUN: %refactor-check-compiles -add-async-alternative -dump-text -source-filename %s -pos=%(line+1):1
454470func voidAndErrorCompletion( completion: ( Void , Error ? ) -> Void ) { }
455- // VOID-AND-ERROR-HANDLER-NOT: async {
471+ // VOID-AND-ERROR-HANDLER: {
472+ // VOID-AND-ERROR-HANDLER-NEXT: async {
473+ // VOID-AND-ERROR-HANDLER-NEXT: do {
474+ // VOID-AND-ERROR-HANDLER-NEXT: try await voidAndErrorCompletion()
475+ // VOID-AND-ERROR-HANDLER-NEXT: completion((), nil)
476+ // VOID-AND-ERROR-HANDLER-NEXT: } catch {
477+ // VOID-AND-ERROR-HANDLER-NEXT: completion((), error)
478+ // VOID-AND-ERROR-HANDLER-NEXT: }
479+ // VOID-AND-ERROR-HANDLER-NEXT: }
480+ // VOID-AND-ERROR-HANDLER-NEXT: }
456481// VOID-AND-ERROR-HANDLER: func voidAndErrorCompletion() async throws {}
457482
458483// 2. Check that the various ways to call a function (and the positions the
0 commit comments