Skip to content

Commit

Permalink
fix NullAway warnings
Browse files Browse the repository at this point in the history
  • Loading branch information
msridhar committed Aug 4, 2023
1 parent 95df551 commit 6cc3e83
Showing 1 changed file with 6 additions and 3 deletions.
9 changes: 6 additions & 3 deletions nullaway/src/main/java/com/uber/nullaway/ErrorBuilder.java
Original file line number Diff line number Diff line change
Expand Up @@ -203,8 +203,10 @@ private Description.Builder addSuggestedSuppression(
if (config.getCastToNonNullMethod() != null && canBeCastToNonNull(suggestTree)) {
builder = addCastToNonNullFix(suggestTree, builder);
} else {
builder =
addSuppressWarningsFix(suppressibleNode(state.getPath()), builder, suppressionName);
Tree suppressibleNode = suppressibleNode(state.getPath());
if (suppressibleNode != null) {
builder = addSuppressWarningsFix(suppressibleNode, builder, suppressionName);
}
}
break;
case CAST_TO_NONNULL_ARG_NONNULL:
Expand Down Expand Up @@ -343,7 +345,8 @@ private boolean canBeCastToNonNull(Tree tree) {
// make the parameter @NonNull and add casts at call sites, but that is beyond the scope of
// our suggested fixes
Symbol symbol = ASTHelpers.getSymbol(tree);
return !(symbol.getKind().equals(ElementKind.PARAMETER)
return !(symbol != null
&& symbol.getKind().equals(ElementKind.PARAMETER)
&& hasNullableAnnotation(symbol, config));
default:
return true;
Expand Down

0 comments on commit 6cc3e83

Please sign in to comment.