Skip to content

Commit ba7524d

Browse files
[Sema] Do not record hole root fix for keypath with invalid component
1 parent fe3216a commit ba7524d

File tree

1 file changed

+9
-0
lines changed

1 file changed

+9
-0
lines changed

lib/Sema/CSBindings.cpp

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1851,6 +1851,15 @@ TypeVariableBinding::fixForHole(ConstraintSystem &cs) const {
18511851
if (cs.hasFixFor(kpLocator, FixKind::AllowKeyPathWithoutComponents))
18521852
return None;
18531853

1854+
// If key path has any invalid component, let's just skip fix because the
1855+
// invalid component would be already diagnosed.
1856+
auto keyPath = castToExpr<KeyPathExpr>(srcLocator->getAnchor());
1857+
if (llvm::any_of(keyPath->getComponents(),
1858+
[](KeyPathExpr::Component component) {
1859+
return !component.isValid();
1860+
}))
1861+
return None;
1862+
18541863
ConstraintFix *fix = SpecifyKeyPathRootType::create(cs, dstLocator);
18551864
return std::make_pair(fix, defaultImpact);
18561865
}

0 commit comments

Comments
 (0)