Skip to content

Commit b0dc998

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 982a2cb commit b0dc998

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
@@ -6182,7 +6182,7 @@ class AbstractFunctionDecl : public GenericContext, public ValueDecl {
61826182
/// handler if \p asyncAlternative is not set (with the same conditions on
61836183
/// its type as above).
61846184
Optional<unsigned> findPotentialCompletionHandlerParam(
6185-
AbstractFunctionDecl *asyncAlternative = nullptr) const;
6185+
const AbstractFunctionDecl *asyncAlternative = nullptr) const;
61866186

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

lib/AST/Decl.cpp

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

70407040
Optional<unsigned> AbstractFunctionDecl::findPotentialCompletionHandlerParam(
7041-
AbstractFunctionDecl *asyncAlternative) const {
7041+
const AbstractFunctionDecl *asyncAlternative) const {
70427042
const ParameterList *params = getParameters();
70437043
if (params->size() == 0)
70447044
return None;
@@ -7121,7 +7121,7 @@ Optional<unsigned> AbstractFunctionDecl::findPotentialCompletionHandlerParam(
71217121

71227122
// The next original param should match the current async, so don't
71237123
// increment the async index
7124-
potentialParam = asyncParamIndex;
7124+
potentialParam = paramIndex;
71257125
paramIndex++;
71267126
}
71277127
return potentialParam;

0 commit comments

Comments
 (0)