Revert "experiment: sort unions in cycle recovery functions"

This reverts commit 74d3ad6ef4.
This commit is contained in:
Shunsuke Shibayama 2025-12-12 16:09:23 +09:00
parent 74d3ad6ef4
commit 5964d7d9d6
2 changed files with 9 additions and 2 deletions

View File

@ -14194,7 +14194,7 @@ impl<'db> UnionType<'db> {
nested: bool,
) -> Option<Type<'db>> {
let mut builder = UnionBuilder::new(db)
.order_elements(true)
.order_elements(false)
.unpack_aliases(false)
.cycle_recovery(true)
.recursively_defined(self.recursively_defined(db));

View File

@ -38,6 +38,7 @@
//! unnecessary `is_subtype_of` checks.
use crate::types::enums::{enum_member_literals, enum_metadata};
use crate::types::type_ordering::union_or_intersection_elements_ordering;
use crate::types::{
BytesLiteralType, IntersectionType, KnownClass, StringLiteralType, Type,
TypeVarBoundOrConstraints, UnionType, structural_type_ordering,
@ -651,7 +652,13 @@ impl<'db> UnionBuilder<'db> {
}
}
if self.order_elements {
types.sort_unstable_by(|l, r| structural_type_ordering(self.db, l, r));
types.sort_unstable_by(|l, r| {
if self.recursively_defined.is_yes() {
structural_type_ordering(self.db, l, r)
} else {
union_or_intersection_elements_ordering(self.db, l, r)
}
});
}
match types.len() {
0 => None,