Commit 4fdb4e8
authored
[ty] avoid unions of generic aliases of the same class in fixpoint (#21909)
Partially addresses astral-sh/ty#1732
Fixes astral-sh/ty#1800
## Summary
At each fixpoint iteration, we union the "previous" and "current"
iteration types, to ensure that the type can only widen at each
iteration. This prevents oscillation and ensures convergence.
But some unions triggered by this behavior (in particular, unions of
differently-specialized generic-aliases of the same class) never
simplify, and cause spurious errors. Since we haven't seen examples of
oscillating types involving class-literal or generic-alias types, just
don't union those.
There may be more thorough/principled ways to avoid undesirable unions
in fixpoint iteration, but this narrow change seems like it results in
strict improvement.
## Test Plan
Removes two false positive `unsupported-class-base` in mdtests, and
several in the ecosystem, without causing other regression.1 parent c548ef2 commit 4fdb4e8
File tree
2 files changed
+13
-7
lines changed- crates/ty_python_semantic
- resources/mdtest/generics/legacy
- src
2 files changed
+13
-7
lines changedLines changed: 0 additions & 5 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
860 | 860 | | |
861 | 861 | | |
862 | 862 | | |
863 | | - | |
864 | | - | |
865 | | - | |
866 | 863 | | |
867 | 864 | | |
868 | 865 | | |
| |||
888 | 885 | | |
889 | 886 | | |
890 | 887 | | |
891 | | - | |
892 | | - | |
893 | 888 | | |
894 | 889 | | |
895 | 890 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
912 | 912 | | |
913 | 913 | | |
914 | 914 | | |
915 | | - | |
916 | | - | |
| 915 | + | |
| 916 | + | |
| 917 | + | |
| 918 | + | |
| 919 | + | |
| 920 | + | |
| 921 | + | |
| 922 | + | |
| 923 | + | |
| 924 | + | |
| 925 | + | |
| 926 | + | |
| 927 | + | |
917 | 928 | | |
918 | 929 | | |
919 | 930 | | |
| |||
0 commit comments