Skip to content

Commit

Permalink
Make ASTHelpers.getSymbol(Tree) delegate to the `MemberReferenceTre…
Browse files Browse the repository at this point in the history
…e` overload.

This may or may not actually change behavior: The handling that I added in e5a6d0d was definitely important for `MethodInvocationTree`, since it affects behavior when code uses static imports. However, static imports can't be used with a `MemberReferenceTree`, so the change might not be important there. Still, as I noted in that previous CL's description, I get the impression that this might also help with cases like `someSerializable.equals`—and presumably `someSerializable::equals`, too.

Anyway, this change seems clearly like either an improvement in behavior or a no-op that makes the implementation more consistent, so either way feels like a win.

PiperOrigin-RevId: 656731744
  • Loading branch information
cpovirk authored and Error Prone Team committed Jul 27, 2024
1 parent 40f5b21 commit 9884911
Showing 1 changed file with 3 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -260,14 +260,13 @@ public static boolean sameVariable(ExpressionTree expr1, ExpressionTree expr2) {
return ((JCIdent) tree).sym;
}
if (tree instanceof JCMethodInvocation) {
return ASTHelpers.getSymbol((MethodInvocationTree) tree);
return getSymbol((MethodInvocationTree) tree);
}
if (tree instanceof JCNewClass) {
return ASTHelpers.getSymbol((NewClassTree) tree);
return getSymbol((NewClassTree) tree);
}
if (tree instanceof MemberReferenceTree) {
// TODO: b/285157761 - Delegate to the MemberReferenceTree overload.
return ((JCMemberReference) tree).sym;
return getSymbol((MemberReferenceTree) tree);
}
if (tree instanceof JCAnnotatedType) {
return getSymbol(((JCAnnotatedType) tree).underlyingType);
Expand Down

0 comments on commit 9884911

Please sign in to comment.