mirror of https://github.com/astral-sh/ruff
constraint implication check
This commit is contained in:
parent
5affc120b3
commit
5c2c3f00ff
|
|
@ -315,11 +315,15 @@ impl<'db> ConstrainedTypeVar<'db> {
|
|||
}
|
||||
|
||||
fn contains(self, db: &'db dyn Db, other: Self) -> bool {
|
||||
other.implies(db, self)
|
||||
}
|
||||
|
||||
fn implies(self, db: &'db dyn Db, other: Self) -> bool {
|
||||
if self.typevar(db) != other.typevar(db) {
|
||||
return false;
|
||||
}
|
||||
self.lower(db).is_subtype_of(db, other.lower(db))
|
||||
&& other.upper(db).is_subtype_of(db, self.upper(db))
|
||||
other.lower(db).is_subtype_of(db, self.lower(db))
|
||||
&& self.upper(db).is_subtype_of(db, other.upper(db))
|
||||
}
|
||||
|
||||
/// Returns the intersection of two range constraints, or `None` if the intersection is empty.
|
||||
|
|
|
|||
Loading…
Reference in New Issue