Skip to content

Commit 8fe1e3c

Browse files
[CSSimplify] Removing repair failures logic that reject duplicated argument fix and increasing the score instead
1 parent 1609088 commit 8fe1e3c

File tree

1 file changed

+14
-17
lines changed

1 file changed

+14
-17
lines changed

lib/Sema/CSSimplify.cpp

Lines changed: 14 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -3653,22 +3653,6 @@ bool ConstraintSystem::repairFailures(
36533653
if (rhs->isAny())
36543654
break;
36553655

3656-
// If there are any other argument mismatches already detected
3657-
// for this call, we can consider overload unrelated.
3658-
if (llvm::any_of(getFixes(), [&](const ConstraintFix *fix) {
3659-
auto *locator = fix->getLocator();
3660-
// Since arguments to @dynamicCallable form either an array
3661-
// or a dictionary and all have to match the same element type,
3662-
// let's allow multiple invalid arguments.
3663-
if (locator->findFirst<LocatorPathElt::DynamicCallable>())
3664-
return false;
3665-
3666-
return locator->findLast<LocatorPathElt::ApplyArgToParam>()
3667-
? locator->getAnchor() == anchor
3668-
: false;
3669-
}))
3670-
break;
3671-
36723656
// If there are any restrictions here we need to wait and let
36733657
// `simplifyRestrictedConstraintImpl` handle them.
36743658
if (llvm::any_of(conversionsOrFixes,
@@ -9841,7 +9825,20 @@ ConstraintSystem::SolutionKind ConstraintSystem::simplifyFixConstraint(
98419825

98429826
case FixKind::AllowArgumentTypeMismatch: {
98439827
increaseScore(SK_Fix);
9844-
return recordFix(fix) ? SolutionKind::Error : SolutionKind::Solved;
9828+
9829+
auto impact = 1;
9830+
// If there are any other argument mismatches already detected for this
9831+
// call, we increase the score even higher so more argument fixes means
9832+
// less viable is the overload.
9833+
if (llvm::any_of(getFixes(), [&](const ConstraintFix *fix) {
9834+
auto *fixLocator = fix->getLocator();
9835+
return fixLocator->findLast<LocatorPathElt::ApplyArgToParam>()
9836+
? fixLocator->getAnchor() == locator.getAnchor()
9837+
: false;
9838+
}))
9839+
impact = 2;
9840+
9841+
return recordFix(fix, impact) ? SolutionKind::Error : SolutionKind::Solved;
98459842
}
98469843

98479844
case FixKind::ContextualMismatch: {

0 commit comments

Comments
 (0)