Skip to content

Commit

Permalink
Build NullAway with JSpecify mode enabled
Browse files Browse the repository at this point in the history
  • Loading branch information
msridhar committed Oct 6, 2023
1 parent 613f98c commit ca23496
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 2 deletions.
1 change: 1 addition & 0 deletions nullaway/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -168,6 +168,7 @@ tasks.register('buildWithNullAway', JavaCompile) {
option("NullAway:CheckOptionalEmptiness")
option("NullAway:AcknowledgeRestrictiveAnnotations")
option("NullAway:CheckContracts")
option("NullAway:JSpecifyMode")
}
// Make sure the jar has already been built
dependsOn 'jar'
Expand Down
6 changes: 4 additions & 2 deletions nullaway/src/main/java/com/uber/nullaway/GenericsChecks.java
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@
import java.util.List;
import java.util.Map;
import javax.annotation.Nullable;
import javax.lang.model.type.ExecutableType;

/** Methods for performing checks related to generic types and nullability. */
public final class GenericsChecks {
Expand Down Expand Up @@ -737,8 +738,9 @@ private static Type getTypeForSymbol(Symbol symbol, VisitorState state) {
private static Nullness getGenericMethodReturnTypeNullness(
Symbol.MethodSymbol method, Type enclosingType, VisitorState state, Config config) {
Type overriddenMethodType = state.getTypes().memberType(enclosingType, method);
if (!(overriddenMethodType instanceof Type.MethodType)) {
throw new RuntimeException("expected method type but instead got " + overriddenMethodType);
if (!(overriddenMethodType instanceof ExecutableType)) {
throw new RuntimeException(
"expected ExecutableType but instead got " + overriddenMethodType.getClass());

Check warning on line 743 in nullaway/src/main/java/com/uber/nullaway/GenericsChecks.java

View check run for this annotation

Codecov / codecov/patch

nullaway/src/main/java/com/uber/nullaway/GenericsChecks.java#L742-L743

Added lines #L742 - L743 were not covered by tests
}
return getTypeNullness(overriddenMethodType.getReturnType(), config);
}
Expand Down

0 comments on commit ca23496

Please sign in to comment.