Skip to content

Commit 9f26b23

Browse files
committed
[Refactoring] Use known alternative in async refactoring if one exists
Update the async refactorings to use the name from the async alternative if one is known, rather than always assuming the name matches the synchronous function. Note that this could also be used to determine whether results remain optional or not, but that has been left for a future patch. Resolves rdar://80612521
1 parent 8f4d272 commit 9f26b23

File tree

8 files changed

+545
-163
lines changed

8 files changed

+545
-163
lines changed

include/swift/AST/Decl.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6210,7 +6210,7 @@ class AbstractFunctionDecl : public GenericContext, public ValueDecl {
62106210
/// handler if \p asyncAlternative is not set (with the same conditions on
62116211
/// its type as above).
62126212
Optional<unsigned> findPotentialCompletionHandlerParam(
6213-
AbstractFunctionDecl *asyncAlternative = nullptr) const;
6213+
const AbstractFunctionDecl *asyncAlternative = nullptr) const;
62146214

62156215
/// Determine whether this function is implicitly known to have its
62166216
/// parameters of function type be @_unsafeSendable.

lib/AST/Decl.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7092,7 +7092,7 @@ static bool isPotentialCompletionHandler(const ParamDecl *param) {
70927092
}
70937093

70947094
Optional<unsigned> AbstractFunctionDecl::findPotentialCompletionHandlerParam(
7095-
AbstractFunctionDecl *asyncAlternative) const {
7095+
const AbstractFunctionDecl *asyncAlternative) const {
70967096
const ParameterList *params = getParameters();
70977097
if (params->size() == 0)
70987098
return None;
@@ -7175,7 +7175,7 @@ Optional<unsigned> AbstractFunctionDecl::findPotentialCompletionHandlerParam(
71757175

71767176
// The next original param should match the current async, so don't
71777177
// increment the async index
7178-
potentialParam = asyncParamIndex;
7178+
potentialParam = paramIndex;
71797179
paramIndex++;
71807180
}
71817181
return potentialParam;

0 commit comments

Comments
 (0)