Skip to content

Commit

Permalink
add test for issue 1035
Browse files Browse the repository at this point in the history
  • Loading branch information
msridhar committed Nov 14, 2024
1 parent 7a3d088 commit 7b6d087
Showing 1 changed file with 29 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -161,6 +161,35 @@ public void genericMethodAndVoidTypeWithInference() {
.doTest();
}

@Test
public void issue1035() {
makeHelper()
.addSourceLines(
"Todo.java",
"import org.jspecify.annotations.*;",
"@NullMarked",
"public class Todo {",
" public static <T extends @Nullable Object> T foo(NullableSupplier<T> code) {",
" return code.get();",
" }",
" public static void main(String[] args) {",
" // BUG: Diagnostic contains: returning @Nullable expression from method with @NonNull return type",
" Todo.<Object>foo(() -> null);",
" Todo.<@Nullable Object>foo(() -> null);",
" }",
" // this method should have no errors once we support inference for generic methods",
" public static void requiresInferenceSupport() {",
" // BUG: Diagnostic contains: returning @Nullable expression from method with @NonNull return type",
" Todo.foo(() -> null);",
" }",
" @FunctionalInterface",
" public interface NullableSupplier<T extends @Nullable Object> {",
" T get();",
" }",
"}")
.doTest();
}

private CompilationTestHelper makeHelper() {
return makeTestHelperWithArgs(
Arrays.asList(
Expand Down

0 comments on commit 7b6d087

Please sign in to comment.