Commit 2e578d6
authored
Invoke generic method inference in more places (#1286)
Fixes #1262, fixes #1263
We now invoke inference for generic method calls in more places,
including when it gets queried from dataflow analysis of a full method.
Where possible, we provide a `TreePath` to the relevant call. With this
`TreePath`, we can reconstruct the assignment context of the call and
use that information when performing inference (see the new
`getInvocationAndContextForInference` method). In some cases, we pass
`null` as the `TreePath` since one is not readily available. I _believe_
that in most / all of these cases, inference should have already been
performed for the call, so we should be able to use the cached result.
If / when we find cases where that didn't happen, and it is impacting
the inference result negatively, we can fix in follow ups.
<!-- This is an auto-generated comment: release notes by coderabbit.ai
-->
## Summary by CodeRabbit
* **New Features**
* Path-aware nullness inference for generic method calls that selects
the correct invocation/assignment context, including nested calls and
assignment sites.
* **Bug Fixes**
* More accurate generic return nullness determination to reduce
incorrect diagnostics in complex call and assignment patterns.
* **Performance**
* Per-invocation caching to speed repeated inference and reuse results
across related calls.
* **Tests**
* Re-enabled and expanded generics inference tests, adding
dataflow-triggered inference scenarios and related assertions.
<!-- end of auto-generated comment: release notes by coderabbit.ai -->1 parent c187bf5 commit 2e578d6
File tree
4 files changed
+306
-61
lines changed- nullaway/src
- main/java/com/uber/nullaway
- dataflow
- generics
- test/java/com/uber/nullaway/jspecify
4 files changed
+306
-61
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
2711 | 2711 | | |
2712 | 2712 | | |
2713 | 2713 | | |
| 2714 | + | |
| 2715 | + | |
| 2716 | + | |
2714 | 2717 | | |
2715 | 2718 | | |
2716 | | - | |
| 2719 | + | |
2717 | 2720 | | |
2718 | 2721 | | |
2719 | 2722 | | |
| |||
Lines changed: 1 addition & 1 deletion
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1155 | 1155 | | |
1156 | 1156 | | |
1157 | 1157 | | |
1158 | | - | |
| 1158 | + | |
1159 | 1159 | | |
1160 | 1160 | | |
1161 | 1161 | | |
| |||
0 commit comments