Repository navigation
Commit c46acee
authored
[ty] Refactor constraint traversal and cache satisfiability checks (astral-sh#29492)
This PR extracts some refactoring changes out of astral-sh#29027 so they can be
reviewed separately. This should be entirely behavioral neutral.
The changes:
- There is now a clear separation between "atomic" constraints and
non-atomic constraints. There aren't actually any non-atomic constraints
yet, but astral-sh#29027 will add existential nodes as a non-atomic constraint.
The defining characteristic is that an atomic constraint is one that is
an actual assignment to a typevar; it is what `PathAssignments` builds
up as it walks a BDD, and is what can live as an antecedent or
consequent in a `SequentMap`.
- We've extracted the logic for persisting a `ConstraintSet` into an
`OwnedConstraintSet`, moving it into a standalone file and structuring
it better via a helper type and some finer grained methods.
- Removed some code sharing in `SolutionWalker` that was actually
leading to more complex code. `visit_node` and
`node_is_satisfiable_on_path` no longer use a shared helper, since the
two uses had many differences, which required overridable hook points.
The shared part was much smaller, so it's simpler to just copy/paste
that part.
- That makes it easier to add caching of `node_is_satisfiable_on_path`,
similar to the caching we already had for `visit_node`.1 parent 477638f commit c46acee
11 files changed
Lines changed: 1693 additions & 1137 deletions
File tree
- crates
- ruff_benchmark/benches
- ty_python_semantic
- resources/mdtest
- regression
- type_properties
- src/types
- call
- constraints
- ty_vendored/ty_extensions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
651 | 651 | | |
652 | 652 | | |
653 | 653 | | |
| 654 | + | |
| 655 | + | |
| 656 | + | |
| 657 | + | |
| 658 | + | |
| 659 | + | |
| 660 | + | |
| 661 | + | |
| 662 | + | |
| 663 | + | |
| 664 | + | |
| 665 | + | |
| 666 | + | |
| 667 | + | |
| 668 | + | |
| 669 | + | |
| 670 | + | |
| 671 | + | |
| 672 | + | |
| 673 | + | |
| 674 | + | |
| 675 | + | |
| 676 | + | |
| 677 | + | |
| 678 | + | |
654 | 679 | | |
655 | 680 | | |
656 | 681 | | |
| |||
667 | 692 | | |
668 | 693 | | |
669 | 694 | | |
| 695 | + | |
670 | 696 | | |
671 | 697 | | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
561 | 561 | | |
562 | 562 | | |
563 | 563 | | |
| 564 | + | |
| 565 | + | |
| 566 | + | |
| 567 | + | |
| 568 | + | |
| 569 | + | |
| 570 | + | |
| 571 | + | |
| 572 | + | |
| 573 | + | |
| 574 | + | |
| 575 | + | |
| 576 | + | |
| 577 | + | |
| 578 | + | |
| 579 | + | |
| 580 | + | |
| 581 | + | |
| 582 | + | |
| 583 | + | |
| 584 | + | |
| 585 | + | |
| 586 | + | |
| 587 | + | |
| 588 | + | |
| 589 | + | |
| 590 | + | |
| 591 | + | |
| 592 | + | |
| 593 | + | |
| 594 | + | |
| 595 | + | |
| 596 | + | |
| 597 | + | |
| 598 | + | |
| 599 | + | |
| 600 | + | |
| 601 | + | |
| 602 | + | |
| 603 | + | |
| 604 | + | |
| 605 | + | |
| 606 | + | |
| 607 | + | |
| 608 | + | |
| 609 | + | |
| 610 | + | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1113 | 1113 | | |
1114 | 1114 | | |
1115 | 1115 | | |
| 1116 | + | |
| 1117 | + | |
| 1118 | + | |
| 1119 | + | |
| 1120 | + | |
| 1121 | + | |
| 1122 | + | |
| 1123 | + | |
| 1124 | + | |
| 1125 | + | |
| 1126 | + | |
| 1127 | + | |
| 1128 | + | |
| 1129 | + | |
| 1130 | + | |
| 1131 | + | |
| 1132 | + | |
| 1133 | + | |
| 1134 | + | |
| 1135 | + | |
| 1136 | + | |
| 1137 | + | |
| 1138 | + | |
| 1139 | + | |
| 1140 | + | |
| 1141 | + | |
1116 | 1142 | | |
1117 | 1143 | | |
1118 | 1144 | | |
| |||
1342 | 1368 | | |
1343 | 1369 | | |
1344 | 1370 | | |
| 1371 | + | |
| 1372 | + | |
| 1373 | + | |
| 1374 | + | |
| 1375 | + | |
| 1376 | + | |
| 1377 | + | |
| 1378 | + | |
| 1379 | + | |
| 1380 | + | |
| 1381 | + | |
| 1382 | + | |
| 1383 | + | |
| 1384 | + | |
| 1385 | + | |
| 1386 | + | |
| 1387 | + | |
| 1388 | + | |
| 1389 | + | |
| 1390 | + | |
| 1391 | + | |
| 1392 | + | |
| 1393 | + | |
| 1394 | + | |
| 1395 | + | |
| 1396 | + | |
| 1397 | + | |
| 1398 | + | |
| 1399 | + | |
| 1400 | + | |
| 1401 | + | |
| 1402 | + | |
| 1403 | + | |
| 1404 | + | |
| 1405 | + | |
| 1406 | + | |
| 1407 | + | |
| 1408 | + | |
| 1409 | + | |
| 1410 | + | |
| 1411 | + | |
| 1412 | + | |
| 1413 | + | |
| 1414 | + | |
1345 | 1415 | | |
1346 | 1416 | | |
1347 | 1417 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
3230 | 3230 | | |
3231 | 3231 | | |
3232 | 3232 | | |
3233 | | - | |
| 3233 | + | |
3234 | 3234 | | |
3235 | | - | |
| 3235 | + | |
3236 | 3236 | | |
3237 | 3237 | | |
3238 | | - | |
| 3238 | + | |
| 3239 | + | |
| 3240 | + | |
| 3241 | + | |
3239 | 3242 | | |
3240 | 3243 | | |
3241 | 3244 | | |
| |||
0 commit comments