chore(frontends/lean/elaborator): cleanup ensure fun

This commit is contained in:
Leonardo de Moura 2015-05-20 15:10:45 -07:00
parent af3f0088f4
commit 608984cd4c

View file

@ -385,18 +385,13 @@ pair<expr, expr> elaborator::ensure_fun(expr f, constraint_seq & cs) {
expr f_type = infer_type(f, cs); expr f_type = infer_type(f, cs);
if (!is_pi(f_type)) if (!is_pi(f_type))
f_type = whnf(f_type, cs); f_type = whnf(f_type, cs);
if (!is_pi(f_type) && has_metavar(f_type)) { if (is_pi(f_type)) {
constraint_seq saved_cs = cs; erase_coercion_info(f);
expr new_f_type = whnf(f_type, cs); } else {
if (!is_pi(new_f_type) && m_tc->is_stuck(new_f_type)) { if (m_tc->is_stuck(f_type)) {
cs = saved_cs; f_type = m_tc->ensure_pi(f_type, f, cs);
// let type checker add constraint erase_coercion_info(f);
f_type = m_tc->ensure_pi(f_type, f, cs);
} else { } else {
f_type = new_f_type;
}
}
if (!is_pi(f_type)) {
// try coercion to function-class // try coercion to function-class
list<expr> coes = get_coercions_to_fun(env(), f_type); list<expr> coes = get_coercions_to_fun(env(), f_type);
if (is_nil(coes)) { if (is_nil(coes)) {
@ -435,8 +430,7 @@ pair<expr, expr> elaborator::ensure_fun(expr f, constraint_seq & cs) {
f_type = m_tc->ensure_pi(f_type, f, cs); f_type = m_tc->ensure_pi(f_type, f, cs);
lean_assert(is_pi(f_type)); lean_assert(is_pi(f_type));
} }
} else { }
erase_coercion_info(f);
} }
lean_assert(is_pi(f_type)); lean_assert(is_pi(f_type));
return mk_pair(f, f_type); return mk_pair(f, f_type);