diff --git a/nullaway/build.gradle b/nullaway/build.gradle index 019cb8b5ff..83f7e62e21 100644 --- a/nullaway/build.gradle +++ b/nullaway/build.gradle @@ -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' diff --git a/nullaway/src/main/java/com/uber/nullaway/GenericsChecks.java b/nullaway/src/main/java/com/uber/nullaway/GenericsChecks.java index 0d814a7bc1..a5ca2b197d 100644 --- a/nullaway/src/main/java/com/uber/nullaway/GenericsChecks.java +++ b/nullaway/src/main/java/com/uber/nullaway/GenericsChecks.java @@ -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 { @@ -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()); } return getTypeNullness(overriddenMethodType.getReturnType(), config); }