mirror of
https://github.com/apple/swift.git
synced 2025-12-21 12:14:44 +01:00
Fixed issue #72085 where BinaryExpr fix-it suggested missing operator.
This commit is contained in:
@@ -5863,12 +5863,16 @@ bool OutOfOrderArgumentFailure::diagnoseAsError() {
|
||||
|
||||
// Move requires postfix comma only if argument is moved in-between
|
||||
// other arguments.
|
||||
bool requiresComma =
|
||||
!isExpr<BinaryExpr>(anchor) && PrevArgIdx != args->size() - 1;
|
||||
std::string argumentSeparator;
|
||||
if (auto *BE = getAsExpr<BinaryExpr>(anchor)) {
|
||||
auto operatorName = std::string(*getOperatorName(BE->getFn()));
|
||||
argumentSeparator = " " + operatorName + " ";
|
||||
} else if (PrevArgIdx != args->size() - 1) {
|
||||
argumentSeparator = ", ";
|
||||
}
|
||||
|
||||
diag.fixItRemove(removalRange);
|
||||
diag.fixItInsert(secondRange.Start,
|
||||
text.str() + (requiresComma ? ", " : ""));
|
||||
diag.fixItInsert(secondRange.Start, text.str() + argumentSeparator);
|
||||
};
|
||||
|
||||
// There are 4 diagnostic messages variations depending on
|
||||
|
||||
Reference in New Issue
Block a user