diff --git a/nullaway/src/main/java/com/uber/nullaway/generics/CheckIdenticalNullabilityVisitor.java b/nullaway/src/main/java/com/uber/nullaway/generics/CheckIdenticalNullabilityVisitor.java index dda48e44ca..94db423663 100644 --- a/nullaway/src/main/java/com/uber/nullaway/generics/CheckIdenticalNullabilityVisitor.java +++ b/nullaway/src/main/java/com/uber/nullaway/generics/CheckIdenticalNullabilityVisitor.java @@ -5,6 +5,7 @@ import com.sun.tools.javac.code.Types; import java.util.List; import javax.lang.model.type.NullType; +import javax.lang.model.type.TypeKind; /** * Visitor that checks for identical nullability annotations at all nesting levels within two types. @@ -23,6 +24,10 @@ public Boolean visitClassType(Type.ClassType lhsType, Type rhsType) { if (rhsType instanceof NullType || rhsType.isPrimitive()) { return true; } + if (rhsType.getKind().equals(TypeKind.WILDCARD)) { + // TODO Handle wildcard types + return true; + } Types types = state.getTypes(); // The base type of rhsType may be a subtype of lhsType's base type. In such cases, we must // compare lhsType against the supertype of rhsType with a matching base type. diff --git a/nullaway/src/test/java/com/uber/nullaway/jspecify/GenericsTests.java b/nullaway/src/test/java/com/uber/nullaway/jspecify/GenericsTests.java index 2a662b55a5..6db6675078 100644 --- a/nullaway/src/test/java/com/uber/nullaway/jspecify/GenericsTests.java +++ b/nullaway/src/test/java/com/uber/nullaway/jspecify/GenericsTests.java @@ -1856,6 +1856,28 @@ public void issue1008() { .doTest(); } + @Test + public void issue1014() { + makeHelper() + .addSourceLines( + "Test.java", + "package com.uber;", + "import org.jspecify.annotations.Nullable;", + "import java.util.function.Function;", + "class Test {", + " public interface PropertyFunction<", + " T extends @Nullable Object, R extends @Nullable Object, E extends Exception>", + " extends Function {", + " R _apply(T t) throws E;", + " }", + " @Nullable PropertyFunction stringFunc;", + " public void propertyString() {", + " var f = stringFunc;", + " }", + "}") + .doTest(); + } + private CompilationTestHelper makeHelper() { return makeTestHelperWithArgs( Arrays.asList(