Skip to content

Commit 89276c0

Browse files
committed
[CS] Tighten up check for unresolved member chain
With the removal of TupleExpr and ParenExpr argument lists, it's no longer sufficient to check whether a given parent expr has a possible chain sub-expr, as it might be a child that's unrelated to the chain under consideration. For example, for a chain that's an argument to a function call, we don't want to walk up and consider the call expr to be an extension of the chain just because it has a function expr. Tighten up the check by comparing whether the given sub-expr of a possible chain parent matches the current expr in the chain.
1 parent a577548 commit 89276c0

File tree

1 file changed

+1
-5
lines changed

1 file changed

+1
-5
lines changed

lib/Sema/PreCheckExpr.cpp

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -340,16 +340,12 @@ UnresolvedMemberExpr *TypeChecker::getUnresolvedMemberChainBase(Expr *expr) {
340340
return dyn_cast<UnresolvedMemberExpr>(expr);
341341
}
342342

343-
/// Whether this expression is a member of a member chain.
344-
static bool isMemberChainMember(Expr *expr) {
345-
return getMemberChainSubExpr(expr) != nullptr;
346-
}
347343
/// Whether this expression sits at the end of a chain of member accesses.
348344
static bool isMemberChainTail(Expr *expr, Expr *parent) {
349345
assert(expr && "isMemberChainTail called with null expr!");
350346
// If this expression's parent is not itself part of a chain (or, this expr
351347
// has no parent expr), this must be the tail of the chain.
352-
return parent == nullptr || !isMemberChainMember(parent);
348+
return !parent || getMemberChainSubExpr(parent) != expr;
353349
}
354350

355351
static bool isValidForwardReference(ValueDecl *D, DeclContext *DC,

0 commit comments

Comments
 (0)