diff options
author | John Hodge <tpg@mutabah.net> | 2016-09-28 21:38:07 +0800 |
---|---|---|
committer | John Hodge <tpg@mutabah.net> | 2016-09-28 21:38:07 +0800 |
commit | 67244fb57c3b1002dc22ea9fb393e660cb000fd1 (patch) | |
tree | 99ceae14bd4caae96f3bb6d1026a853766679eee /src | |
parent | a8b03dcb6af53f403c26683c6eb56cdf1d047020 (diff) | |
download | mrust-67244fb57c3b1002dc22ea9fb393e660cb000fd1.tar.gz |
HIR Typecheck Expr - Rough up support for autoderef in _CallValue
Diffstat (limited to 'src')
-rw-r--r-- | src/hir_typeck/expr_cs.cpp | 24 |
1 files changed, 20 insertions, 4 deletions
diff --git a/src/hir_typeck/expr_cs.cpp b/src/hir_typeck/expr_cs.cpp index 6af70d30..8b4cc3a1 100644 --- a/src/hir_typeck/expr_cs.cpp +++ b/src/hir_typeck/expr_cs.cpp @@ -1999,8 +1999,17 @@ namespace { } void visit(::HIR::ExprNode_CallValue& node) override { const auto& sp = node.span(); - const auto& ty = this->context.get_type(node.m_value->m_res_type); - TRACE_FUNCTION_F("CallValue: ty=" << ty); + const auto& ty_o = this->context.get_type(node.m_value->m_res_type); + TRACE_FUNCTION_F("CallValue: ty=" << ty_o); + + unsigned int deref_count = 0; + const auto* ty_p = &ty_o; + while(ty_p->m_data.is_Borrow()) + { + deref_count ++; + ty_p = &this->context.get_type(*ty_p->m_data.as_Borrow().inner); + } + const auto& ty = *ty_p; TU_MATCH_DEF(decltype(ty.m_data), (ty.m_data), (e), ( @@ -2099,8 +2108,9 @@ namespace { node.m_trait_used = ::HIR::ExprNode_CallValue::TraitUsed::Fn; ), (Borrow, - // TODO: Locate trait impl via borrow - TODO(sp, "CallValue on an &-ptr"); + // - Check inner (recursively) + // > use upper + TODO(sp, "CallValue on an &-ptr - " << ty); return ; ), (Infer, @@ -2108,6 +2118,12 @@ namespace { return ; ) ) + + if( deref_count > 0 ) + { + TODO(sp, "Insert autoderef for CallValue (" << deref_count << " needed) - " << ty << " and " << ty_o); + } + assert( node.m_arg_types.size() == node.m_args.size() + 1 ); for(unsigned int i = 0; i < node.m_args.size(); i ++) { |