Skip to content

Commit b37f5f9

Browse files
authored
Add test for #1011 (#1018)
We can enable the test on appropriate JDK versions once openjdk/jdk#20460 lands. #1011
1 parent e6839dd commit b37f5f9

File tree

2 files changed

+29
-0
lines changed

2 files changed

+29
-0
lines changed

nullaway/src/test/java/com/uber/nullaway/jspecify/BytecodeGenericsTests.java

+20
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
import com.google.errorprone.CompilationTestHelper;
44
import com.uber.nullaway.NullAwayTestsBase;
55
import java.util.Arrays;
6+
import org.junit.Ignore;
67
import org.junit.Test;
78

89
public class BytecodeGenericsTests extends NullAwayTestsBase {
@@ -222,6 +223,25 @@ public void overrideReturnTypes() {
222223
.doTest();
223224
}
224225

226+
@Test
227+
@Ignore("Failing due to https://bugs.openjdk.org/browse/JDK-8337795")
228+
// TODO Re-enable this test once the JDK bug is fixed, on appropriate JDK versions
229+
// See https://github.com/uber/NullAway/issues/1011
230+
public void callMethodTakingJavaUtilFunction() {
231+
makeHelper()
232+
.addSourceLines(
233+
"Test.java",
234+
"package com.uber;",
235+
"import org.jspecify.annotations.Nullable;",
236+
"import com.uber.lib.generics.JavaUtilFunctionMethods;",
237+
"class Test {",
238+
" static void testNegative() {",
239+
" JavaUtilFunctionMethods.withFunction(s -> { return null; });",
240+
" }",
241+
"}")
242+
.doTest();
243+
}
244+
225245
private CompilationTestHelper makeHelper() {
226246
return makeTestHelperWithArgs(
227247
Arrays.asList(
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
package com.uber.lib.generics;
2+
3+
import java.util.function.Function;
4+
import org.jspecify.annotations.Nullable;
5+
6+
public class JavaUtilFunctionMethods {
7+
8+
public static void withFunction(Function<String, @Nullable String> f) {}
9+
}

0 commit comments

Comments
 (0)