Commit 9907586
authored
Use refined types from dataflow analysis in generic method inference (#1309)
Fixes #1287
In generic method inference, we now try to obtain a refined type from
dataflow-based type inference for arguments when generating constraints.
This introduces a recursive dependence between dataflow analysis and
generic method inference, which we handle as follows. We track whether
generic method inference has been invoked from dataflow by passing a
`calledFromDataflow` parameter. When the parameter is true, generic
method inference calls a new API to get the _current_ dataflow fact for
the argument from the running dataflow analysis, avoiding a recursive
run. Since this may not be the fact in the final fixed point of
dataflow, we skip caching of generic method inference results when it is
invoked from the dataflow analysis. This may skip caching unnecessarily
in some cases, but we prefer to make correctness more obvious for now;
we can optimize further in the future if needed.
<!-- This is an auto-generated comment: release notes by coderabbit.ai
-->
## Summary by CodeRabbit
* **New Features**
* Dataflow-aware argument/type refinement for improved nullness
precision.
* Ability to query in-flight ("running") dataflow nullness and control
whether analysis runs.
* Utility to strip nullable annotations from types.
* **Bug Fixes**
* Guarded caching and path-aware propagation to avoid reusing
dataflow-dependent inference results.
* **Tests**
* Re-enabled a test, added dataflow/loop/local-variable tests, and
updated diagnostics.
<!-- end of auto-generated comment: release notes by coderabbit.ai -->1 parent c6d2ba3 commit 9907586
7 files changed
Lines changed: 377 additions & 48 deletions
File tree
- nullaway/src
- main/java/com/uber/nullaway
- dataflow
- generics
- test/java/com/uber/nullaway/jspecify
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
2711 | 2711 | | |
2712 | 2712 | | |
2713 | 2713 | | |
2714 | | - | |
| 2714 | + | |
2715 | 2715 | | |
2716 | 2716 | | |
2717 | 2717 | | |
| |||
Lines changed: 14 additions & 2 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
112 | 112 | | |
113 | 113 | | |
114 | 114 | | |
115 | | - | |
| 115 | + | |
| 116 | + | |
| 117 | + | |
| 118 | + | |
| 119 | + | |
| 120 | + | |
| 121 | + | |
| 122 | + | |
| 123 | + | |
| 124 | + | |
| 125 | + | |
| 126 | + | |
| 127 | + | |
116 | 128 | | |
117 | 129 | | |
118 | 130 | | |
| |||
125 | 137 | | |
126 | 138 | | |
127 | 139 | | |
128 | | - | |
| 140 | + | |
129 | 141 | | |
130 | 142 | | |
131 | 143 | | |
| |||
Lines changed: 1 addition & 1 deletion
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1154 | 1154 | | |
1155 | 1155 | | |
1156 | 1156 | | |
1157 | | - | |
| 1157 | + | |
1158 | 1158 | | |
1159 | 1159 | | |
1160 | 1160 | | |
| |||
Lines changed: 35 additions & 9 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
85 | 85 | | |
86 | 86 | | |
87 | 87 | | |
88 | | - | |
89 | 88 | | |
90 | 89 | | |
91 | 90 | | |
92 | 91 | | |
93 | | - | |
94 | 92 | | |
95 | 93 | | |
96 | 94 | | |
| |||
147 | 145 | | |
148 | 146 | | |
149 | 147 | | |
| 148 | + | |
| 149 | + | |
| 150 | + | |
| 151 | + | |
| 152 | + | |
| 153 | + | |
| 154 | + | |
150 | 155 | | |
151 | 156 | | |
152 | | - | |
| 157 | + | |
| 158 | + | |
153 | 159 | | |
154 | 160 | | |
155 | 161 | | |
156 | 162 | | |
157 | 163 | | |
| 164 | + | |
| 165 | + | |
| 166 | + | |
158 | 167 | | |
159 | 168 | | |
160 | 169 | | |
| |||
187 | 196 | | |
188 | 197 | | |
189 | 198 | | |
190 | | - | |
| 199 | + | |
| 200 | + | |
191 | 201 | | |
192 | 202 | | |
193 | 203 | | |
| |||
197 | 207 | | |
198 | 208 | | |
199 | 209 | | |
| 210 | + | |
200 | 211 | | |
201 | 212 | | |
202 | 213 | | |
203 | 214 | | |
204 | 215 | | |
205 | 216 | | |
206 | | - | |
207 | | - | |
208 | | - | |
| 217 | + | |
| 218 | + | |
| 219 | + | |
| 220 | + | |
| 221 | + | |
| 222 | + | |
| 223 | + | |
| 224 | + | |
| 225 | + | |
| 226 | + | |
| 227 | + | |
| 228 | + | |
| 229 | + | |
| 230 | + | |
| 231 | + | |
| 232 | + | |
| 233 | + | |
| 234 | + | |
209 | 235 | | |
210 | 236 | | |
211 | 237 | | |
| |||
230 | 256 | | |
231 | 257 | | |
232 | 258 | | |
233 | | - | |
| 259 | + | |
234 | 260 | | |
235 | 261 | | |
236 | 262 | | |
| |||
280 | 306 | | |
281 | 307 | | |
282 | 308 | | |
283 | | - | |
| 309 | + | |
284 | 310 | | |
285 | 311 | | |
286 | 312 | | |
| |||
0 commit comments