Skip to content

Commit f75eca9

Browse files
committed
[ConstraintSystem] Allow early conformance checking for overload choices
if the best solution has a non-default literal type.
1 parent a3957b9 commit f75eca9

File tree

1 file changed

+17
-3
lines changed

1 file changed

+17
-3
lines changed

lib/Sema/CSStep.cpp

Lines changed: 17 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -642,9 +642,23 @@ bool DisjunctionStep::shouldSkip(const DisjunctionChoice &choice) const {
642642
// current score), we can skip any generic operators with conformance
643643
// requirements that are not satisfied by any known argument types.
644644
auto argFnType = CS.getAppliedDisjunctionArgumentFunction(Disjunction);
645-
auto bestScore = getBestScore(Solutions);
646-
auto bestChoiceNeedsConversions = bestScore && (bestScore > getCurrentScore());
647-
if (bestScore && !bestChoiceNeedsConversions && choice.isGenericOperator() && argFnType) {
645+
auto checkRequirementsEarly = [&]() -> bool {
646+
auto bestScore = getBestScore(Solutions);
647+
if (!(bestScore && choice.isGenericOperator() && argFnType))
648+
return false;
649+
650+
auto currentScore = getCurrentScore();
651+
for (unsigned i = 0; i < NumScoreKinds; ++i) {
652+
if (i == SK_NonDefaultLiteral)
653+
continue;
654+
655+
if (bestScore->Data[i] > currentScore.Data[i])
656+
return false;
657+
}
658+
659+
return true;
660+
};
661+
if (checkRequirementsEarly()) {
648662
Constraint *constraint = choice;
649663
auto *decl = constraint->getOverloadChoice().getDecl();
650664
auto *useDC = constraint->getOverloadUseDC();

0 commit comments

Comments
 (0)