Skip to content

Commit c3153e0

Browse files
committed
[CSRanking] Account for that fact that some bindings can be type holes
1 parent 22e12e8 commit c3153e0

File tree

1 file changed

+15
-0
lines changed

1 file changed

+15
-0
lines changed

lib/Sema/CSRanking.cpp

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1080,6 +1080,21 @@ SolutionCompareResult ConstraintSystem::compareSolutions(
10801080
continue;
10811081
}
10821082

1083+
// With introduction of holes it's currently possible to form solutions
1084+
// with UnresolvedType bindings, we need to account for that in
1085+
// ranking. If one solution has a hole for a given type variable
1086+
// it's always worse than any non-hole type other solution might have.
1087+
if (type1->is<UnresolvedType>() || type2->is<UnresolvedType>()) {
1088+
if (type1->is<UnresolvedType>()) {
1089+
++score2;
1090+
} else {
1091+
++score1;
1092+
}
1093+
1094+
identical = false;
1095+
continue;
1096+
}
1097+
10831098
// If one type is a subtype of the other, but not vice-versa,
10841099
// we prefer the system with the more-constrained type.
10851100
// FIXME: Collapse this check into the second check.

0 commit comments

Comments
 (0)