Skip to content

Commit f4f58f9

Browse files
committed
[CSSolver] Prefer disjunction that has at some favored overloads over one that has none
If one of the sides has no favored overloads, it's a strong enough indication that we know more about the other side.
1 parent ad787a4 commit f4f58f9

File tree

1 file changed

+8
-1
lines changed

1 file changed

+8
-1
lines changed

lib/Sema/CSSolver.cpp

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2190,8 +2190,15 @@ ConstraintSystem::selectBestDisjunction(ArrayRef<Constraint *> disjunctions) {
21902190
unsigned firstFavored = first->countFavoredNestedConstraints();
21912191
unsigned secondFavored = second->countFavoredNestedConstraints();
21922192

2193-
if (!isOperatorDisjunction(first) || !isOperatorDisjunction(second))
2193+
if (!isOperatorDisjunction(first) || !isOperatorDisjunction(second)) {
2194+
// If one of the sides has favored overloads, let's prefer it
2195+
// since it's a strong enough signal that there is something
2196+
// known about the arguments associated with the call.
2197+
if (firstFavored == 0 || secondFavored == 0)
2198+
return firstFavored > secondFavored;
2199+
21942200
return firstActive < secondActive;
2201+
}
21952202

21962203
if (firstFavored == secondFavored) {
21972204
// Look for additional choices that are "favored"

0 commit comments

Comments
 (0)