Skip to content

Commit

Permalink
Fix nullaway issues in nullaway
Browse files Browse the repository at this point in the history
  • Loading branch information
mauricioaniche committed Sep 29, 2024
1 parent 2623bfa commit 1b1967c
Showing 1 changed file with 7 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -170,7 +170,8 @@ public void onDataflowVisitReturn(

// Get the declared configuration of the EnsureNonNullIf method under analysis
Symbol.MethodSymbol methodSymbolUnderAnalysis =
methodAnalysisContextUnderAnalysis.methodSymbol();
NullabilityUtil.castToNonNull(methodAnalysisContextUnderAnalysis).methodSymbol();

Set<String> fieldNames = getAnnotationValueArray(methodSymbolUnderAnalysis, annotName, false);
if (fieldNames == null) {
throw new RuntimeException("List of field names shouldn't be null");

Check warning on line 177 in nullaway/src/main/java/com/uber/nullaway/handlers/contract/fieldcontract/EnsuresNonNullIfHandler.java

View check run for this annotation

Codecov / codecov/patch

nullaway/src/main/java/com/uber/nullaway/handlers/contract/fieldcontract/EnsuresNonNullIfHandler.java#L177

Added line #L177 was not covered by tests
Expand All @@ -197,8 +198,8 @@ public void onDataflowVisitReturn(
}

boolean evaluatesToLiteral = expressionAsBoolean.isPresent();
boolean evaluatesToFalse = evaluatesToLiteral && !expressionAsBoolean.get();
boolean evaluatesToTrue = evaluatesToLiteral && expressionAsBoolean.get();
boolean evaluatesToFalse = expressionAsBoolean.isPresent() && !expressionAsBoolean.get();
boolean evaluatesToTrue = expressionAsBoolean.isPresent() && expressionAsBoolean.get();

/*
* Decide whether the semantics of this ReturnTree are correct.
Expand Down Expand Up @@ -243,7 +244,9 @@ public void onDataflowVisitReturn(
}

private void raiseError(Tree returnTree, VisitorState state, String message) {
NullAway analysis = methodAnalysisContextUnderAnalysis.analysis();
NullAway analysis =
NullabilityUtil.castToNonNull(methodAnalysisContextUnderAnalysis).analysis();

state.reportMatch(
analysis
.getErrorBuilder()
Expand Down

0 comments on commit 1b1967c

Please sign in to comment.