Skip to content

Commit 35e02f0

Browse files
author
Amritpan Kaur
committed
[CSBindings] Prevent supertype bindings if type var is a key path type
1 parent fc8da01 commit 35e02f0

File tree

1 file changed

+8
-4
lines changed

1 file changed

+8
-4
lines changed

lib/Sema/CSBindings.cpp

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2044,10 +2044,14 @@ bool TypeVarBindingProducer::computeNext() {
20442044
addNewBinding(binding.withSameSource(voidType, BindingKind::Exact));
20452045
}
20462046

2047-
for (auto supertype : enumerateDirectSupertypes(type)) {
2048-
// If we're not allowed to try this binding, skip it.
2049-
if (auto simplifiedSuper = checkTypeOfBinding(TypeVar, supertype))
2050-
addNewBinding(binding.withType(*simplifiedSuper));
2047+
// If the type variable is not a key path type, attempt to bind
2048+
// supertypes.
2049+
if (!TypeVar->getImpl().isKeyPathType()) {
2050+
for (auto supertype : enumerateDirectSupertypes(type)) {
2051+
// If we're not allowed to try this binding, skip it.
2052+
if (auto simplifiedSuper = checkTypeOfBinding(TypeVar, supertype))
2053+
addNewBinding(binding.withType(*simplifiedSuper));
2054+
}
20512055
}
20522056
}
20532057
}

0 commit comments

Comments
 (0)