Skip to content
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions crates/red_knot_python_semantic/src/types.rs
Original file line number Diff line number Diff line change
Expand Up @@ -299,6 +299,7 @@ impl<'db> Type<'db> {
}
}

#[track_caller]
pub fn expect_class_literal(self) -> ClassType<'db> {
self.into_class_literal_type()
.expect("Expected a Type::ClassLiteral variant")
Expand All @@ -315,6 +316,7 @@ impl<'db> Type<'db> {
}
}

#[track_caller]
pub fn expect_module_literal(self) -> File {
self.into_module_literal_type()
.expect("Expected a Type::ModuleLiteral variant")
Expand All @@ -327,6 +329,7 @@ impl<'db> Type<'db> {
}
}

#[track_caller]
pub fn expect_union(self) -> UnionType<'db> {
self.into_union_type()
.expect("Expected a Type::Union variant")
Expand All @@ -343,6 +346,7 @@ impl<'db> Type<'db> {
}
}

#[track_caller]
pub fn expect_intersection(self) -> IntersectionType<'db> {
self.into_intersection_type()
.expect("Expected a Type::Intersection variant")
Expand All @@ -355,6 +359,7 @@ impl<'db> Type<'db> {
}
}

#[track_caller]
pub fn expect_function_literal(self) -> FunctionType<'db> {
self.into_function_literal_type()
.expect("Expected a Type::FunctionLiteral variant")
Expand All @@ -371,6 +376,7 @@ impl<'db> Type<'db> {
}
}

#[track_caller]
pub fn expect_int_literal(self) -> i64 {
self.into_int_literal_type()
.expect("Expected a Type::IntLiteral variant")
Expand Down
Loading