From ec113ef69243b861b7f06147774211df97c9e49e Mon Sep 17 00:00:00 2001 From: Carl Meyer Date: Thu, 11 Dec 2025 09:24:27 -0800 Subject: [PATCH] review comments --- crates/ty_python_semantic/src/types.rs | 19 ++++++++++--------- 1 file changed, 10 insertions(+), 9 deletions(-) diff --git a/crates/ty_python_semantic/src/types.rs b/crates/ty_python_semantic/src/types.rs index 60d0261ae8..e2050ec45f 100644 --- a/crates/ty_python_semantic/src/types.rs +++ b/crates/ty_python_semantic/src/types.rs @@ -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()) - { - self - } else { - UnionType::from_elements_cycle_recovery(db, [self, previous]) - }; - base_ty.recursive_type_normalized(db, cycle) + match (previous, self) { + (Type::GenericAlias(prev_alias), Type::GenericAlias(curr_alias)) + if prev_alias.origin(db) == curr_alias.origin(db) => + { + self + } + _ => UnionType::from_elements_cycle_recovery(db, [self, previous]), + } + .recursive_type_normalized(db, cycle) } fn is_none(&self, db: &'db dyn Db) -> bool {