diff --git a/crates/ty_python_semantic/src/types.rs b/crates/ty_python_semantic/src/types.rs index 21246a75d7..71e7ab5798 100644 --- a/crates/ty_python_semantic/src/types.rs +++ b/crates/ty_python_semantic/src/types.rs @@ -1104,7 +1104,9 @@ impl<'db> Type<'db> { Type::FunctionLiteral(function_literal) => { Some(Type::Callable(function_literal.into_callable_type(db))) } - Type::BoundMethod(bound_method) => Some(bound_method.into_callable_type(db)), + Type::BoundMethod(bound_method) => { + Some(Type::Callable(bound_method.into_callable_type(db))) + } Type::NominalInstance(_) | Type::ProtocolInstance(_) => { let call_symbol = self @@ -7166,8 +7168,8 @@ fn walk_bound_method_type<'db, V: visitor::TypeVisitor<'db> + ?Sized>( } impl<'db> BoundMethodType<'db> { - pub(crate) fn into_callable_type(self, db: &'db dyn Db) -> Type<'db> { - Type::Callable(CallableType::new( + pub(crate) fn into_callable_type(self, db: &'db dyn Db) -> CallableType<'db> { + CallableType::new( db, CallableSignature::from_overloads( self.function(db) @@ -7177,7 +7179,7 @@ impl<'db> BoundMethodType<'db> { .map(signatures::Signature::bind_self), ), false, - )) + ) } fn normalized_impl(self, db: &'db dyn Db, visitor: &mut TypeTransformer<'db>) -> Self { diff --git a/crates/ty_python_semantic/src/types/class.rs b/crates/ty_python_semantic/src/types/class.rs index c7ab016c85..fd64f5e204 100644 --- a/crates/ty_python_semantic/src/types/class.rs +++ b/crates/ty_python_semantic/src/types/class.rs @@ -602,7 +602,7 @@ impl<'db> ClassType<'db> { // https://typing.python.org/en/latest/spec/constructors.html#converting-a-constructor-to-callable // by always respecting the signature of the metaclass `__call__`, rather than // using a heuristic which makes unwarranted assumptions to sometimes ignore it. - return metaclass_dunder_call_function.into_callable_type(db); + return Type::Callable(metaclass_dunder_call_function.into_callable_type(db)); } let dunder_new_function_symbol = self_ty diff --git a/crates/ty_python_semantic/src/types/function.rs b/crates/ty_python_semantic/src/types/function.rs index 0a814f8e13..189ea9dd12 100644 --- a/crates/ty_python_semantic/src/types/function.rs +++ b/crates/ty_python_semantic/src/types/function.rs @@ -766,7 +766,7 @@ impl<'db> FunctionType<'db> { self.literal(db).signature(db, self.type_mappings(db)) } - /// Convert the `FunctionType` into a [`Type::Callable`]. + /// Convert the `FunctionType` into a [`CallableType`]. pub(crate) fn into_callable_type(self, db: &'db dyn Db) -> CallableType<'db> { CallableType::new(db, self.signature(db), false) }