First attempt at generic type inference for fns

This commit is contained in:
Marcus Klaas de Vries
2019-01-25 21:16:02 +01:00
parent 3f4f50baaa
commit 3bd47c0285
6 changed files with 81 additions and 21 deletions

View File

@@ -32,7 +32,7 @@ impl FnSignature {
.name()
.map(|n| n.as_name())
.unwrap_or_else(Name::missing);
let mut params = Vec::new();
let mut args = Vec::new();
let mut has_self_param = false;
if let Some(param_list) = node.param_list() {
if let Some(self_param) = param_list.self_param() {
@@ -50,12 +50,12 @@ impl FnSignature {
}
}
};
params.push(self_type);
args.push(self_type);
has_self_param = true;
}
for param in param_list.params() {
let type_ref = TypeRef::from_ast_opt(param.type_ref());
params.push(type_ref);
args.push(type_ref);
}
}
let ret_type = if let Some(type_ref) = node.ret_type().and_then(|rt| rt.type_ref()) {
@@ -66,7 +66,7 @@ impl FnSignature {
let sig = FnSignature {
name,
params,
args,
ret_type,
has_self_param,
};