This commit is contained in:
Douglas Creager 2025-12-03 12:36:55 -05:00
parent 94aca37ca8
commit b90cdfc2f7
2 changed files with 11 additions and 4 deletions

View File

@ -1772,7 +1772,7 @@ impl<'db> Type<'db> {
} }
} }
Type::ClassLiteral(class_literal) => { Type::ClassLiteral(class_literal) => {
Some(class_literal.default_specialization(db).into_callable(db)) Some(class_literal.identity_specialization(db).into_callable(db))
} }
Type::GenericAlias(alias) => Some(ClassType::Generic(alias).into_callable(db)), Type::GenericAlias(alias) => Some(ClassType::Generic(alias).into_callable(db)),

View File

@ -1126,6 +1126,9 @@ impl<'db> ClassType<'db> {
/// constructor signature of this class. /// constructor signature of this class.
#[salsa::tracked(cycle_initial=into_callable_cycle_initial, heap_size=ruff_memory_usage::heap_size)] #[salsa::tracked(cycle_initial=into_callable_cycle_initial, heap_size=ruff_memory_usage::heap_size)]
pub(super) fn into_callable(self, db: &'db dyn Db) -> CallableTypes<'db> { pub(super) fn into_callable(self, db: &'db dyn Db) -> CallableTypes<'db> {
let (class_literal, _) = self.class_literal(db);
let generic_context = class_literal.generic_context(db);
let self_ty = Type::from(self); let self_ty = Type::from(self);
let metaclass_dunder_call_function_symbol = self_ty let metaclass_dunder_call_function_symbol = self_ty
.member_lookup_with_policy( .member_lookup_with_policy(
@ -1222,9 +1225,13 @@ impl<'db> ClassType<'db> {
}); });
let return_type = self_annotation.unwrap_or(correct_return_type); let return_type = self_annotation.unwrap_or(correct_return_type);
let instance_ty = self_annotation.unwrap_or_else(|| Type::instance(db, self)); let instance_ty = self_annotation.unwrap_or_else(|| Type::instance(db, self));
Signature::new(signature.parameters().clone(), Some(return_type)) Signature::new_generic(
.with_definition(signature.definition()) generic_context,
.bind_self(db, Some(instance_ty)) signature.parameters().clone(),
Some(return_type),
)
.with_definition(signature.definition())
.bind_self(db, Some(instance_ty))
}; };
let synthesized_dunder_init_signature = CallableSignature::from_overloads( let synthesized_dunder_init_signature = CallableSignature::from_overloads(