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) => {
|
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)),
|
||||||
|
|
|
||||||
|
|
@ -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,7 +1225,11 @@ 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(
|
||||||
|
generic_context,
|
||||||
|
signature.parameters().clone(),
|
||||||
|
Some(return_type),
|
||||||
|
)
|
||||||
.with_definition(signature.definition())
|
.with_definition(signature.definition())
|
||||||
.bind_self(db, Some(instance_ty))
|
.bind_self(db, Some(instance_ty))
|
||||||
};
|
};
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue