Skip to content

Commit ef1802b

Browse files
[ty] Repurpose FunctionType.into_bound_method_type to return BoundMethodType (#19793)
## Summary As per our naming scheme (at least for callable types) this should return a `BoundMethodType`, or be renamed, but it makes more sense to change the return type. I also ensure `ClassType.into_callable` returns a `Type::Callable` in the changed branch. Ideally we could return a `CallableType` from these `into_callable` functions (and rename to `into_callable_type` but because of unions we cannot do this.
1 parent 98df62d commit ef1802b

File tree

2 files changed

+8
-4
lines changed

2 files changed

+8
-4
lines changed

crates/ty_python_semantic/src/types/class.rs

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1044,7 +1044,11 @@ impl<'db> ClassType<'db> {
10441044
.place;
10451045

10461046
if let Place::Type(Type::FunctionLiteral(new_function), _) = new_function_symbol {
1047-
new_function.into_bound_method_type(db, self_ty)
1047+
Type::Callable(
1048+
new_function
1049+
.into_bound_method_type(db, self_ty)
1050+
.into_callable_type(db),
1051+
)
10481052
} else {
10491053
// Fallback if no `object.__new__` is found.
10501054
CallableType::single(

crates/ty_python_semantic/src/types/function.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -800,13 +800,13 @@ impl<'db> FunctionType<'db> {
800800
CallableType::new(db, self.signature(db), false)
801801
}
802802

803-
/// Convert the `FunctionType` into a [`Type::BoundMethod`].
803+
/// Convert the `FunctionType` into a [`BoundMethodType`].
804804
pub(crate) fn into_bound_method_type(
805805
self,
806806
db: &'db dyn Db,
807807
self_instance: Type<'db>,
808-
) -> Type<'db> {
809-
Type::BoundMethod(BoundMethodType::new(db, self, self_instance))
808+
) -> BoundMethodType<'db> {
809+
BoundMethodType::new(db, self, self_instance)
810810
}
811811

812812
pub(crate) fn has_relation_to(

0 commit comments

Comments
 (0)