diff options
author | John Hodge <tpg@mutabah.net> | 2016-07-12 17:42:53 +1000 |
---|---|---|
committer | John Hodge <tpg@mutabah.net> | 2016-07-12 17:42:53 +1000 |
commit | fa7bc272c17a1fa4401ae3733984e338ff95443b (patch) | |
tree | 4ad877c876462ebb571e110f4b6c171a7e9c8014 /src/hir/type.cpp | |
parent | a7fb52b0e1f2a0159a986b25b10241655b56c077 (diff) | |
download | mrust-fa7bc272c17a1fa4401ae3733984e338ff95443b.tar.gz |
HIR Typecheck - Handle more complex impl bindings
Diffstat (limited to 'src/hir/type.cpp')
-rw-r--r-- | src/hir/type.cpp | 14 |
1 files changed, 6 insertions, 8 deletions
diff --git a/src/hir/type.cpp b/src/hir/type.cpp index ae49f3db..46ecf229 100644 --- a/src/hir/type.cpp +++ b/src/hir/type.cpp @@ -297,12 +297,10 @@ bool ::HIR::TypeRef::match_test_generics(const Span& sp, const ::HIR::TypeRef& x } ::HIR::Compare HIR::TypeRef::match_test_generics_fuzz(const Span& sp, const ::HIR::TypeRef& x_in, t_cb_resolve_type resolve_placeholder, t_cb_match_generics callback) const { - if( m_data.is_Infer() ) { - BUG(sp, "Encountered '_' as this - " << *this); - } if( m_data.is_Generic() ) { return callback(m_data.as_Generic().binding, x_in); } + const auto& v = (this->m_data.is_Infer() ? resolve_placeholder(*this) : *this); const auto& x = (x_in.m_data.is_Infer() || x_in.m_data.is_Generic() ? resolve_placeholder(x_in) : x_in); TU_IFLET(::HIR::TypeRef::Data, x.m_data, Infer, xe, switch(xe.ty_class) @@ -312,7 +310,7 @@ bool ::HIR::TypeRef::match_test_generics(const Span& sp, const ::HIR::TypeRef& x //return true; return Compare::Fuzzy; case ::HIR::InferClass::Integer: - TU_IFLET(::HIR::TypeRef::Data, m_data, Primitive, te, + TU_IFLET(::HIR::TypeRef::Data, v.m_data, Primitive, te, switch(te) { case ::HIR::CoreType::I8: case ::HIR::CoreType::U8: @@ -329,7 +327,7 @@ bool ::HIR::TypeRef::match_test_generics(const Span& sp, const ::HIR::TypeRef& x ) break; case ::HIR::InferClass::Float: - TU_IFLET(::HIR::TypeRef::Data, m_data, Primitive, te, + TU_IFLET(::HIR::TypeRef::Data, v.m_data, Primitive, te, switch(te) { case ::HIR::CoreType::F32: @@ -344,11 +342,11 @@ bool ::HIR::TypeRef::match_test_generics(const Span& sp, const ::HIR::TypeRef& x break; } ) - if( m_data.tag() != x.m_data.tag() ) { - DEBUG("- Tag mismatch " << *this << " and " << x); + if( v.m_data.tag() != x.m_data.tag() ) { + DEBUG("- Tag mismatch " << v << " and " << x); return Compare::Unequal; } - TU_MATCH(::HIR::TypeRef::Data, (m_data, x.m_data), (te, xe), + TU_MATCH(::HIR::TypeRef::Data, (v.m_data, x.m_data), (te, xe), (Infer, throw "";), (Generic, throw "";), (Primitive, |