diff options
author | John Hodge <tpg@mutabah.net> | 2017-01-07 17:39:37 +0800 |
---|---|---|
committer | John Hodge <tpg@mutabah.net> | 2017-01-07 17:39:37 +0800 |
commit | 6c9b3ac1b56ba4333ca71023962f50e250b3ace1 (patch) | |
tree | 288aa57308d0dd4e65558f149873f9090598b65d | |
parent | 243dc219d63e9f003b964090db52c80027bc99e8 (diff) | |
download | mrust-6c9b3ac1b56ba4333ca71023962f50e250b3ace1.tar.gz |
HIR Typecheck Expr - Handle coercing to trait objects with foreign associated types
-rw-r--r-- | src/hir_typeck/helpers.cpp | 15 |
1 files changed, 12 insertions, 3 deletions
diff --git a/src/hir_typeck/helpers.cpp b/src/hir_typeck/helpers.cpp index ac94909d..92c084b4 100644 --- a/src/hir_typeck/helpers.cpp +++ b/src/hir_typeck/helpers.cpp @@ -1097,8 +1097,18 @@ bool TraitResolution::find_trait_impls(const Span& sp, return false; total_cmp &= cmp; tmp_e.m_trait.m_path.m_params = impl.get_trait_params(); - for(const auto& aty : e.m_trait.m_type_bounds) - tmp_e.m_trait.m_type_bounds[aty.first] = impl.get_type(aty.first.c_str()); + for(const auto& aty : e.m_trait.m_type_bounds) { + auto atyv = impl.get_type(aty.first.c_str()); + if( atyv == ::HIR::TypeRef() ) + { + // Get the trait from which this associated type comes. + // Insert a UfcsKnown path for that + auto p = ::HIR::Path( ty.clone(), e.m_trait.m_path.clone(), aty.first ); + // Run EAT + atyv = this->expand_associated_types( sp, ::HIR::TypeRef::new_path( mv$(p), {} ) ); + } + tmp_e.m_trait.m_type_bounds[aty.first] = mv$(atyv); + } return true; }); } @@ -1116,7 +1126,6 @@ bool TraitResolution::find_trait_impls(const Span& sp, good &= find_trait_impls(sp, marker.m_path, marker.m_params, ty, cb); } if( good ) { - // TODO: params.clone() isn't quite right. ::HIR::PathParams real_params { ::HIR::TypeRef( ::HIR::TypeRef::Data(mv$(tmp_e)) ) }; return callback( ImplRef(type.clone(), mv$(real_params), {}), total_cmp ); } |