Skip to content

Commit f6a8dab

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 7e7b521 commit f6a8dab

File tree

7 files changed

+546
-158
lines changed

7 files changed

+546
-158
lines changed

include/swift/AST/Decl.h

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

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

lib/AST/Decl.cpp

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

71227122
Optional<unsigned> AbstractFunctionDecl::findPotentialCompletionHandlerParam(
7123-
AbstractFunctionDecl *asyncAlternative) const {
7123+
const AbstractFunctionDecl *asyncAlternative) const {
71247124
const ParameterList *params = getParameters();
71257125
if (params->size() == 0)
71267126
return None;
@@ -7203,7 +7203,7 @@ Optional<unsigned> AbstractFunctionDecl::findPotentialCompletionHandlerParam(
72037203

72047204
// The next original param should match the current async, so don't
72057205
// increment the async index
7206-
potentialParam = asyncParamIndex;
7206+
potentialParam = paramIndex;
72077207
paramIndex++;
72087208
}
72097209
return potentialParam;

0 commit comments

Comments
 (0)