Merge pull request #38968 from apple/double-async-bad

[Refactoring] Do not add "async" if function is already async
This commit is contained in:
Ben Barham
2021-08-21 07:32:39 +10:00
committed by GitHub
2 changed files with 13 additions and 1 deletions

View File

@@ -21,6 +21,17 @@ func simpleErr(arg: String) async throws -> String { }
func simpleRes(arg: String, _ completion: @escaping (Result<String, Error>) -> Void) { }
func simpleRes(arg: String) async throws -> String { }
// RUN: %refactor-check-compiles -convert-to-async -dump-text -source-filename %s -pos=%(line+1):1 | %FileCheck -check-prefix=ALREADY-ASYNC %s
func alreadyAsync() async {
simple {
print($0)
}
}
// ALREADY-ASYNC: func alreadyAsync() async {
// ALREADY-ASYNC-NEXT: let val0 = await simple()
// ALREADY-ASYNC-NEXT: print(val0)
// ALREADY-ASYNC-NEXT: }
// RUN: %refactor-check-compiles -convert-to-async -dump-text -source-filename %s -pos=%(line+1):1 | %FileCheck -check-prefix=NESTED %s
func nested() {
simple {