Fix inferring bug

This commit is contained in:
Shunsuke Shibayama 2022-10-14 09:46:42 +09:00
parent d0fa924ea8
commit 7776297de2
2 changed files with 37 additions and 23 deletions

View file

@ -919,6 +919,19 @@ impl Context {
if sub == Type::Never {
return Ok(proj(lhs, rhs));
}
// in Methods
if self.name == sub.qual_name() {
if let Ok(obj) = self.get_const_local(&Token::symbol(&rhs), &self.name) {
if let ValueObj::Type(quant_t) = obj {
let subst_ctx = SubstContext::new(&sub, self, t_loc);
let t = subst_ctx.substitute(quant_t.typ().clone())?;
let t = self.eval_t_params(t, level, t_loc)?;
return Ok(t);
} else {
todo!()
}
}
}
for ty_ctx in self.get_nominal_super_type_ctxs(&sub).ok_or_else(|| {
EvalError::no_var_error(
self.cfg.input.clone(),