@@ -14,9 +14,9 @@ typealias NestedAliasCallback = SomeCallback
14
14
// 1. Check various functions for having/not having async alternatives
15
15
16
16
// RUN: %refactor-check-compiles -add-async-alternative -dump-text -source-filename %s -pos=%(line+4):1 | %FileCheck -check-prefix=ASYNC-SIMPLE %s
17
- // RUN: %refactor -add-async-alternative -dump-text -source-filename %s -pos=%(line+3):6 | %FileCheck -check-prefix=ASYNC-SIMPLE %s
18
- // RUN: %refactor -add-async-alternative -dump-text -source-filename %s -pos=%(line+2):12 | %FileCheck -check-prefix=ASYNC-SIMPLE %s
19
- // RUN: %refactor -add-async-alternative -dump-text -source-filename %s -pos=%(line+1):20 | %FileCheck -check-prefix=ASYNC-SIMPLE %s
17
+ // RUN: %refactor-check-compiles -add-async-alternative -dump-text -source-filename %s -pos=%(line+3):6 | %FileCheck -check-prefix=ASYNC-SIMPLE %s
18
+ // RUN: %refactor-check-compiles -add-async-alternative -dump-text -source-filename %s -pos=%(line+2):12 | %FileCheck -check-prefix=ASYNC-SIMPLE %s
19
+ // RUN: %refactor-check-compiles -add-async-alternative -dump-text -source-filename %s -pos=%(line+1):20 | %FileCheck -check-prefix=ASYNC-SIMPLE %s
20
20
func simple( /*cs*/ completion: @escaping ( String ) -> Void /*ce*/) { }
21
21
// ASYNC-SIMPLE: basic.swift [[# @LINE-1]]:1 -> [[# @LINE-1]]:1
22
22
// ASYNC-SIMPLE-NEXT: @available(*, renamed: "simple()")
@@ -113,7 +113,7 @@ func errorOnly(completion: @escaping (Error?) -> Void) { }
113
113
// ASYNC-ERRORONLY-NEXT: }
114
114
// ASYNC-ERRORONLY: func errorOnly() async throws { }
115
115
116
- // RUN: %refactor -add-async-alternative -dump-text -source-filename %s -pos=%(line+1):1 | %FileCheck -check-prefix=ASYNC-ERRORNONOPTIONALRESULT %s
116
+ // RUN: %refactor-check-compiles -add-async-alternative -dump-text -source-filename %s -pos=%(line+1):1 | %FileCheck -check-prefix=ASYNC-ERRORNONOPTIONALRESULT %s
117
117
func errorNonOptionalResult( completion: @escaping ( String , Error ? ) -> Void ) { }
118
118
// ASYNC-ERRORNONOPTIONALRESULT: {
119
119
// ASYNC-ERRORNONOPTIONALRESULT-NEXT: Task {
@@ -253,7 +253,7 @@ func mixed(_ completion: @escaping (String?, Int) -> Void) { }
253
253
// MIXED-NEXT: }
254
254
// MIXED: func mixed() async -> (String?, Int) { }
255
255
256
- // RUN: %refactor -add-async-alternative -dump-text -source-filename %s -pos=%(line+1):1 | %FileCheck -check-prefix=MIXED-OPTIONAL-ERROR %s
256
+ // RUN: %refactor-check-compiles -add-async-alternative -dump-text -source-filename %s -pos=%(line+1):1 | %FileCheck -check-prefix=MIXED-OPTIONAL-ERROR %s
257
257
func mixedOptionalError( _ completion: @escaping ( String ? , Int , Error ? ) -> Void ) { }
258
258
// MIXED-OPTIONAL-ERROR: {
259
259
// MIXED-OPTIONAL-ERROR-NEXT: Task {
@@ -377,7 +377,7 @@ protocol MyProtocol {
377
377
}
378
378
379
379
// RUN: not %refactor -add-async-alternative -dump-text -source-filename %s -pos=%(line+2):1
380
- // RUN: %refactor -convert-to-async -dump-text -source-filename %s -pos=%(line+1):1 | %FileCheck -check-prefix=NON-COMPLETION %s
380
+ // RUN: %refactor-check-compiles -convert-to-async -dump-text -source-filename %s -pos=%(line+1):1 | %FileCheck -check-prefix=NON-COMPLETION %s
381
381
func nonCompletion( a: Int ) { }
382
382
// NON-COMPLETION: func nonCompletion(a: Int) async { }
383
383
@@ -387,27 +387,27 @@ func nonEscapingCompletion(completion: (Int) -> Void) { }
387
387
// NON-ESCAPING-COMPLETION: func nonEscapingCompletion(completion: (Int) -> Void) async { }
388
388
389
389
// RUN: not %refactor -add-async-alternative -dump-text -source-filename %s -pos=%(line+2):1
390
- // RUN: %refactor -convert-to-async -dump-text -source-filename %s -pos=%(line+1):1 | %FileCheck -check-prefix=MULTIPLE-RESULTS %s
390
+ // RUN: %refactor-check-compiles -convert-to-async -dump-text -source-filename %s -pos=%(line+1):1 | %FileCheck -check-prefix=MULTIPLE-RESULTS %s
391
391
func multipleResults( completion: @escaping ( Result < String , Error > , Result < String , Error > ) -> Void ) { }
392
392
// MULTIPLE-RESULTS: func multipleResults(completion: @escaping (Result<String, Error>, Result<String, Error>) -> Void) async { }
393
393
394
394
// RUN: not %refactor -add-async-alternative -dump-text -source-filename %s -pos=%(line+2):1
395
- // RUN: %refactor -convert-to-async -dump-text -source-filename %s -pos=%(line+1):1 | %FileCheck -check-prefix=NON-VOID %s
395
+ // RUN: %refactor-check-compiles -convert-to-async -dump-text -source-filename %s -pos=%(line+1):1 | %FileCheck -check-prefix=NON-VOID %s
396
396
func nonVoid( completion: @escaping ( String ) -> Void ) -> Int { return 0 }
397
397
// NON-VOID: func nonVoid(completion: @escaping (String) -> Void) async -> Int { return 0 }
398
398
399
399
// RUN: not %refactor -add-async-alternative -dump-text -source-filename %s -pos=%(line+2):1
400
- // RUN: %refactor -convert-to-async -dump-text -source-filename %s -pos=%(line+1):1 | %FileCheck -check-prefix=COMPLETION-NON-VOID %s
400
+ // RUN: %refactor-check-compiles -convert-to-async -dump-text -source-filename %s -pos=%(line+1):1 | %FileCheck -check-prefix=COMPLETION-NON-VOID %s
401
401
func completionNonVoid( completion: @escaping ( String ) -> Int ) -> Void { }
402
402
// COMPLETION-NON-VOID: func completionNonVoid(completion: @escaping (String) -> Int) async -> Void { }
403
403
404
404
// RUN: not %refactor -add-async-alternative -dump-text -source-filename %s -pos=%(line+2):1
405
- // RUN: %refactor -convert-to-async -dump-text -source-filename %s -pos=%(line+1):1 | %FileCheck -check-prefix=ALREADY-THROWS %s
405
+ // RUN: %refactor-check-compiles -convert-to-async -dump-text -source-filename %s -pos=%(line+1):1 | %FileCheck -check-prefix=ALREADY-THROWS %s
406
406
func alreadyThrows( completion: @escaping ( String ) -> Void ) throws { }
407
407
// ALREADY-THROWS: func alreadyThrows(completion: @escaping (String) -> Void) async throws { }
408
408
409
409
// RUN: not %refactor -add-async-alternative -dump-text -source-filename %s -pos=%(line+2):1
410
- // RUN: %refactor -convert-to-async -dump-text -source-filename %s -pos=%(line+1):1 | %FileCheck -check-prefix=AUTO-CLOSURE %s
410
+ // RUN: %refactor-check-compiles -convert-to-async -dump-text -source-filename %s -pos=%(line+1):1 | %FileCheck -check-prefix=AUTO-CLOSURE %s
411
411
func noParamAutoclosure( completion: @escaping @autoclosure ( ) -> Void ) { }
412
412
// AUTO-CLOSURE: func noParamAutoclosure(completion: @escaping @autoclosure () -> Void) async { }
413
413
@@ -640,13 +640,17 @@ func testSkipAssign() {
640
640
// SKIP-ASSIGN-FUNC-NEXT: print("assigned"){{$}}
641
641
// SKIP-ASSIGN-FUNC-NEXT: }{{$}}
642
642
643
+ // Same as noParamAutoclosure defined above, but used just for the test below.
644
+ // This avoids a compiler error when converting noParamAutoclosure to async.
645
+ func noParamAutoclosure2( completion: @escaping @autoclosure ( ) -> Void ) { }
646
+
643
647
// RUN: %refactor -convert-to-async -dump-text -source-filename %s -pos=%(line+1):1 | %FileCheck -check-prefixes=SKIP-AUTOCLOSURE-FUNC %s
644
648
func testSkipAutoclosure( ) {
645
649
// RUN: not %refactor -convert-call-to-async-alternative -dump-text -source-filename %s -pos=%(line+1):3
646
- noParamAutoclosure ( completion: print ( " autoclosure " ) )
650
+ noParamAutoclosure2 ( completion: print ( " autoclosure " ) )
647
651
}
648
652
// SKIP-AUTOCLOSURE-FUNC: {{^}}func testSkipAutoclosure() async {
649
- // SKIP-AUTOCLOSURE-FUNC: noParamAutoclosure (completion: print("autoclosure")){{$}}
653
+ // SKIP-AUTOCLOSURE-FUNC: noParamAutoclosure2 (completion: print("autoclosure")){{$}}
650
654
651
655
// RUN: %refactor -convert-to-async -dump-text -source-filename %s -pos=%(line+1):1 | %FileCheck -check-prefix=EMPTY-CAPTURE %s
652
656
func testEmptyCapture( ) {
0 commit comments