Skip to content

Commit 043fba7

Browse files
authored
[red-knot] Fix a few details around Type::call (#13593)
1 parent 20d9977 commit 043fba7

File tree

1 file changed

+6
-7
lines changed
  • crates/red_knot_python_semantic/src

1 file changed

+6
-7
lines changed

crates/red_knot_python_semantic/src/types.rs

+6-7
Original file line numberDiff line numberDiff line change
@@ -624,8 +624,7 @@ impl<'db> Type<'db> {
624624
union
625625
.elements(db)
626626
.iter()
627-
.map(|elem| elem.call(db, arg_types))
628-
.collect::<Box<[CallOutcome<'db>]>>(),
627+
.map(|elem| elem.call(db, arg_types)),
629628
),
630629

631630
// TODO: intersection types
@@ -664,7 +663,7 @@ impl<'db> Type<'db> {
664663
if !dunder_iter_method.is_unbound() {
665664
let CallOutcome::Callable {
666665
return_ty: iterator_ty,
667-
} = dunder_iter_method.call(db, &[])
666+
} = dunder_iter_method.call(db, &[self])
668667
else {
669668
return IterationOutcome::NotIterable {
670669
not_iterable_ty: self,
@@ -673,7 +672,7 @@ impl<'db> Type<'db> {
673672

674673
let dunder_next_method = iterator_ty.to_meta_type(db).member(db, "__next__");
675674
return dunder_next_method
676-
.call(db, &[])
675+
.call(db, &[self])
677676
.return_ty(db)
678677
.map(|element_ty| IterationOutcome::Iterable { element_ty })
679678
.unwrap_or(IterationOutcome::NotIterable {
@@ -690,7 +689,7 @@ impl<'db> Type<'db> {
690689
let dunder_get_item_method = iterable_meta_type.member(db, "__getitem__");
691690

692691
dunder_get_item_method
693-
.call(db, &[])
692+
.call(db, &[self, builtins_symbol_ty(db, "int").to_instance(db)])
694693
.return_ty(db)
695694
.map(|element_ty| IterationOutcome::Iterable { element_ty })
696695
.unwrap_or(IterationOutcome::NotIterable {
@@ -840,11 +839,11 @@ impl<'db> CallOutcome<'db> {
840839
/// Create a new `CallOutcome::Union` with given wrapped outcomes.
841840
fn union(
842841
called_ty: Type<'db>,
843-
outcomes: impl Into<Box<[CallOutcome<'db>]>>,
842+
outcomes: impl IntoIterator<Item = CallOutcome<'db>>,
844843
) -> CallOutcome<'db> {
845844
CallOutcome::Union {
846845
called_ty,
847-
outcomes: outcomes.into(),
846+
outcomes: outcomes.into_iter().collect(),
848847
}
849848
}
850849

0 commit comments

Comments
 (0)