mirror of
https://github.com/apple/swift.git
synced 2025-12-21 12:14:44 +01:00
[Refactoring] Do not add "async" if function is already async
Convert Function to Async is available on an async function. It could be useful to run this refactoring still, as it would attempt to convert any completion-handler functions to their async alternatives. Keep allowing this, but make sure not to re-add "async" to the function declaration. Resolves rdar://82156720
This commit is contained in:
@@ -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 {
|
||||
|
||||
Reference in New Issue
Block a user