Skip to content

Commit

Permalink
refactor to directly return mayBeNullFieldAccess
Browse files Browse the repository at this point in the history
the method already calls `onOverrideMayBeNullExpr` and `nullnessFromDataflow`
so there is no point to break out of the switch to call the former
again

see also other usage of `mayBeNullFieldAccess` a few lines below

also remove comments that just restated the obvious
  • Loading branch information
XN137 committed Apr 1, 2023
1 parent e4dfeac commit f8143b3
Showing 1 changed file with 2 additions and 6 deletions.
8 changes: 2 additions & 6 deletions nullaway/src/main/java/com/uber/nullaway/NullAway.java
Original file line number Diff line number Diff line change
Expand Up @@ -2265,19 +2265,15 @@ private boolean mayBeNullExpr(VisitorState state, ExpressionTree expr) {
throw new IllegalStateException(
"unexpected null symbol for dereference expression " + state.getSourceForNode(expr));
}
exprMayBeNull = mayBeNullFieldAccess(state, expr, exprSymbol);
break;
return mayBeNullFieldAccess(state, expr, exprSymbol);
case IDENTIFIER:
if (exprSymbol == null) {
throw new IllegalStateException(
"unexpected null symbol for identifier " + state.getSourceForNode(expr));
}
if (exprSymbol.getKind().equals(ElementKind.FIELD)) {
// Special case: mayBeNullFieldAccess runs handler.onOverrideMayBeNullExpr before
// dataflow.
if (exprSymbol.getKind() == ElementKind.FIELD) {
return mayBeNullFieldAccess(state, expr, exprSymbol);
} else {
// Check handler.onOverrideMayBeNullExpr before dataflow.
exprMayBeNull = handler.onOverrideMayBeNullExpr(this, expr, exprSymbol, state, true);
return exprMayBeNull ? nullnessFromDataflow(state, expr) : false;
}
Expand Down

0 comments on commit f8143b3

Please sign in to comment.