diff options
author | John Hodge <tpg@mutabah.net> | 2016-11-18 11:00:12 +0800 |
---|---|---|
committer | John Hodge <tpg@mutabah.net> | 2016-11-18 11:00:12 +0800 |
commit | 2fe8d6af673577c7289efb3b51e93acfc360237e (patch) | |
tree | 18eadd599d6c235d38dbe183d0c2229fae4e72d4 | |
parent | 6a4bf8a5ac9c37fe98d8bb29ea265c73e595809c (diff) | |
download | mrust-2fe8d6af673577c7289efb3b51e93acfc360237e.tar.gz |
HIR Typecheck Static - Convert a fuzzy into a concrete in EAT
-rw-r--r-- | src/hir_typeck/static.cpp | 21 |
1 files changed, 19 insertions, 2 deletions
diff --git a/src/hir_typeck/static.cpp b/src/hir_typeck/static.cpp index 4bb87f1d..651f0cfe 100644 --- a/src/hir_typeck/static.cpp +++ b/src/hir_typeck/static.cpp @@ -826,9 +826,26 @@ void StaticTraitResolve::expand_associated_types__UfcsKnown(const Span& sp, ::HI ::ImplRef best_impl; rv = this->find_impl(sp, trait_path.m_path, trait_path.m_params, *e2.type, [&](auto impl, bool fuzzy) { DEBUG("[expand_associated_types] Found " << impl); + // If a fuzzy match was found, monomorphise and EAT the checked types and try again + // - A fuzzy can be caused by an opaque match. + // - TODO: Move this logic into `find_impl` if( fuzzy ) { - DEBUG("[expand_associated_types] - Fuzzy"); - return false; + DEBUG("[expand_associated_types] - Fuzzy, monomorph+expand and recheck"); + + auto impl_ty = impl.get_impl_type(); + this->expand_associated_types(sp, impl_ty); + if(impl_ty != *e2.type) { + DEBUG("[expand_associated_types] - Fuzzy - Doesn't match"); + return false; + } + auto pp = impl.get_trait_params(); + for(auto& ty : pp.m_types) + this->expand_associated_types(sp, ty); + if( pp != trait_path.m_params ) { + DEBUG("[expand_associated_types] - Fuzzy - Doesn't match"); + return false; + } + DEBUG("[expand_associated_types] - Fuzzy - Actually matches"); } if( impl.type_is_specialisable(e2.item.c_str()) ) { |