Skip to content

Commit 52cadcd

Browse files
graememorganError Prone Team
authored andcommitted
Document that IdentifierTrees may have null symbols in some cases to save the next person some time.
PiperOrigin-RevId: 735397059
1 parent ca5f827 commit 52cadcd

1 file changed

Lines changed: 2 additions & 0 deletions

File tree

check_api/src/main/java/com/google/errorprone/util/ASTHelpers.java

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -259,6 +259,8 @@ public static boolean sameVariable(ExpressionTree expr1, ExpressionTree expr2) {
259259
return jcFieldAccess.sym;
260260
}
261261
if (tree instanceof JCIdent jcIdent) {
262+
// You might reasonably expect that IdentifierTrees always have a non-null symbol, but a few
263+
// cases don't, including module names and identifiers resolved from Javadoc (sometimes).
262264
return jcIdent.sym;
263265
}
264266
if (tree instanceof JCMethodInvocation jcMethodInvocation) {

0 commit comments

Comments
 (0)