diff --git a/nullaway/src/test/java/com/uber/nullaway/NullAwayJSpecifyGenericsTests.java b/nullaway/src/test/java/com/uber/nullaway/NullAwayJSpecifyGenericsTests.java index 7d445cedd4..0d6bcd0093 100644 --- a/nullaway/src/test/java/com/uber/nullaway/NullAwayJSpecifyGenericsTests.java +++ b/nullaway/src/test/java/com/uber/nullaway/NullAwayJSpecifyGenericsTests.java @@ -606,6 +606,28 @@ public void testForLambdasInAnAssignment() { .doTest(); } + @Test + public void testForLambdasInAnAssignmentWithoutJSpecifyMode() { + makeHelperWithoutJSpecifyMode() + .addSourceLines( + "Test.java", + "package com.uber;", + "import org.jspecify.annotations.Nullable;", + "class Test {", + " interface A {", + " String function(T1 o);", + " }", + " static void testPositive() {", + " // Using outside JSpecify Mode So we don't get a bug here", + " A<@Nullable Object> p = o -> o.toString();", + " }", + " static void testNegative() {", + " A p = o -> o.toString();", + " }", + "}") + .doTest(); + } + @Test public void testForDiamondInAnAssignment() { makeHelper() @@ -1426,4 +1448,8 @@ private CompilationTestHelper makeHelper() { Arrays.asList( "-XepOpt:NullAway:AnnotatedPackages=com.uber", "-XepOpt:NullAway:JSpecifyMode=true")); } + + private CompilationTestHelper makeHelperWithoutJSpecifyMode() { + return makeTestHelperWithArgs(Arrays.asList("-XepOpt:NullAway:AnnotatedPackages=com.uber")); + } }