Skip to content

Commit 5872fa4

Browse files
committed
Infer in the same definition query
1 parent d34211d commit 5872fa4

File tree

2 files changed

+184
-233
lines changed

2 files changed

+184
-233
lines changed

crates/red_knot_python_semantic/src/types.rs

Lines changed: 2 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -181,21 +181,13 @@ pub(crate) fn global_symbol<'db>(db: &'db dyn Db, file: File, name: &str) -> Sym
181181
/// Infer the type of a binding.
182182
pub(crate) fn binding_ty<'db>(db: &'db dyn Db, definition: Definition<'db>) -> Type<'db> {
183183
let inference = infer_definition_types(db, definition);
184-
if inference.is_eagerly_deferred(definition) {
185-
infer_deferred_types(db, definition).binding_ty(definition)
186-
} else {
187-
inference.binding_ty(definition)
188-
}
184+
inference.binding_ty(definition)
189185
}
190186

191187
/// Infer the type of a declaration.
192188
fn declaration_ty<'db>(db: &'db dyn Db, definition: Definition<'db>) -> Type<'db> {
193189
let inference = infer_definition_types(db, definition);
194-
if inference.is_eagerly_deferred(definition) {
195-
infer_deferred_types(db, definition).declaration_ty(definition)
196-
} else {
197-
inference.declaration_ty(definition)
198-
}
190+
inference.declaration_ty(definition)
199191
}
200192

201193
/// Infer the type of a (possibly deferred) sub-expression of a [`Definition`].
@@ -2229,21 +2221,6 @@ impl<'db> IterationOutcome<'db> {
22292221
}
22302222
}
22312223

2232-
#[derive(Debug)]
2233-
enum MaybeDeferred<'db> {
2234-
Type(Type<'db>),
2235-
Deferred,
2236-
}
2237-
2238-
impl<'db> MaybeDeferred<'db> {
2239-
fn expect_type(self) -> Type<'db> {
2240-
match self {
2241-
MaybeDeferred::Type(ty) => ty,
2242-
MaybeDeferred::Deferred => panic!("expected a type, but got a deferred annotation"),
2243-
}
2244-
}
2245-
}
2246-
22472224
#[derive(Debug, Copy, Clone, PartialEq, Eq)]
22482225
pub enum Truthiness {
22492226
/// For an object `x`, `bool(x)` will always return `True`

0 commit comments

Comments
 (0)