Skip to content

Commit 0051c89

Browse files
committed
[ConstraintSystem] Account for scoring in the new generic overload
heuristics.
1 parent dff5401 commit 0051c89

File tree

1 file changed

+3
-2
lines changed

1 file changed

+3
-2
lines changed

lib/Sema/CSStep.cpp

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -623,7 +623,8 @@ bool DisjunctionStep::shouldSkip(const DisjunctionChoice &choice) const {
623623
// If the solver already found a solution with a better overload choice that
624624
// can be unconditionally substituted by the current choice, skip the current
625625
// choice.
626-
if (LastSolvedChoice && isGenericDisjunctionChoice(choice)) {
626+
if (LastSolvedChoice && LastSolvedChoice->second == getCurrentScore() &&
627+
isGenericDisjunctionChoice(choice)) {
627628
auto *declA = LastSolvedChoice->first->getOverloadChoice().getDecl();
628629
auto *declB = static_cast<Constraint *>(choice)->getOverloadChoice().getDecl();
629630

@@ -639,7 +640,7 @@ bool DisjunctionStep::shouldSkip(const DisjunctionChoice &choice) const {
639640
// requirements that are not satisfied by any known argument types.
640641
auto bestScore = getBestScore(Solutions);
641642
auto bestChoiceNeedsConversions = bestScore && (bestScore > getCurrentScore());
642-
if (!bestChoiceNeedsConversions && choice.isGenericOperator() && argFnType) {
643+
if (bestScore && !bestChoiceNeedsConversions && choice.isGenericOperator() && argFnType) {
643644
Constraint *constraint = choice;
644645
auto *decl = constraint->getOverloadChoice().getDecl();
645646
auto *useDC = constraint->getOverloadUseDC();

0 commit comments

Comments
 (0)