Skip to content

Commit b095158

Browse files
committed
[CSBinding] Don't produce type-erased key path bindings for a key path type
Such types are not going to be applied by `ConstraintSystem::resolveClosure` anyway and they impede diagnostics by forcing the solver to produce mutliple equal solutions.
1 parent 0a9e960 commit b095158

File tree

1 file changed

+9
-2
lines changed

1 file changed

+9
-2
lines changed

lib/Sema/CSBindings.cpp

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2060,8 +2060,15 @@ bool TypeVarBindingProducer::computeNext() {
20602060

20612061
for (auto supertype : enumerateDirectSupertypes(type)) {
20622062
// If we're not allowed to try this binding, skip it.
2063-
if (auto simplifiedSuper = checkTypeOfBinding(TypeVar, supertype))
2064-
addNewBinding(binding.withType(*simplifiedSuper));
2063+
if (auto simplifiedSuper = checkTypeOfBinding(TypeVar, supertype)) {
2064+
auto supertype = *simplifiedSuper;
2065+
// A key path type cannot be bound to type-erased key path variants.
2066+
if (TypeVar->getImpl().isKeyPathType() &&
2067+
(supertype->isPartialKeyPath() || supertype->isAnyKeyPath()))
2068+
continue;
2069+
2070+
addNewBinding(binding.withType(supertype));
2071+
}
20652072
}
20662073
}
20672074
}

0 commit comments

Comments
 (0)