diff options
author | John Hodge <tpg@mutabah.net> | 2016-07-17 12:51:06 +0800 |
---|---|---|
committer | John Hodge <tpg@mutabah.net> | 2016-07-17 12:51:06 +0800 |
commit | c9c325b294db270a093f652fa7aced682a5c183c (patch) | |
tree | 1b479471440124424b28d643bd94d61daf4bfbdf /src | |
parent | 923d403d45dbcfe4d02c0fd2923ef97760ff1659 (diff) | |
download | mrust-c9c325b294db270a093f652fa7aced682a5c183c.tar.gz |
HIR Typecheck - Building set of type equalities
Diffstat (limited to 'src')
-rw-r--r-- | src/hir_typeck/helpers.cpp | 29 |
1 files changed, 28 insertions, 1 deletions
diff --git a/src/hir_typeck/helpers.cpp b/src/hir_typeck/helpers.cpp index fd5533e4..345e8943 100644 --- a/src/hir_typeck/helpers.cpp +++ b/src/hir_typeck/helpers.cpp @@ -942,16 +942,43 @@ bool HMTypeInferrence::types_equal(const ::HIR::TypeRef& rl, const ::HIR::TypeRe // ------------------------------------------------------------------------------------------------------------------- void TraitResolution::prep_indexes() { + static Span sp; this->iterate_bounds([&](const auto& b) { TU_MATCH_DEF(::HIR::GenericBound, (b), (be), ( ), (TraitBound, + DEBUG("[prep_indexes] `" << be.type << " : " << be.trait); for( const auto& tb : be.trait.m_type_bounds ) { - DEBUG("Equality (TB) - <" << be.type << " as " << be.trait.m_path << ">::" << tb.first << " = " << tb.second); + DEBUG("[prep_indexes] Equality (TB) - <" << be.type << " as " << be.trait.m_path << ">::" << tb.first << " = " << tb.second); auto ty_l = ::HIR::TypeRef( ::HIR::Path( be.type.clone(), be.trait.m_path.clone(), tb.first ) ); this->m_type_equalities.insert( ::std::make_pair( mv$(ty_l), tb.second.clone() ) ); } + + const auto& trait = m_crate.get_trait_by_path(sp, be.trait.m_path.m_path); + for(const auto& a_ty : trait.m_types) + { + //auto ty_a = ::HIR::TypeRef( ::HIR::Path( be.type.clone(), be.trait.m_path.clone(), ty_a.first ) ); + for( const auto& a_ty_b : a_ty.second.m_params.m_bounds ) { + TU_MATCH_DEF(::HIR::GenericBound, (a_ty_b), (a_ty_be), + ( + ), + (TraitBound, + DEBUG("[prep_indexes] (Assoc) `" << a_ty_be.type << " : " << a_ty_be.trait); + for( const auto& tb : a_ty_be.trait.m_type_bounds ) { + DEBUG("[prep_indexes] Equality (ATB) - <" << a_ty_be.type << " as " << a_ty_be.trait.m_path << ">::" << tb.first << " = " << tb.second); + //auto ty_l = ::HIR::TypeRef( ::HIR::Path( a_ty_be.type.clone(), a_ty_be.trait.m_path.clone(), tb.first ) ); + //ty_l = monomorphise_type_with(sp, mv$(ty_l), [&](const auto& ty) { + // const auto& ge = ty.m_data.as_Generic(); + // assert(ge.binding == 0xFFFF); + // return ty_a; + // }); + //this->m_type_equalities.insert( ::std::make_pair( mv$(ty_l), tb.second.clone() ) ); + } + ) + ) + } + } ), (TypeEquality, DEBUG("Equality - " << be.type << " = " << be.other_type); |