Skip to content

Commit 9e58d47

Browse files
committed
[ty] Refactor TypeInferenceBuilder::infer_subscript_expression_types
1 parent d2d4b11 commit 9e58d47

File tree

2 files changed

+209
-212
lines changed

2 files changed

+209
-212
lines changed

crates/ty_python_semantic/src/types/class.rs

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -4213,14 +4213,14 @@ pub(crate) struct SliceLiteral {
42134213
pub(crate) step: Option<i32>,
42144214
}
42154215

4216-
impl<'db> Type<'db> {
4217-
/// If this type represents a valid slice literal, returns a [`SliceLiteral`] describing it.
4216+
impl<'db> ClassType<'db> {
4217+
/// If this class is a specialization of `slice`, returns a [`SliceLiteral`] describing it.
42184218
/// Otherwise returns `None`.
42194219
///
4220-
/// The type must be a specialization of the `slice` builtin type, where the specialized
4221-
/// typevars are statically known integers or `None`.
4220+
/// The specialization must be one in which the typevars are solved as being statically known
4221+
/// integers or `None`.
42224222
pub(crate) fn slice_literal(self, db: &'db dyn Db) -> Option<SliceLiteral> {
4223-
let ClassType::Generic(alias) = self.into_nominal_instance()?.class else {
4223+
let ClassType::Generic(alias) = self else {
42244224
return None;
42254225
};
42264226
if !alias.origin(db).is_known(db, KnownClass::Slice) {

0 commit comments

Comments
 (0)