constraint implication check

This commit is contained in:
Douglas Creager 2025-10-16 15:22:48 -04:00
parent 5affc120b3
commit 5c2c3f00ff
1 changed files with 6 additions and 2 deletions

View File

@ -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.