Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Infer generics for assignments #1131

Open
wants to merge 47 commits into
base: master
Choose a base branch
from
Open
Changes from 1 commit
Commits
Show all changes
47 commits
Select commit Hold shift + click to select a range
b3eba82
fix and test
msridhar Nov 5, 2024
bc9e5fb
another fix and test
msridhar Nov 5, 2024
174b262
add TODO
msridhar Nov 5, 2024
c94dc28
check explicit type arguments when comparing generic type param nulla…
haewiful Nov 11, 2024
32b87ab
formatting
haewiful Nov 11, 2024
e1dfa8a
add test case for explicit type arguments
haewiful Nov 11, 2024
be9c657
Merge branch 'master' into check-type-param
haewiful Nov 11, 2024
24ca5a1
apply substitution to method type
msridhar Nov 11, 2024
cc45e43
Merge branch 'master' into check-type-param
msridhar Nov 12, 2024
3f3ebf2
make function that substitutes explicit type arguments
haewiful Nov 12, 2024
7004926
test case
haewiful Nov 18, 2024
aaba869
add test for multiple generics
haewiful Dec 7, 2024
37ef4d1
temp structure of inferred_types cache - need to change map key type
haewiful Dec 7, 2024
c6a6244
infer on assignments draft
haewiful Jan 13, 2025
277e2b6
new test case for inference on assignments
haewiful Jan 13, 2025
e7346d3
update test case
haewiful Jan 13, 2025
bca1d7d
simple cleanup
haewiful Jan 15, 2025
453623a
formatting
haewiful Jan 15, 2025
9375170
Merge remote-tracking branch 'upstream/master' into infer-generics
haewiful Jan 15, 2025
db0b6ce
minor changes
haewiful Jan 15, 2025
35b18cf
move cache into GenericsChecks and make related methods nonstatic
haewiful Jan 15, 2025
0308a5b
Merge branch 'master' into infer-generics
msridhar Jan 26, 2025
f5ece94
formatting
msridhar Jan 26, 2025
f89fef0
fix CI Job failure
haewiful Jan 28, 2025
0c577ae
remove unused code
haewiful Jan 28, 2025
61e4f3e
debugged for testJdk23
haewiful Feb 3, 2025
9f6c91b
fetch and merge
haewiful Feb 3, 2025
8a30816
Merge branch 'master' into infer-generics
haewiful Feb 3, 2025
4f4ca89
recreated :caffeine:compileTestJava error
haewiful Feb 4, 2025
d96769a
update test case
haewiful Feb 4, 2025
b3dda68
add scenarios to test cases
haewiful Feb 5, 2025
5f1e08f
add expected errors for testcase
haewiful Feb 6, 2025
1e9699a
add upper bound checks
haewiful Feb 6, 2025
a2489ea
update NullAway.java
haewiful Feb 6, 2025
ddf2440
formatting
msridhar Feb 7, 2025
24241b5
remove unnecessary parameter
msridhar Feb 7, 2025
fbedd9c
Merge branch 'master' into infer-generics
msridhar Feb 7, 2025
e07c020
update test cases
haewiful Feb 10, 2025
e15754a
version passing all tests
haewiful Feb 10, 2025
d5c4e5f
change according to comments
haewiful Feb 10, 2025
6c4430e
mid status
haewiful Feb 10, 2025
e4051cc
make code more simple
haewiful Feb 10, 2025
82628ca
make pass ./gradlew :nullaway:buildWithNullAway
haewiful Feb 10, 2025
430e855
Merge branch 'master' into infer-generics
haewiful Feb 10, 2025
f8c8d07
remove always true condition
haewiful Feb 10, 2025
6bc1d0c
make method for clearing inferredTypes cache
haewiful Feb 10, 2025
099fae7
Merge branch 'master' into infer-generics
msridhar Feb 13, 2025
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
new test case for inference on assignments
  • Loading branch information
haewiful committed Jan 13, 2025
commit 277e2b6b815cbf1cedbdf1239c720b8a49f1ddac
Original file line number Diff line number Diff line change
Expand Up @@ -195,6 +195,40 @@ public void genericInferenceOnAssignments() {
.doTest();
}

@Test
public void genericInferenceOnAssignmentsWithLocalVarTypeInference() {
makeHelper()
.addSourceLines(
"Test.java",
"package com.uber;",
"import org.jspecify.annotations.Nullable;",
" class Test {",
" static class Foo<T extends @Nullable Object> {",
" Foo(T t) {}",
" static <U extends @Nullable Object> Foo<U> make(U u) {", // use return type for inference
" return new Foo<>(u);",
" }",
" }",
// " static class Bar<S extends @Nullable Object, Z extends @Nullable Object> {",
// " Bar(S s, Z z) {}",
// " static <U extends @Nullable Object, B extends @Nullable Object> Bar<U, B> make(U a, B b) {",
// " return new Bar<>(a, b);",
// " }",
// " }",
" static void testLocalAssign() {",
" // legal",
" var f1 = Foo.make(new String());",
" // legal: infers Foo<@Nullable Object>",
" var f2 = Foo.make(null);",
// " // legal",
// " Bar<@Nullable Object, Object> b = Bar.make(null, new Object());",
// " // BUG: Diagnostic contains: passing @Nullable parameter 'null' where @NonNull is required",
// " Bar<@Nullable Object, Object> b2 = Bar.make(null, null);",
" }",
" }")
.doTest();
}

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