File tree Expand file tree Collapse file tree 1 file changed +9
-6
lines changed Expand file tree Collapse file tree 1 file changed +9
-6
lines changed Original file line number Diff line number Diff line change @@ -1303,25 +1303,28 @@ void KeyPathTypeCheckCompletionCallback::sawSolution(
1303
1303
// to look up type variables by their locators.
1304
1304
auto RootLocator =
1305
1305
S.getConstraintLocator (KeyPath, {ConstraintLocator::KeyPathRoot});
1306
- auto BaseVariableType =
1306
+ auto BaseVariableTypeBinding =
1307
1307
llvm::find_if (S.typeBindings , [&RootLocator](const auto &Entry) {
1308
1308
return Entry.first ->getImpl ().getLocator () == RootLocator;
1309
- })->getSecond ();
1310
- BaseType = S.simplifyType (BaseVariableType);
1309
+ });
1310
+ if (BaseVariableTypeBinding != S.typeBindings .end ()) {
1311
+ BaseType = S.simplifyType (BaseVariableTypeBinding->getSecond ());
1312
+ }
1311
1313
}
1312
1314
} else {
1313
1315
// We are completing after a component. Get the previous component's result
1314
1316
// type.
1315
1317
BaseType = S.simplifyType (S.getType (KeyPath, ComponentIndex - 1 ));
1316
1318
}
1319
+ if (BaseType.isNull ()) {
1320
+ return ;
1321
+ }
1317
1322
1318
1323
// If ExpectedTy is a duplicate of any other result, ignore this solution.
1319
1324
if (llvm::any_of (Results, [&](const Result &R) {
1320
1325
return R.BaseType ->isEqual (BaseType);
1321
1326
})) {
1322
1327
return ;
1323
1328
}
1324
- if (BaseType) {
1325
- Results.push_back ({BaseType, /* OnRoot=*/ (ComponentIndex == 0 )});
1326
- }
1329
+ Results.push_back ({BaseType, /* OnRoot=*/ (ComponentIndex == 0 )});
1327
1330
}
You can’t perform that action at this time.
0 commit comments