Commit 0000cf2
Try to predict when obj_get will fail and use constraints then
Summary:
Try to detect when we are about to try to resolve a method on a receiver where the type is so under-constrained (e.g., a variable with no interesting bounds) that it will definitely fail. In that case, try constraint-based method inference to defer needing the type of the receiver. We don't do constraint-based always, because the error messages are currently degraded, but also because some features checks are not implemented yet. However, going to constraints when we are otherwise doomed to get a 4297 error, gives us some more completeness for inference.
This is gated behind an experimental_tc_feature flag `try_constraint_method_inference`, so we can control the roll out.
It also only works inside of expression trees, because there are a number of features that aren't implemented yet, but they aren't supported in expression trees
- some attributes (__Memoized, __IgnoreReadonly, __AcceptDisposable)
- noreturn
- explicit type applications for generics
There is also a config option `constraint_method_call` that enables constraints categorically, for testing purposes.
Also make constraints work with inout and named parameters
Reviewed By: andrewjkennedy
Differential Revision: D84817455
fbshipit-source-id: 20a6846e9318fe6605306853cda5c15362f901611 parent 1128e6a commit 0000cf2
5 files changed
Lines changed: 97 additions & 26 deletions
File tree
- hphp/hack
- src
- options
- typing
- test/typecheck/expression_trees/nesting/vars
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
62 | 62 | | |
63 | 63 | | |
64 | 64 | | |
| 65 | + | |
| 66 | + | |
| 67 | + | |
65 | 68 | | |
66 | 69 | | |
67 | 70 | | |
| |||
74 | 77 | | |
75 | 78 | | |
76 | 79 | | |
| 80 | + | |
77 | 81 | | |
78 | 82 | | |
79 | 83 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
6254 | 6254 | | |
6255 | 6255 | | |
6256 | 6256 | | |
| 6257 | + | |
| 6258 | + | |
| 6259 | + | |
| 6260 | + | |
| 6261 | + | |
| 6262 | + | |
| 6263 | + | |
| 6264 | + | |
| 6265 | + | |
| 6266 | + | |
| 6267 | + | |
| 6268 | + | |
| 6269 | + | |
| 6270 | + | |
| 6271 | + | |
| 6272 | + | |
| 6273 | + | |
| 6274 | + | |
| 6275 | + | |
| 6276 | + | |
| 6277 | + | |
| 6278 | + | |
| 6279 | + | |
| 6280 | + | |
| 6281 | + | |
| 6282 | + | |
| 6283 | + | |
| 6284 | + | |
| 6285 | + | |
| 6286 | + | |
| 6287 | + | |
| 6288 | + | |
| 6289 | + | |
| 6290 | + | |
| 6291 | + | |
| 6292 | + | |
| 6293 | + | |
| 6294 | + | |
| 6295 | + | |
| 6296 | + | |
| 6297 | + | |
| 6298 | + | |
| 6299 | + | |
| 6300 | + | |
| 6301 | + | |
| 6302 | + | |
| 6303 | + | |
| 6304 | + | |
| 6305 | + | |
| 6306 | + | |
| 6307 | + | |
| 6308 | + | |
6257 | 6309 | | |
6258 | 6310 | | |
6259 | 6311 | | |
| |||
6266 | 6318 | | |
6267 | 6319 | | |
6268 | 6320 | | |
6269 | | - | |
| 6321 | + | |
| 6322 | + | |
6270 | 6323 | | |
6271 | 6324 | | |
6272 | 6325 | | |
6273 | | - | |
| 6326 | + | |
| 6327 | + | |
| 6328 | + | |
| 6329 | + | |
| 6330 | + | |
| 6331 | + | |
| 6332 | + | |
| 6333 | + | |
| 6334 | + | |
| 6335 | + | |
| 6336 | + | |
| 6337 | + | |
| 6338 | + | |
| 6339 | + | |
| 6340 | + | |
| 6341 | + | |
| 6342 | + | |
| 6343 | + | |
| 6344 | + | |
| 6345 | + | |
6274 | 6346 | | |
6275 | 6347 | | |
6276 | 6348 | | |
| |||
6289 | 6361 | | |
6290 | 6362 | | |
6291 | 6363 | | |
6292 | | - | |
6293 | | - | |
6294 | | - | |
6295 | | - | |
6296 | | - | |
6297 | | - | |
6298 | | - | |
6299 | | - | |
6300 | | - | |
| 6364 | + | |
| 6365 | + | |
| 6366 | + | |
| 6367 | + | |
| 6368 | + | |
| 6369 | + | |
| 6370 | + | |
| 6371 | + | |
| 6372 | + | |
| 6373 | + | |
| 6374 | + | |
6301 | 6375 | | |
6302 | 6376 | | |
6303 | | - | |
| 6377 | + | |
6304 | 6378 | | |
6305 | 6379 | | |
6306 | | - | |
| 6380 | + | |
| 6381 | + | |
| 6382 | + | |
| 6383 | + | |
6307 | 6384 | | |
6308 | 6385 | | |
6309 | 6386 | | |
| |||
6346 | 6423 | | |
6347 | 6424 | | |
6348 | 6425 | | |
6349 | | - | |
| 6426 | + | |
| 6427 | + | |
6350 | 6428 | | |
6351 | 6429 | | |
6352 | 6430 | | |
| |||
Lines changed: 1 addition & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1 | 1 | | |
2 | 2 | | |
| 3 | + | |
Lines changed: 0 additions & 6 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
4 | 4 | | |
5 | 5 | | |
6 | 6 | | |
7 | | - | |
8 | | - | |
9 | | - | |
10 | | - | |
11 | | - | |
12 | | - | |
Lines changed: 0 additions & 6 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
4 | 4 | | |
5 | 5 | | |
6 | 6 | | |
7 | | - | |
8 | | - | |
9 | | - | |
10 | | - | |
11 | | - | |
12 | | - | |
0 commit comments