Always build a union of inferred_ty and declared_ty

This commit is contained in:
David Peter
2024-12-19 16:52:44 +01:00
parent c0e7c08705
commit 89fefe0164

View File

@@ -90,12 +90,10 @@ fn symbol_by_id<'db>(db: &'db dyn Db, scope: ScopeId<'db>, symbol: ScopedSymbolI
match inferred_ty {
// Symbol is possibly undeclared and definitely unbound
Symbol::Unbound => Symbol::Type(declared_ty, Boundness::Bound),
// Symbol is possibly undeclared and definitely bound
inferred @ Symbol::Type(_, Boundness::Bound) => inferred,
// Symbol is possibly undeclared and possibly unbound
Symbol::Type(inferred_ty, Boundness::PossiblyUnbound) => Symbol::Type(
UnionType::from_elements(db, [declared_ty, inferred_ty].iter().copied()),
Boundness::PossiblyUnbound,
// Symbol is possibly undeclared and (possibly) bound
Symbol::Type(inferred_ty, boundness) => Symbol::Type(
UnionType::from_elements(db, [inferred_ty, declared_ty].iter().copied()),
boundness,
),
}
}