Repository navigation
Commit 0547190
committed
fix(python): bind ClassName() only to the class own __init__
A construction call now resolves to __init__ only when the called
class declares that __init__ itself. An inherited __init__ is no
longer followed: class B(A) without its own __init__ keeps the B()
call on the Class B, as it was before this branch.
Following the bases bound every subclass construction to the base
constructor. On a django index (fb113765) that made Model.__init__
a 583-caller hub (every model instantiation), bound IntegerField()
to Field.__init__ and HttpResponseForbidden() to
HttpResponse.__init__, and degraded 625 constructor call sites
versus main (457 fell back to textual resolution, 168 lost their
row; CALLS -161). With own __init__ only, 6016 sites move to the
class own __init__, 5468 stay on the Class, none fall back to a
textual strategy, and total CALLS is +4 versus main.
Tests: the same-file and cross-file inherited cases now pin the
Class target, and a new same-file subclass test at the LSP and the
graph level covers B(A) without __init__ (stays on B, never
A.__init__) and C(A) with its own __init__ (binds to C.__init__,
never the class C or A.__init__). The strategy inventory comment in
the repro suite is updated to match.
Refs DeusData#1642
Signed-off-by: Martin Vogel <martin.vogel.tech@gmail.com>1 parent aa02511 commit 0547190
4 files changed
Lines changed: 105 additions & 27 deletions
File tree
- internal/cbm/lsp
- tests
- repro
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
3249 | 3249 | | |
3250 | 3250 | | |
3251 | 3251 | | |
3252 | | - | |
3253 | | - | |
3254 | | - | |
3255 | | - | |
| 3252 | + | |
| 3253 | + | |
| 3254 | + | |
| 3255 | + | |
| 3256 | + | |
| 3257 | + | |
3256 | 3258 | | |
3257 | 3259 | | |
3258 | 3260 | | |
3259 | 3261 | | |
3260 | 3262 | | |
3261 | 3263 | | |
3262 | | - | |
| 3264 | + | |
3263 | 3265 | | |
3264 | 3266 | | |
3265 | 3267 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
64 | 64 | | |
65 | 65 | | |
66 | 66 | | |
67 | | - | |
68 | | - | |
69 | | - | |
70 | | - | |
| 67 | + | |
| 68 | + | |
| 69 | + | |
| 70 | + | |
| 71 | + | |
| 72 | + | |
71 | 73 | | |
72 | 74 | | |
73 | 75 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1853 | 1853 | | |
1854 | 1854 | | |
1855 | 1855 | | |
| 1856 | + | |
| 1857 | + | |
| 1858 | + | |
| 1859 | + | |
| 1860 | + | |
| 1861 | + | |
| 1862 | + | |
| 1863 | + | |
| 1864 | + | |
| 1865 | + | |
| 1866 | + | |
| 1867 | + | |
| 1868 | + | |
| 1869 | + | |
| 1870 | + | |
| 1871 | + | |
| 1872 | + | |
| 1873 | + | |
| 1874 | + | |
| 1875 | + | |
| 1876 | + | |
| 1877 | + | |
| 1878 | + | |
| 1879 | + | |
| 1880 | + | |
| 1881 | + | |
| 1882 | + | |
| 1883 | + | |
| 1884 | + | |
| 1885 | + | |
| 1886 | + | |
| 1887 | + | |
| 1888 | + | |
| 1889 | + | |
| 1890 | + | |
| 1891 | + | |
| 1892 | + | |
| 1893 | + | |
| 1894 | + | |
| 1895 | + | |
| 1896 | + | |
| 1897 | + | |
| 1898 | + | |
1856 | 1899 | | |
1857 | 1900 | | |
1858 | 1901 | | |
| |||
1970 | 2013 | | |
1971 | 2014 | | |
1972 | 2015 | | |
| 2016 | + | |
1973 | 2017 | | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
403 | 403 | | |
404 | 404 | | |
405 | 405 | | |
406 | | - | |
407 | | - | |
| 406 | + | |
| 407 | + | |
| 408 | + | |
| 409 | + | |
| 410 | + | |
| 411 | + | |
| 412 | + | |
| 413 | + | |
| 414 | + | |
| 415 | + | |
| 416 | + | |
| 417 | + | |
| 418 | + | |
| 419 | + | |
| 420 | + | |
| 421 | + | |
| 422 | + | |
| 423 | + | |
| 424 | + | |
| 425 | + | |
| 426 | + | |
| 427 | + | |
408 | 428 | | |
409 | 429 | | |
410 | 430 | | |
411 | 431 | | |
412 | 432 | | |
413 | 433 | | |
414 | | - | |
415 | | - | |
| 434 | + | |
| 435 | + | |
| 436 | + | |
| 437 | + | |
| 438 | + | |
| 439 | + | |
| 440 | + | |
416 | 441 | | |
417 | | - | |
| 442 | + | |
| 443 | + | |
| 444 | + | |
| 445 | + | |
| 446 | + | |
418 | 447 | | |
419 | 448 | | |
420 | 449 | | |
421 | 450 | | |
422 | | - | |
423 | | - | |
| 451 | + | |
424 | 452 | | |
425 | | - | |
| 453 | + | |
| 454 | + | |
426 | 455 | | |
427 | 456 | | |
428 | 457 | | |
| |||
1126 | 1155 | | |
1127 | 1156 | | |
1128 | 1157 | | |
1129 | | - | |
1130 | | - | |
1131 | | - | |
1132 | | - | |
| 1158 | + | |
| 1159 | + | |
| 1160 | + | |
| 1161 | + | |
| 1162 | + | |
1133 | 1163 | | |
1134 | 1164 | | |
1135 | 1165 | | |
| |||
1168 | 1198 | | |
1169 | 1199 | | |
1170 | 1200 | | |
1171 | | - | |
| 1201 | + | |
| 1202 | + | |
1172 | 1203 | | |
1173 | 1204 | | |
1174 | | - | |
1175 | | - | |
1176 | | - | |
| 1205 | + | |
| 1206 | + | |
1177 | 1207 | | |
1178 | 1208 | | |
1179 | 1209 | | |
| |||
5266 | 5296 | | |
5267 | 5297 | | |
5268 | 5298 | | |
5269 | | - | |
| 5299 | + | |
5270 | 5300 | | |
5271 | 5301 | | |
5272 | 5302 | | |
| |||
5289 | 5319 | | |
5290 | 5320 | | |
5291 | 5321 | | |
5292 | | - | |
| 5322 | + | |
5293 | 5323 | | |
5294 | 5324 | | |
5295 | 5325 | | |
| |||
0 commit comments