Prefer hir::SelfParam and fix signature help of methods from macros

This commit is contained in:
oxalica 2023-08-09 02:42:08 +08:00
parent 6a2f83a8a2
commit de86444756
No known key found for this signature in database
GPG key ID: D425CB23CADE82D9
3 changed files with 27 additions and 7 deletions

View file

@ -4406,14 +4406,13 @@ impl Callable {
Other => CallableKind::Other,
}
}
pub fn receiver_param(&self, db: &dyn HirDatabase) -> Option<(ast::SelfParam, Type)> {
pub fn receiver_param(&self, db: &dyn HirDatabase) -> Option<(SelfParam, Type)> {
let func = match self.callee {
Callee::Def(CallableDefId::FunctionId(it)) if self.is_bound_method => it,
_ => return None,
};
let src = func.lookup(db.upcast()).source(db.upcast());
let param_list = src.value.param_list()?;
Some((param_list.self_param()?, self.ty.derived(self.sig.params()[0].clone())))
let func = Function { id: func };
Some((func.self_param(db)?, self.ty.derived(self.sig.params()[0].clone())))
}
pub fn n_params(&self) -> usize {
self.sig.params().len() - if self.is_bound_method { 1 } else { 0 }