Skip to content

Commit a7c0460

Browse files
committed
[CS] Record IgnoreInvalidASTNode for invalid key path component
And ensure we don't end up with invalid key paths in CSApply.
1 parent cdf0bfb commit a7c0460

File tree

2 files changed

+7
-7
lines changed

2 files changed

+7
-7
lines changed

lib/Sema/CSApply.cpp

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -5395,19 +5395,18 @@ namespace {
53955395
}
53965396
break;
53975397
}
5398-
case KeyPathExpr::Component::Kind::Invalid:
5399-
case KeyPathExpr::Component::Kind::CodeCompletion: {
5400-
auto component = origComponent;
5401-
component.setComponentType(leafTy);
5402-
resolvedComponents.push_back(component);
5403-
break;
5404-
}
54055398
case KeyPathExpr::Component::Kind::Identity: {
54065399
auto component = origComponent;
54075400
component.setComponentType(componentTy);
54085401
resolvedComponents.push_back(component);
54095402
break;
54105403
}
5404+
case KeyPathExpr::Component::Kind::CodeCompletion:
5405+
llvm_unreachable("solver-based completion shouldn't do CSApply");
5406+
break;
5407+
case KeyPathExpr::Component::Kind::Invalid:
5408+
llvm_unreachable("should have been diagnosed");
5409+
break;
54115410
case KeyPathExpr::Component::Kind::Member:
54125411
case KeyPathExpr::Component::Kind::Subscript:
54135412
case KeyPathExpr::Component::Kind::Apply:

lib/Sema/CSGen.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3845,6 +3845,7 @@ namespace {
38453845

38463846
switch (auto kind = component.getKind()) {
38473847
case KeyPathExpr::Component::Kind::Invalid:
3848+
CS.recordFix(IgnoreInvalidASTNode::create(CS, memberLocator));
38483849
break;
38493850
case KeyPathExpr::Component::Kind::CodeCompletion:
38503851
// We don't know what the code completion might resolve to, so we are

0 commit comments

Comments
 (0)