Skip to content

Commit

Permalink
Revert "refactor simple onOverrideMayBeNullExpr handlers (uber#747)"
Browse files Browse the repository at this point in the history
This reverts commit 7714c45.
  • Loading branch information
msridhar committed Jul 19, 2023
1 parent 382452b commit 2420b80
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 20 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -196,15 +196,11 @@ public boolean onOverrideMayBeNullExpr(
@Nullable Symbol exprSymbol,
VisitorState state,
boolean exprMayBeNull) {
if (exprMayBeNull) {
return true;
if (expr.getKind().equals(Tree.Kind.METHOD_INVOCATION)
&& exprSymbol instanceof Symbol.MethodSymbol) {
return exprMayBeNull || isReturnAnnotatedNullable((Symbol.MethodSymbol) exprSymbol);
}
if (expr.getKind() == Tree.Kind.METHOD_INVOCATION
&& exprSymbol instanceof Symbol.MethodSymbol
&& isReturnAnnotatedNullable((Symbol.MethodSymbol) exprSymbol)) {
return true;
}
return false;
return exprMayBeNull;
}

private boolean isReturnAnnotatedNullable(Symbol.MethodSymbol methodSymbol) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -87,15 +87,12 @@ public boolean onOverrideMayBeNullExpr(
@Nullable Symbol exprSymbol,
VisitorState state,
boolean exprMayBeNull) {
if (exprMayBeNull) {
return true;
}
if (expr.getKind() == Tree.Kind.METHOD_INVOCATION
if (expr.getKind().equals(Tree.Kind.METHOD_INVOCATION)
&& exprSymbol instanceof Symbol.MethodSymbol
&& optionalIsGetCall((Symbol.MethodSymbol) exprSymbol, state.getTypes())) {
return true;
}
return false;
return exprMayBeNull;
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -76,16 +76,13 @@ public boolean onOverrideMayBeNullExpr(
@Nullable Symbol exprSymbol,
VisitorState state,
boolean exprMayBeNull) {
if (exprMayBeNull) {
return true;
}
Tree.Kind exprKind = expr.getKind();
if (exprSymbol != null
&& (exprKind == Tree.Kind.METHOD_INVOCATION || exprKind == Tree.Kind.IDENTIFIER)
&& isSymbolRestrictivelyNullable(exprSymbol, state.context)) {
return true;
&& (exprKind.equals(Tree.Kind.METHOD_INVOCATION)
|| exprKind.equals(Tree.Kind.IDENTIFIER))) {
return exprMayBeNull || isSymbolRestrictivelyNullable(exprSymbol, state.context);
}
return false;
return exprMayBeNull;
}

@Nullable private CodeAnnotationInfo codeAnnotationInfo;
Expand Down

0 comments on commit 2420b80

Please sign in to comment.