[Refactoring] SyntacticRename should walk into ObjC Keypath components when matching name locations.

It wasn't previously so missed them.

Resolves rdar://61573935
This commit is contained in:
Nathan Hawes
2021-03-12 15:13:28 +10:00
parent eeab067a45
commit 07ebaccfd3
10 changed files with 281 additions and 0 deletions

View File

@@ -424,6 +424,36 @@ std::pair<bool, Expr*> NameMatcher::walkToExprPre(Expr *E) {
return {false, nullptr};
return {false, E};
}
case ExprKind::KeyPath: {
KeyPathExpr *KP = cast<KeyPathExpr>(E);
// Swift keypath components are visited already, so there's no need to
// handle them specially.
if (!KP->isObjC())
break;
for (auto Component: KP->getComponents()) {
switch (Component.getKind()) {
case KeyPathExpr::Component::Kind::UnresolvedProperty:
case KeyPathExpr::Component::Kind::Property:
tryResolve(ASTWalker::ParentTy(E), Component.getLoc());
break;
case KeyPathExpr::Component::Kind::DictionaryKey:
case KeyPathExpr::Component::Kind::Invalid:
break;
case KeyPathExpr::Component::Kind::OptionalForce:
case KeyPathExpr::Component::Kind::OptionalChain:
case KeyPathExpr::Component::Kind::OptionalWrap:
case KeyPathExpr::Component::Kind::UnresolvedSubscript:
case KeyPathExpr::Component::Kind::Subscript:
case KeyPathExpr::Component::Kind::Identity:
case KeyPathExpr::Component::Kind::TupleElement:
llvm_unreachable("Unexpected component in ObjC KeyPath expression");
break;
}
}
break;
}
default: // ignored
break;
}