[Refactoring] Convert completion handler when converting function to async

Convert function to async currently only adds "async" to the function and runs the convert call refactoring on the body.

This was intentional, but it turns out to be somewhat confusing. Instead, run the same refactoring as the add async alternative refactoring but just replace rather than add.

Resolves rdar://77103049
This commit is contained in:
Alex Hoppen
2021-04-30 12:53:22 +02:00
parent 7e4b66e071
commit b2378a401e
3 changed files with 9 additions and 8 deletions

View File

@@ -151,14 +151,9 @@ func retStruct() -> MyStruct { return MyStruct() }
protocol MyProtocol {
// RUN: %refactor -add-async-alternative -dump-text -source-filename %s -pos=%(line+2):3 | %FileCheck -check-prefix=PROTO-MEMBER %s
// RUN: %refactor -convert-to-async -dump-text -source-filename %s -pos=%(line+1):3 | %FileCheck -check-prefix=PROTO-MEMBER-TO-ASYNC %s
// RUN: %refactor -convert-to-async -dump-text -source-filename %s -pos=%(line+1):3 | %FileCheck -check-prefix=PROTO-MEMBER %s
func protoMember(completion: (String) -> Void)
// PROTO-MEMBER: func protoMember() async -> String{{$}}
// FIXME: The current async refactoring only refactors the client side and thus only adds the 'async' keyword.
// We should be refactoring the entire method signature here and removing the completion parameter.
// This test currently checks that we are not crashing.
// PROTO-MEMBER-TO-ASYNC: func protoMember(completion: (String) -> Void) async
}
// RUN: not %refactor -add-async-alternative -dump-text -source-filename %s -pos=%(line+1):1