mirror of
https://github.com/apple/swift.git
synced 2025-12-21 12:14:44 +01:00
[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:
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user