[ty] Simplify unions containing multiple type variables during inference (#21275)
## Summary Splitting this one out from https://github.com/astral-sh/ruff/pull/21210. This is also something that should be made obselete by the new constraint solver, but is easy enough to fix now.
This commit is contained in:
@@ -1397,11 +1397,13 @@ impl<'db> SpecializationBuilder<'db> {
|
||||
return Ok(());
|
||||
}
|
||||
|
||||
// Remove the union elements that are not related to `formal`.
|
||||
// Remove the union elements from `actual` that are not related to `formal`, and vice
|
||||
// versa.
|
||||
//
|
||||
// For example, if `formal` is `list[T]` and `actual` is `list[int] | None`, we want to specialize `T`
|
||||
// to `int`.
|
||||
// to `int`, and so ignore the `None`.
|
||||
let actual = actual.filter_disjoint_elements(self.db, formal, self.inferable);
|
||||
let formal = formal.filter_disjoint_elements(self.db, actual, self.inferable);
|
||||
|
||||
match (formal, actual) {
|
||||
// TODO: We haven't implemented a full unification solver yet. If typevars appear in
|
||||
|
||||
Reference in New Issue
Block a user