Skip to content

Commit dd978cc

Browse files
committed
[Refactoring] Support refactoring calls to async if a variable or function is used as completion handler
Previously, we only supported refactoring a function to call the async alternative if a closure was used for the callback parameter. With this change, we also support calling a arbitrary function (or variable with function type) that is passed to the completion handler argument. The implementation basically re-uses the code we already have to create the legacy function’s body (which calls the newly created async version and then forwards the arguments to the legacy completion handler). To describe the completion handler that the result is being forwarded to, I’m also using `AsyncHandlerDesc`, but since the completion handler may be a variable, it doesn’t necessarily have an `Index` within a function decl that declares it. Because of this, I split the `AsyncHandlerDesc` up into a context-free `AsyncHandlerDesc` (without an `Index`) and `AsyncHandlerParamDesc` (which includes the `Index`). It turns out that `AsyncHandlerDesc` is sufficient in most places. Resolves rdar://77460524
1 parent b8ec778 commit dd978cc

File tree

2 files changed

+458
-95
lines changed

2 files changed

+458
-95
lines changed

0 commit comments

Comments
 (0)