Commit 3ad6157
authored
Fix match statement narrowing for self-matching class patterns with literal arguments (#21918)
Fixes #21780
This was likely because join_types was being used to combine two
possible remaining types (e.g. tuple[int, int] and int), and it would
collapse those into object instead of keeping both, which is why mypy
couldn't narrow down to a bottom type (Never).
This PR replaces join_types with make_simplified_union, and adds a
regression test based on the repro in the issue.
Could be a better fix than this, I would welcome it.1 parent 4b6ec9d commit 3ad6157
2 files changed
Lines changed: 27 additions & 1 deletion
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
605 | 605 | | |
606 | 606 | | |
607 | 607 | | |
608 | | - | |
| 608 | + | |
609 | 609 | | |
610 | 610 | | |
611 | 611 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1905 | 1905 | | |
1906 | 1906 | | |
1907 | 1907 | | |
| 1908 | + | |
| 1909 | + | |
| 1910 | + | |
| 1911 | + | |
| 1912 | + | |
| 1913 | + | |
| 1914 | + | |
| 1915 | + | |
| 1916 | + | |
| 1917 | + | |
| 1918 | + | |
| 1919 | + | |
| 1920 | + | |
| 1921 | + | |
| 1922 | + | |
| 1923 | + | |
| 1924 | + | |
| 1925 | + | |
| 1926 | + | |
| 1927 | + | |
| 1928 | + | |
| 1929 | + | |
| 1930 | + | |
| 1931 | + | |
| 1932 | + | |
| 1933 | + | |
1908 | 1934 | | |
1909 | 1935 | | |
1910 | 1936 | | |
| |||
0 commit comments