[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.
This commit is contained in:
Matthew Mckee 2025-08-06 23:24:59 +01:00 committed by GitHub
parent 98df62db79
commit ef1802b94f
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 8 additions and 4 deletions

View File

@ -1044,7 +1044,11 @@ impl<'db> ClassType<'db> {
.place;
if let Place::Type(Type::FunctionLiteral(new_function), _) = new_function_symbol {
new_function.into_bound_method_type(db, self_ty)
Type::Callable(
new_function
.into_bound_method_type(db, self_ty)
.into_callable_type(db),
)
} else {
// Fallback if no `object.__new__` is found.
CallableType::single(

View File

@ -800,13 +800,13 @@ impl<'db> FunctionType<'db> {
CallableType::new(db, self.signature(db), false)
}
/// Convert the `FunctionType` into a [`Type::BoundMethod`].
/// Convert the `FunctionType` into a [`BoundMethodType`].
pub(crate) fn into_bound_method_type(
self,
db: &'db dyn Db,
self_instance: Type<'db>,
) -> Type<'db> {
Type::BoundMethod(BoundMethodType::new(db, self, self_instance))
) -> BoundMethodType<'db> {
BoundMethodType::new(db, self, self_instance)
}
pub(crate) fn has_relation_to(