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,
|
||||
cycle: &salsa::Cycle,
|
||||
) -> 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
|
||||
// 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.
|
||||
let base_ty = if (self.is_class_literal() && previous.is_class_literal())
|
||||
|| (self.is_generic_alias() && previous.is_generic_alias())
|
||||
match (previous, self) {
|
||||
(Type::GenericAlias(prev_alias), Type::GenericAlias(curr_alias))
|
||||
if prev_alias.origin(db) == curr_alias.origin(db) =>
|
||||
{
|
||||
self
|
||||
} else {
|
||||
UnionType::from_elements_cycle_recovery(db, [self, previous])
|
||||
};
|
||||
base_ty.recursive_type_normalized(db, cycle)
|
||||
}
|
||||
_ => UnionType::from_elements_cycle_recovery(db, [self, previous]),
|
||||
}
|
||||
.recursive_type_normalized(db, cycle)
|
||||
}
|
||||
|
||||
fn is_none(&self, db: &'db dyn Db) -> bool {
|
||||
|
|
|
|||
Loading…
Reference in New Issue