Commit 9f69bea
Fix crash on lambda in generic context with generic method in body (#15155)
Fixes #15060
The example in the issue contains another case where an erased type may
legitimately appear in a generic function. Namely, when we have a lambda
in a generic context, and its body contains a call to a generic
_method_. First, since we infer the type of lambda in erased context,
some of lambda parameters may get assigned a type containing erased
components. Then, when accessing a generic method on such type we may
get a callable that is both generic and has erased components, thus
causing the crash (actually there are two very similar crashes depending
on the details of the generic method).
Provided that we now have two legitimate cases for erased type appearing
in `expand_type()`, and special-casing (enabling) them would be tricky
(a lot of functions will need to have `allow_erased_callables`), I
propose to simply remove the check.
Co-authored-by: Shantanu <12621235+hauntsaninja@users.noreply.github.com>1 parent 6f28cc3 commit 9f69bea
File tree
4 files changed
+28
-36
lines changed- mypy
- test-data/unit
4 files changed
+28
-36
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
75 | 75 | | |
76 | 76 | | |
77 | 77 | | |
78 | | - | |
79 | 78 | | |
80 | 79 | | |
81 | 80 | | |
| |||
119 | 118 | | |
120 | 119 | | |
121 | 120 | | |
122 | | - | |
123 | | - | |
124 | | - | |
125 | | - | |
| 121 | + | |
126 | 122 | | |
127 | | - | |
128 | | - | |
129 | | - | |
130 | | - | |
| 123 | + | |
131 | 124 | | |
132 | 125 | | |
133 | 126 | | |
| |||
163 | 156 | | |
164 | 157 | | |
165 | 158 | | |
166 | | - | |
167 | | - | |
168 | | - | |
| 159 | + | |
169 | 160 | | |
170 | 161 | | |
171 | 162 | | |
172 | 163 | | |
173 | | - | |
| 164 | + | |
174 | 165 | | |
175 | 166 | | |
176 | 167 | | |
177 | 168 | | |
178 | 169 | | |
179 | 170 | | |
180 | 171 | | |
181 | | - | |
| 172 | + | |
182 | 173 | | |
183 | 174 | | |
184 | 175 | | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
48 | 48 | | |
49 | 49 | | |
50 | 50 | | |
51 | | - | |
52 | | - | |
53 | | - | |
| 51 | + | |
54 | 52 | | |
55 | 53 | | |
56 | 54 | | |
57 | 55 | | |
58 | | - | |
59 | | - | |
60 | | - | |
| 56 | + | |
61 | 57 | | |
62 | 58 | | |
63 | 59 | | |
64 | 60 | | |
65 | | - | |
66 | | - | |
67 | | - | |
| 61 | + | |
68 | 62 | | |
69 | 63 | | |
70 | 64 | | |
71 | | - | |
72 | | - | |
73 | | - | |
| 65 | + | |
74 | 66 | | |
75 | 67 | | |
76 | 68 | | |
77 | | - | |
| 69 | + | |
78 | 70 | | |
79 | 71 | | |
80 | 72 | | |
| |||
195 | 187 | | |
196 | 188 | | |
197 | 189 | | |
198 | | - | |
199 | | - | |
200 | | - | |
| 190 | + | |
201 | 191 | | |
202 | | - | |
203 | 192 | | |
204 | 193 | | |
205 | 194 | | |
| |||
217 | 206 | | |
218 | 207 | | |
219 | 208 | | |
220 | | - | |
221 | | - | |
222 | 209 | | |
223 | 210 | | |
224 | 211 | | |
225 | | - | |
226 | | - | |
| 212 | + | |
| 213 | + | |
| 214 | + | |
227 | 215 | | |
228 | 216 | | |
229 | 217 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1714 | 1714 | | |
1715 | 1715 | | |
1716 | 1716 | | |
1717 | | - | |
| 1717 | + | |
1718 | 1718 | | |
1719 | 1719 | | |
1720 | 1720 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
2698 | 2698 | | |
2699 | 2699 | | |
2700 | 2700 | | |
| 2701 | + | |
| 2702 | + | |
| 2703 | + | |
| 2704 | + | |
| 2705 | + | |
| 2706 | + | |
| 2707 | + | |
| 2708 | + | |
| 2709 | + | |
| 2710 | + | |
| 2711 | + | |
| 2712 | + | |
| 2713 | + | |
0 commit comments