Skip to content

Commit

Permalink
rewriting the ternary operator as if-else and adding comments for bet…
Browse files Browse the repository at this point in the history
…ter documentation
  • Loading branch information
akulk022 committed Oct 17, 2023
1 parent 8c2f589 commit d92b71b
Showing 1 changed file with 12 additions and 8 deletions.
20 changes: 12 additions & 8 deletions nullaway/src/main/java/com/uber/nullaway/NullAway.java
Original file line number Diff line number Diff line change
Expand Up @@ -996,14 +996,18 @@ private boolean overriddenMethodReturnsNonNull(
// In JSpecify mode, for generic methods, we additionally need to check the return nullness
// using the type parameters from the type enclosing the overriding method
if (config.isJSpecifyMode()) {

return (memberReferenceTree != null)
? GenericsChecks.getGenericMethodReturnTypeNullness(
overriddenMethod, ASTHelpers.getType(memberReferenceTree), state, config)
.equals(Nullness.NONNULL)
: GenericsChecks.getGenericMethodReturnTypeNullness(
overriddenMethod, enclosingSymbol, state, config)
.equals(Nullness.NONNULL);
if (memberReferenceTree != null) {
// For a method reference, we get generic type arguments from javac's inferred type for the
// tree which properly preserves type-use annotations
return GenericsChecks.getGenericMethodReturnTypeNullness(
overriddenMethod, ASTHelpers.getType(memberReferenceTree), state, config)
.equals(Nullness.NONNULL);
} else {
// Using the enclosing class of the overriding method to find generic type arguments
return GenericsChecks.getGenericMethodReturnTypeNullness(
overriddenMethod, enclosingSymbol, state, config)
.equals(Nullness.NONNULL);
}
}
return true;
}
Expand Down

0 comments on commit d92b71b

Please sign in to comment.