Skip to content

Commit c4aee80

Browse files
committed
this should check the constraints too
1 parent 6c4b27f commit c4aee80

1 file changed

Lines changed: 3 additions & 11 deletions

File tree

crates/ty_python_semantic/src/types/constraints.rs

Lines changed: 3 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -325,14 +325,6 @@ impl<'db> ConstrainedTypeVar<'db> {
325325
ConstraintAssignment::Negative(self)
326326
}
327327

328-
fn contains(self, db: &'db dyn Db, other: Self) -> bool {
329-
if self.typevar(db) != other.typevar(db) {
330-
return false;
331-
}
332-
self.lower(db).is_subtype_of(db, other.lower(db))
333-
&& other.upper(db).is_subtype_of(db, self.upper(db))
334-
}
335-
336328
/// Returns whether this constraint implies contains another — i.e., whether every type that
337329
/// satisfies this constraint also satisfies `other`.
338330
///
@@ -1104,10 +1096,10 @@ impl<'db> InteriorNode<'db> {
11041096

11051097
// Containment: The range of one constraint might completely contain the range of the
11061098
// other. If so, there are several potential simplifications.
1107-
let larger_smaller = if left_constraint.contains(db, right_constraint) {
1108-
Some((left_constraint, right_constraint))
1109-
} else if right_constraint.contains(db, left_constraint) {
1099+
let larger_smaller = if left_constraint.implies(db, right_constraint, constraints) {
11101100
Some((right_constraint, left_constraint))
1101+
} else if right_constraint.implies(db, left_constraint, constraints) {
1102+
Some((left_constraint, right_constraint))
11111103
} else {
11121104
None
11131105
};

0 commit comments

Comments
 (0)