diff options
author | John Hodge <tpg@mutabah.net> | 2016-07-05 23:53:36 +0800 |
---|---|---|
committer | John Hodge <tpg@mutabah.net> | 2016-07-05 23:53:36 +0800 |
commit | d17d5052766c3cec96bb226efcb60c367b7484f7 (patch) | |
tree | b215dbec7552386a9188f590cc140bdd006281c4 /src | |
parent | 005eda08c57c8bb2dcad96e9b8909babff906b4b (diff) | |
download | mrust-d17d5052766c3cec96bb226efcb60c367b7484f7.tar.gz |
HIR Typecheck CS - Method handling tweaks
Diffstat (limited to 'src')
-rw-r--r-- | src/hir_typeck/expr_cs.cpp | 5 | ||||
-rw-r--r-- | src/hir_typeck/helpers.cpp | 11 |
2 files changed, 12 insertions, 4 deletions
diff --git a/src/hir_typeck/expr_cs.cpp b/src/hir_typeck/expr_cs.cpp index 7e14dc87..c304654b 100644 --- a/src/hir_typeck/expr_cs.cpp +++ b/src/hir_typeck/expr_cs.cpp @@ -1237,13 +1237,14 @@ namespace { } void visit(::HIR::ExprNode_CallMethod& node) override { const auto& ty = this->context.get_type(node.m_value->m_res_type); - //const auto ty = this->context.expand_associated_types(node.span(), this->context.get_type(node.m_value->m_res_type).clone()); - DEBUG("(CallMethod) ty = " << ty); + //const auto ty = this->context.m_resolve.expand_associated_types(node.span(), this->context.get_type(node.m_value->m_res_type).clone()); + TRACE_FUNCTION_F("(CallMethod) ty = " << this->context.m_ivars.fmt_type(ty)); // Using autoderef, locate this method on the type ::HIR::Path fcn_path { ::HIR::SimplePath() }; unsigned int deref_count = this->context.m_resolve.autoderef_find_method(node.span(), node.m_traits, ty, node.m_method, fcn_path); if( deref_count != ~0u ) { + DEBUG("- deref_count = " << deref_count); visit_call_populate_cache(this->context, node.span(), fcn_path, node.m_cache); assert( node.m_cache.m_arg_types.size() >= 1); diff --git a/src/hir_typeck/helpers.cpp b/src/hir_typeck/helpers.cpp index 238b2cac..a44d8608 100644 --- a/src/hir_typeck/helpers.cpp +++ b/src/hir_typeck/helpers.cpp @@ -1499,8 +1499,15 @@ unsigned int TraitResolution::autoderef_find_method(const Span& sp, const HIR::t ) // Dereference failed! This is a hard error (hitting _ is checked above and returns ~0) - this->m_ivars.dump(); - TODO(sp, "Error when no method could be found, but type is known - (: " << top_ty << ")." << method_name); + if( this->m_ivars.type_contains_ivars(top_ty) ) + { + return ~0u; + } + else + { + this->m_ivars.dump(); + TODO(sp, "Error when no method could be found, but type is known - (: " << top_ty << ")." << method_name); + } } bool TraitResolution::find_method(const Span& sp, const HIR::t_trait_list& traits, const ::HIR::TypeRef& ty, const ::std::string& method_name, /* Out -> */::HIR::Path& fcn_path) const |