Skip to content

Commit ac92f4e

Browse files
[Sema] Ignore individual FunctionArgument inout mismatch fix if there is already a fix recorded for function type locator
1 parent 2ae2fee commit ac92f4e

File tree

1 file changed

+13
-1
lines changed

1 file changed

+13
-1
lines changed

lib/Sema/CSSimplify.cpp

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4497,8 +4497,21 @@ bool ConstraintSystem::repairFailures(
44974497
break;
44984498
}
44994499

4500+
auto *parentLoc = getConstraintLocator(anchor, path);
4501+
45004502
if ((lhs->is<InOutType>() && !rhs->is<InOutType>()) ||
45014503
(!lhs->is<InOutType>() && rhs->is<InOutType>())) {
4504+
// Since `FunctionArgument` as a last locator element represents
4505+
// a single parameter of the function type involved in a conversion
4506+
// to another function type, see `matchFunctionTypes`. If there is already
4507+
// a fix for the this convertion, we can just ignore individual function
4508+
// argument in-out mismatch failure by considered this fixed increasing
4509+
// the score.
4510+
if (hasFixFor(parentLoc)) {
4511+
increaseScore(SK_Fix);
4512+
return true;
4513+
}
4514+
45024515
// We want to call matchTypes with the default decomposition options
45034516
// in case there are type variables that we couldn't bind due to the
45044517
// inout attribute mismatch.
@@ -4514,7 +4527,6 @@ bool ConstraintSystem::repairFailures(
45144527
}
45154528
}
45164529

4517-
auto *parentLoc = getConstraintLocator(anchor, path);
45184530
// In cases like this `FunctionArgument` as a last locator element
45194531
// represents a single parameter of the function type involved in
45204532
// a conversion to another function type, see `matchFunctionTypes`.

0 commit comments

Comments
 (0)