Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 3 additions & 7 deletions nullaway/src/main/java/com/uber/nullaway/NullAway.java
Original file line number Diff line number Diff line change
Expand Up @@ -2700,16 +2700,12 @@ private boolean mayBeNullExpr(VisitorState state, ExpressionTree expr) {
break;
case CONDITIONAL_EXPRESSION:
case ASSIGNMENT:
case SWITCH_EXPRESSION:
exprMayBeNull = true;
break;
default:
// match switch expressions by comparing strings, so the code compiles on JDK versions < 12
if (expr.getKind().name().equals("SWITCH_EXPRESSION")) {
exprMayBeNull = true;
} else {
throw new RuntimeException(
"whoops, better handle " + expr.getKind() + " " + state.getSourceForNode(expr));
}
throw new RuntimeException(
"whoops, better handle " + expr.getKind() + " " + state.getSourceForNode(expr));
}
exprMayBeNull = handler.onOverrideMayBeNullExpr(this, expr, exprSymbol, state, exprMayBeNull);
return exprMayBeNull && nullnessFromDataflow(state, expr);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1051,21 +1051,17 @@ private static boolean shouldRunDataflowForExpression(Type exprType, ExpressionT
return false;
}
expr = NullabilityUtil.stripParensAndCasts(expr);
switch (expr.getKind()) {
case ARRAY_ACCESS:
case MEMBER_SELECT:
case METHOD_INVOCATION:
case IDENTIFIER:
case ASSIGNMENT:
case CONDITIONAL_EXPRESSION:
return true;
default:
// match switch expressions by comparing strings, so the code compiles on JDK versions < 12
if (expr.getKind().name().equals("SWITCH_EXPRESSION")) {
return true;
}
return false;
}
return switch (expr.getKind()) {
case ARRAY_ACCESS,
MEMBER_SELECT,
METHOD_INVOCATION,
IDENTIFIER,
ASSIGNMENT,
CONDITIONAL_EXPRESSION,
SWITCH_EXPRESSION ->
true;
default -> false;
};
}

private Type updateTypeWithNullness(
Expand Down