mirror of https://github.com/astral-sh/ruff
generic
This commit is contained in:
parent
94aca37ca8
commit
b90cdfc2f7
|
|
@ -1772,7 +1772,7 @@ impl<'db> Type<'db> {
|
|||
}
|
||||
}
|
||||
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)),
|
||||
|
|
|
|||
|
|
@ -1126,6 +1126,9 @@ impl<'db> ClassType<'db> {
|
|||
/// constructor signature of this class.
|
||||
#[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> {
|
||||
let (class_literal, _) = self.class_literal(db);
|
||||
let generic_context = class_literal.generic_context(db);
|
||||
|
||||
let self_ty = Type::from(self);
|
||||
let metaclass_dunder_call_function_symbol = self_ty
|
||||
.member_lookup_with_policy(
|
||||
|
|
@ -1222,9 +1225,13 @@ impl<'db> ClassType<'db> {
|
|||
});
|
||||
let return_type = self_annotation.unwrap_or(correct_return_type);
|
||||
let instance_ty = self_annotation.unwrap_or_else(|| Type::instance(db, self));
|
||||
Signature::new(signature.parameters().clone(), Some(return_type))
|
||||
.with_definition(signature.definition())
|
||||
.bind_self(db, Some(instance_ty))
|
||||
Signature::new_generic(
|
||||
generic_context,
|
||||
signature.parameters().clone(),
|
||||
Some(return_type),
|
||||
)
|
||||
.with_definition(signature.definition())
|
||||
.bind_self(db, Some(instance_ty))
|
||||
};
|
||||
|
||||
let synthesized_dunder_init_signature = CallableSignature::from_overloads(
|
||||
|
|
|
|||
Loading…
Reference in New Issue