Skip to content

Commit 15098e2

Browse files
committed
[AST] Rename resolveComponents -> setComponents
The naming here has bothered me for a little while now, it just sets the components, it doesn't resolve anything.
1 parent ac56bfb commit 15098e2

File tree

5 files changed

+15
-16
lines changed

5 files changed

+15
-16
lines changed

include/swift/AST/Expr.h

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5592,10 +5592,9 @@ class KeyPathExpr : public Expr {
55925592
return Components;
55935593
}
55945594

5595-
/// Resolve the components of an un-type-checked expr. This copies over the
5596-
/// components from the argument array.
5597-
void resolveComponents(ASTContext &C,
5598-
ArrayRef<Component> resolvedComponents);
5595+
/// Set the key path components. This copies over the components from the
5596+
/// argument array.
5597+
void setComponents(ASTContext &C, ArrayRef<Component> newComponents);
55995598

56005599
/// Indicates if the key path expression is composed by a single invalid
56015600
/// component. e.g. missing component `\Root`

lib/AST/Expr.cpp

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -2001,20 +2001,20 @@ KeyPathExpr::KeyPathExpr(ASTContext &C, SourceLoc keywordLoc,
20012001
}
20022002

20032003
void
2004-
KeyPathExpr::resolveComponents(ASTContext &C,
2005-
ArrayRef<KeyPathExpr::Component> resolvedComponents) {
2004+
KeyPathExpr::setComponents(ASTContext &C,
2005+
ArrayRef<KeyPathExpr::Component> newComponents) {
20062006
// Reallocate the components array if it needs to be.
2007-
if (Components.size() < resolvedComponents.size()) {
2008-
Components = C.Allocate<Component>(resolvedComponents.size());
2007+
if (Components.size() < newComponents.size()) {
2008+
Components = C.Allocate<Component>(newComponents.size());
20092009
for (unsigned i : indices(Components)) {
20102010
::new ((void*)&Components[i]) Component{};
20112011
}
20122012
}
20132013

2014-
for (unsigned i : indices(resolvedComponents)) {
2015-
Components[i] = resolvedComponents[i];
2014+
for (unsigned i : indices(newComponents)) {
2015+
Components[i] = newComponents[i];
20162016
}
2017-
Components = Components.slice(0, resolvedComponents.size());
2017+
Components = Components.slice(0, newComponents.size());
20182018
}
20192019

20202020
Optional<unsigned> KeyPathExpr::findComponentWithSubscriptArg(Expr *arg) {

lib/Sema/CSApply.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2247,7 +2247,7 @@ namespace {
22472247
case OverloadChoiceKind::KeyPathDynamicMemberLookup: {
22482248
buildKeyPathSubscriptComponent(overload, dotLoc, /*args=*/nullptr,
22492249
componentLoc, components);
2250-
keyPath->resolveComponents(ctx, components);
2250+
keyPath->setComponents(ctx, components);
22512251
cs.cacheExprTypes(keyPath);
22522252
return keyPath;
22532253
}
@@ -2328,7 +2328,7 @@ namespace {
23282328
cs.cacheType(componentExpr);
23292329

23302330
keyPath->setParsedPath(componentExpr);
2331-
keyPath->resolveComponents(ctx, components);
2331+
keyPath->setComponents(ctx, components);
23322332
cs.cacheExprTypes(keyPath);
23332333

23342334
// See whether there's an equivalent ObjC key path string we can produce
@@ -4894,7 +4894,7 @@ namespace {
48944894
}
48954895

48964896
// Set the resolved components, and cache their types.
4897-
E->resolveComponents(cs.getASTContext(), resolvedComponents);
4897+
E->setComponents(cs.getASTContext(), resolvedComponents);
48984898
cs.cacheExprTypes(E);
48994899

49004900
// See whether there's an equivalent ObjC key path string we can produce

lib/Sema/PreCheckExpr.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2008,7 +2008,7 @@ void PreCheckExpression::resolveKeyPathExpr(KeyPathExpr *KPE) {
20082008
std::reverse(components.begin(), components.end());
20092009

20102010
KPE->setRootType(rootType);
2011-
KPE->resolveComponents(getASTContext(), components);
2011+
KPE->setComponents(getASTContext(), components);
20122012
}
20132013

20142014
Expr *PreCheckExpression::simplifyTypeConstructionWithLiteralArg(Expr *E) {

lib/Sema/TypeCheckExprObjC.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -419,7 +419,7 @@ Optional<Type> TypeChecker::checkObjCKeyPathExpr(DeclContext *dc,
419419
// A successful check of an ObjC keypath shouldn't add or remove components,
420420
// currently.
421421
if (resolvedComponents.size() == expr->getComponents().size())
422-
expr->resolveComponents(Context, resolvedComponents);
422+
expr->setComponents(Context, resolvedComponents);
423423

424424
// Check for an empty key-path string.
425425
auto keyPathString = keyPathOS.str();

0 commit comments

Comments
 (0)