Alex Waygood
ec3d5ebda2
[ty] Upcast heterogeneous and mixed tuples to homogeneous tuples where it's necessary to solve a TypeVar ( #19635 )
...
## Summary
This PR improves our generics solver such that we are able to solve the
`TypeVar` in this snippet to `int | str` (the union of the elements in
the heterogeneous tuple) by upcasting the heterogeneous tuple to its
pure-homogeneous-tuple supertype:
```py
def f[T](x: tuple[T, ...]) -> T:
return x[0]
def g(x: tuple[int, str]):
reveal_type(f(x))
```
## Test Plan
Mdtests. Some TODOs remain in the mdtest regarding solving `TypeVar`s
for mixed tuples, but I think this PR on its own is a significant step
forward for our generics solver when it comes to tuple types.
---------
Co-authored-by: Douglas Creager <dcreager@dcreager.net >
2025-07-30 17:12:21 +01:00
..
2025-07-25 02:05:32 +00:00
2025-06-20 18:23:54 -04:00
2025-06-20 18:23:54 -04:00
2025-05-17 08:27:32 -04:00
2025-05-06 20:11:25 -04:00
2025-07-30 11:51:21 +02:00
2025-05-06 20:11:25 -04:00
2025-07-15 21:31:53 +02:00
2025-07-30 17:40:24 +02:00
2025-07-23 22:45:45 +02:00
2025-07-25 14:56:04 +02:00
2025-06-26 14:29:33 +02:00
2025-07-30 17:40:24 +02:00
2025-07-23 22:45:45 +02:00
2025-05-09 13:40:51 -04:00
2025-06-12 07:44:42 -07:00
2025-07-30 11:51:21 +02:00
2025-07-28 15:52:59 +02:00
2025-07-30 17:12:21 +01:00
2025-07-15 21:31:53 +02:00
2025-07-15 16:56:54 -07:00
2025-05-09 17:39:15 +01:00
2025-07-30 17:40:24 +02:00
2025-07-25 14:56:14 +02:00
2025-05-03 19:49:15 +02:00
2025-07-25 07:11:11 +00:00
2025-05-03 19:49:15 +02:00
2025-07-30 17:40:24 +02:00
2025-05-22 21:37:03 -04:00
2025-07-30 11:25:44 +00:00
2025-07-22 16:10:38 +02:00
2025-07-21 21:25:11 +00:00
2025-07-15 21:31:53 +02:00
2025-07-23 15:55:42 +02:00
2025-07-24 16:33:33 +02:00
2025-05-06 20:11:25 -04:00
2025-07-30 11:51:21 +02:00
2025-05-03 19:49:15 +02:00
2025-07-30 11:51:21 +02:00
2025-07-25 14:56:14 +02:00
2025-05-13 21:27:48 +00:00
2025-05-09 13:40:51 -04:00
2025-07-25 07:11:11 +00:00
2025-07-22 16:10:38 +02:00
2025-07-05 19:34:23 +01:00
2025-07-23 22:45:45 +02:00
2025-07-23 22:45:45 +02:00
2025-05-03 19:49:15 +02:00
2025-06-24 20:27:37 +00:00
2025-07-21 19:37:55 +02:00
2025-05-03 19:49:15 +02:00
2025-05-03 19:49:15 +02:00
2025-05-03 19:49:15 +02:00
2025-05-06 12:37:10 +01:00
2025-05-06 20:11:25 -04:00
2025-05-26 20:40:16 +01:00
2025-06-03 09:59:43 -07:00
2025-06-20 10:38:17 +02:00
2025-05-19 16:36:49 +02:00
2025-05-09 13:40:51 -04:00
2025-07-25 14:56:14 +02:00
2025-07-25 07:11:11 +00:00
2025-06-26 12:24:40 +02:00
2025-05-03 19:49:15 +02:00
2025-05-03 19:49:15 +02:00
2025-07-25 07:11:11 +00:00
2025-07-24 08:24:26 +00:00
2025-07-15 12:47:19 +01:00
2025-07-21 19:37:55 +02:00
2025-06-27 15:29:04 -04:00
2025-07-25 07:11:11 +00:00