diff options
author | John Hodge <tpg@mutabah.net> | 2016-09-23 08:41:31 +0800 |
---|---|---|
committer | John Hodge <tpg@mutabah.net> | 2016-09-23 08:41:31 +0800 |
commit | 2fa482cbc18890d9bbbae10c20e0cb1d964c0516 (patch) | |
tree | 9a27a8100d17dfbb4a0078d3079a2fe7a6233edf /src | |
parent | 79863239ffe60599f23657a92187922893caa855 (diff) | |
download | mrust-2fa482cbc18890d9bbbae10c20e0cb1d964c0516.tar.gz |
HIR Typecheck Expr - _PathValue UfcsInherent with ivars
Diffstat (limited to 'src')
-rw-r--r-- | src/hir_typeck/expr_cs.cpp | 22 |
1 files changed, 12 insertions, 10 deletions
diff --git a/src/hir_typeck/expr_cs.cpp b/src/hir_typeck/expr_cs.cpp index 61bf6886..5d09e90c 100644 --- a/src/hir_typeck/expr_cs.cpp +++ b/src/hir_typeck/expr_cs.cpp @@ -1422,19 +1422,14 @@ namespace { ) ), (UfcsInherent, - // TODO: If ivars are valid within the type of this UFCS, then resolution has to be deferred until iteration - // - If they're not valid, then resolution can be done here. - ASSERT_BUG(sp, !this->context.m_ivars.type_contains_ivars(*e.type), "Found ivar in UfcsInherent"); + // TODO: Share code with visit_call_populate_cache // - Locate function (and impl block) const ::HIR::Function* fcn_ptr = nullptr; const ::HIR::TypeImpl* impl_ptr = nullptr; - this->context.m_crate.find_type_impls(*e.type, [&](const auto& ty)->const auto& { - if( ty.m_data.is_Infer() ) - return this->context.get_type(ty); - else - return ty; - }, + // TODO: Support mutiple matches here (if there's a fuzzy match) and retry if so + unsigned int count = 0; + this->context.m_crate.find_type_impls(*e.type, context.m_ivars.callback_resolve_infer(), [&](const auto& impl) { DEBUG("- impl" << impl.m_params.fmt_args() << " " << impl.m_type); auto it = impl.m_methods.find(e.item); @@ -1442,11 +1437,16 @@ namespace { return false; fcn_ptr = &it->second.data; impl_ptr = &impl; - return true; + count += 1; + return false; + //return true; }); if( !fcn_ptr ) { ERROR(sp, E0000, "Failed to locate function " << node.m_path); } + if( count > 1 ) { + TODO(sp, "Revisit _PathValue when UfcsInherent has multiple options - " << node.m_path); + } assert(impl_ptr); fix_param_count(sp, this->context, node.m_path, fcn_ptr->m_params, e.params); @@ -1490,6 +1490,8 @@ namespace { } }; + // TODO: Impl/method type bounds + ::HIR::FunctionType ft { fcn_ptr->m_unsafe, fcn_ptr->m_abi, box$( monomorphise_type_with(sp, fcn_ptr->m_return, monomorph_cb) ), |