Commit 9ecc33d
metacompile isinstance checks (#23885)
Summary:
Pull Request resolved: #23885
This is a series of PRs that will allow us to support adding [padding to conv](#22484) and also reduce the friction of adding method overloads that was brought up in #23266.
This PR only compiles one if branch if the condition is an isinstance check. This is consistent with what mypy does; it does not report errors if a branch can be determined statically to be unreachable.
```
def foo(x):
# type: (int) -> int
if isinstance(x, str):
return x["1"]
return x + 1
reveal_type(foo) # no error, shows int -> int
```
Test Plan: Imported from OSS
Differential Revision: D16697092
Pulled By: eellison
fbshipit-source-id: d3eb4925cd16d551515ac6ff620a69897dbec1301 parent 33a1c30 commit 9ecc33d
2 files changed
+61
-6
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
12960 | 12960 | | |
12961 | 12961 | | |
12962 | 12962 | | |
| 12963 | + | |
| 12964 | + | |
| 12965 | + | |
| 12966 | + | |
| 12967 | + | |
| 12968 | + | |
| 12969 | + | |
| 12970 | + | |
| 12971 | + | |
| 12972 | + | |
| 12973 | + | |
| 12974 | + | |
| 12975 | + | |
| 12976 | + | |
| 12977 | + | |
| 12978 | + | |
| 12979 | + | |
| 12980 | + | |
| 12981 | + | |
| 12982 | + | |
| 12983 | + | |
| 12984 | + | |
| 12985 | + | |
| 12986 | + | |
| 12987 | + | |
| 12988 | + | |
| 12989 | + | |
| 12990 | + | |
| 12991 | + | |
12963 | 12992 | | |
12964 | 12993 | | |
12965 | 12994 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1280 | 1280 | | |
1281 | 1281 | | |
1282 | 1282 | | |
| 1283 | + | |
| 1284 | + | |
| 1285 | + | |
| 1286 | + | |
| 1287 | + | |
| 1288 | + | |
| 1289 | + | |
| 1290 | + | |
| 1291 | + | |
| 1292 | + | |
| 1293 | + | |
| 1294 | + | |
1283 | 1295 | | |
1284 | | - | |
1285 | | - | |
| 1296 | + | |
| 1297 | + | |
| 1298 | + | |
1286 | 1299 | | |
1287 | 1300 | | |
| 1301 | + | |
| 1302 | + | |
1288 | 1303 | | |
1289 | | - | |
1290 | | - | |
| 1304 | + | |
| 1305 | + | |
1291 | 1306 | | |
1292 | | - | |
1293 | | - | |
| 1307 | + | |
| 1308 | + | |
| 1309 | + | |
| 1310 | + | |
| 1311 | + | |
| 1312 | + | |
| 1313 | + | |
| 1314 | + | |
| 1315 | + | |
| 1316 | + | |
| 1317 | + | |
| 1318 | + | |
1294 | 1319 | | |
| 1320 | + | |
1295 | 1321 | | |
1296 | 1322 | | |
1297 | 1323 | | |
| |||
0 commit comments