Revert "[CSSolver] Use correct locator when matching function result types re…"

This commit is contained in:
Pavel Yaskevich
2018-03-07 23:19:30 -08:00
committed by GitHub
parent c4c5b7130e
commit d8b355dbae
7 changed files with 14 additions and 174 deletions

View File

@@ -1007,32 +1007,14 @@ SolutionCompareResult ConstraintSystem::compareSolutions(
// Compare the type variable bindings.
auto &tc = cs.getTypeChecker();
for (auto &binding : diff.typeBindings) {
auto type1 = binding.bindings[idx1];
auto type2 = binding.bindings[idx2];
auto &impl = binding.typeVar->getImpl();
if (auto *locator = impl.getLocator()) {
auto path = locator->getPath();
if (!path.empty() &&
path.back().getKind() == ConstraintLocator::ClosureResult) {
// Since we support `() -> T` to `() -> Void` and
// `() -> Never` to `() -> T` conversions, it's always
// preferable to pick `T` rather than `Never` with
// all else being equal.
if (type2->isUninhabited())
++score1;
if (type1->isUninhabited())
++score2;
}
}
// If the type variable isn't one for which we should be looking at the
// bindings, don't.
if (!impl.prefersSubtypeBinding())
if (!binding.typeVar->getImpl().prefersSubtypeBinding())
continue;
auto type1 = binding.bindings[idx1];
auto type2 = binding.bindings[idx2];
// If the types are equivalent, there's nothing more to do.
if (type1->isEqual(type2))
continue;