Skip to content

Commit 3140c12

Browse files
author
Amritpan Kaur
committed
[CSSimplify] If keypath is malformed, do not attempt to
1 parent 6296be7 commit 3140c12

File tree

1 file changed

+6
-3
lines changed

1 file changed

+6
-3
lines changed

lib/Sema/CSSimplify.cpp

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -11550,14 +11550,17 @@ bool ConstraintSystem::resolveClosure(TypeVariableType *typeVar,
1155011550
bool ConstraintSystem::resolveKeyPath(TypeVariableType *typeVar,
1155111551
Type contextualType,
1155211552
ConstraintLocatorBuilder locator) {
11553-
11553+
auto *keyPathLocator = typeVar->getImpl().getLocator();
11554+
auto *keyPath = castToExpr<KeyPathExpr>(keyPathLocator->getAnchor());
11555+
if (keyPath->hasSingleInvalidComponent()) {
11556+
assignFixedType(typeVar, contextualType);
11557+
return true;
11558+
}
1155411559
if (auto *BGT = contextualType->getAs<BoundGenericType>()) {
1155511560
auto args = BGT->getGenericArgs();
1155611561
if (isKnownKeyPathType(contextualType) && args.size() >= 1) {
1155711562
auto root = BGT->getGenericArgs()[0];
1155811563

11559-
auto *keyPathLocator = typeVar->getImpl().getLocator();
11560-
auto *keyPath = castToExpr<KeyPathExpr>(keyPathLocator->getAnchor());
1156111564
auto *keyPathValueTV = getKeyPathValueType(keyPath);
1156211565
contextualType = BoundGenericType::get(
1156311566
args.size() == 1 ? getASTContext().getKeyPathDecl() : BGT->getDecl(),

0 commit comments

Comments
 (0)