mirror of https://github.com/astral-sh/ruff
review comments
This commit is contained in:
parent
e7ccc073d1
commit
ec113ef692
|
|
@ -912,18 +912,19 @@ impl<'db> Type<'db> {
|
||||||
previous: Self,
|
previous: Self,
|
||||||
cycle: &salsa::Cycle,
|
cycle: &salsa::Cycle,
|
||||||
) -> Self {
|
) -> Self {
|
||||||
// Avoid unioning two class-literals or generic-aliases together; this union will never
|
// Avoid unioning two generic aliases of the same class together; this union will never
|
||||||
// simplify and is likely to cause downstream problems. This introduces the theoretical
|
// simplify and is likely to cause downstream problems. This introduces the theoretical
|
||||||
// possibility of cycle oscillation involving such types (because we are not strictly
|
// possibility of cycle oscillation involving such types (because we are not strictly
|
||||||
// widening the type on each iteration), but so far we have not seen an example of that.
|
// widening the type on each iteration), but so far we have not seen an example of that.
|
||||||
let base_ty = if (self.is_class_literal() && previous.is_class_literal())
|
match (previous, self) {
|
||||||
|| (self.is_generic_alias() && previous.is_generic_alias())
|
(Type::GenericAlias(prev_alias), Type::GenericAlias(curr_alias))
|
||||||
|
if prev_alias.origin(db) == curr_alias.origin(db) =>
|
||||||
{
|
{
|
||||||
self
|
self
|
||||||
} else {
|
}
|
||||||
UnionType::from_elements_cycle_recovery(db, [self, previous])
|
_ => UnionType::from_elements_cycle_recovery(db, [self, previous]),
|
||||||
};
|
}
|
||||||
base_ty.recursive_type_normalized(db, cycle)
|
.recursive_type_normalized(db, cycle)
|
||||||
}
|
}
|
||||||
|
|
||||||
fn is_none(&self, db: &'db dyn Db) -> bool {
|
fn is_none(&self, db: &'db dyn Db) -> bool {
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue