Skip to content

Commit

Permalink
Adding a test case for lambdas without JSpecify mode
Browse files Browse the repository at this point in the history
  • Loading branch information
akulk022 committed Oct 21, 2023
1 parent 3f653c7 commit 5f545de
Showing 1 changed file with 26 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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<T1 extends @Nullable Object> {",
" 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<Object> p = o -> o.toString();",
" }",
"}")
.doTest();
}

@Test
public void testForDiamondInAnAssignment() {
makeHelper()
Expand Down Expand Up @@ -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"));
}
}

0 comments on commit 5f545de

Please sign in to comment.