File tree Expand file tree Collapse file tree
crates/ty_python_semantic/src Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -14109,12 +14109,18 @@ impl<'db> UnionType<'db> {
1410914109
1411014110 pub(crate) fn filter(self, db: &'db dyn Db, f: impl FnMut(&Type<'db>) -> bool) -> Type<'db> {
1411114111 let current = self.elements(db);
14112- let new: Box<[ Type<'db>] > = current.iter().copied().filter(f).collect();
14112+ let new: Vec< Type<'db>> = current.iter().copied().filter(f).collect();
1411314113 match new.len() {
1411414114 0 => Type::Never,
1411514115 1 => new[0],
1411614116 len if len == current.len() => Type::Union(self),
14117- _ => Type::Union(UnionType::new(db, new, self.recursively_defined(db))),
14117+ _ => new
14118+ .iter()
14119+ .fold(UnionBuilder::new(db), |builder, element| {
14120+ builder.add(*element)
14121+ })
14122+ .recursively_defined(self.recursively_defined(db))
14123+ .build(),
1411814124 }
1411914125 }
1412014126
You can’t perform that action at this time.
0 commit comments