[red-knot] Use Unknown | T_inferred for undeclared public symbols (#15674)

## Summary

Use `Unknown | T_inferred` as the type for *undeclared* public symbols.

## Test Plan

- Updated existing tests
- New test for external `__slots__` modifications.
- New tests for external modifications of public symbols.
This commit is contained in:
David Peter 2025-01-24 12:47:48 +01:00 committed by GitHub
parent 7778d1d646
commit 1feb3cf41a
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
23 changed files with 212 additions and 91 deletions

View file

@ -85,6 +85,14 @@ impl<'db> Symbol<'db> {
Symbol::Unbound => self,
}
}
#[must_use]
pub(crate) fn map_type(self, f: impl FnOnce(Type<'db>) -> Type<'db>) -> Symbol<'db> {
match self {
Symbol::Type(ty, boundness) => Symbol::Type(f(ty), boundness),
Symbol::Unbound => Symbol::Unbound,
}
}
}
#[cfg(test)]