[red-knot] don't include Unknown in the type for a conditionally-defined import (#13563)

## Summary

Fixes the bug described in #13514 where an unbound public type defaulted
to the type or `Unknown`, whereas it should only be the type if unbound.

## Test Plan

Added a new test case

---------

Co-authored-by: Carl Meyer <carl@astral.sh>
This commit is contained in:
aditya pillai 2024-10-16 16:46:03 -04:00 committed by GitHub
parent 2095ea8372
commit ed4a0b34ba
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
10 changed files with 126 additions and 91 deletions

View file

@ -37,6 +37,13 @@ fn core_module_symbol_ty<'db>(
) -> Type<'db> {
resolve_module(db, &core_module.name())
.map(|module| global_symbol_ty(db, module.file(), symbol))
.map(|ty| {
if ty.is_unbound() {
ty
} else {
ty.replace_unbound_with(db, Type::Never)
}
})
.unwrap_or(Type::Unbound)
}