Skip to content

Commit

Permalink
Build NullAway with JSpecify mode enabled (#841)
Browse files Browse the repository at this point in the history
This will give us a bit better test coverage as we continue to implement
JSpecify. With one small fix to an assertion check, now NullAway can
build itself in JSpecify mode without crashing!
  • Loading branch information
msridhar authored Oct 6, 2023
1 parent 613f98c commit 790a9ec
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 3 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
8 changes: 5 additions & 3 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,9 +738,10 @@ 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);
}
verify(
overriddenMethodType instanceof ExecutableType,
"expected ExecutableType but instead got %s",
overriddenMethodType.getClass());
return getTypeNullness(overriddenMethodType.getReturnType(), config);
}

Expand Down

0 comments on commit 790a9ec

Please sign in to comment.