Skip to content

Commit

Permalink
another test
Browse files Browse the repository at this point in the history
  • Loading branch information
msridhar committed Dec 19, 2024
1 parent 6a32c6a commit 1a1c042
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 1 deletion.
1 change: 0 additions & 1 deletion nullaway/src/main/java/com/uber/nullaway/NullAway.java
Original file line number Diff line number Diff line change
Expand Up @@ -490,7 +490,6 @@ public Description matchAssignment(AssignmentTree tree, VisitorState state) {
// assigning to symbol that is unannotated
return Description.NO_MATCH;
}
// TODO add test that we skip generics check if lhs symbol is unannotated
// generics check
if (lhsType != null && config.isJSpecifyMode()) {
GenericsChecks.checkTypeParameterNullnessForAssignability(tree, this, state);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2045,6 +2045,30 @@ public void issue1093() {
.doTest();
}

@Test
public void nullUnmarkedGenericField() {
makeHelper()
.addSourceLines(
"Test.java",
"package com.unannotated;",
"import org.jspecify.annotations.*;",
"import java.util.function.Function;",
"public class Test {",
" static Function<@Nullable String, @Nullable String> foo;",
" @NullMarked",
" static class Inner {",
" static @Nullable Function<@Nullable String, @Nullable String> bar;",
" void bar(Function<String,String> f) {",
" // no error since foo is in @NullUnmarked code",
" foo = f;",
" // BUG: Diagnostic contains: Cannot assign from type Function<String, String>",
" bar = f;",
" }",
" }",
"}")
.doTest();
}

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

0 comments on commit 1a1c042

Please sign in to comment.