From 5c1d99a384f67c3d186289bc295c958ccba52721 Mon Sep 17 00:00:00 2001 From: John Hodge Date: Tue, 22 Nov 2016 20:35:33 +0800 Subject: HIR Typecheck - Expand assocated types in outer typecheck --- src/hir_typeck/outer.cpp | 64 +++++++++++++---------------------------------- src/hir_typeck/static.cpp | 11 ++++++-- 2 files changed, 26 insertions(+), 49 deletions(-) diff --git a/src/hir_typeck/outer.cpp b/src/hir_typeck/outer.cpp index 4b4e802d..ed2063d4 100644 --- a/src/hir_typeck/outer.cpp +++ b/src/hir_typeck/outer.cpp @@ -265,50 +265,8 @@ namespace { TODO(sp, "Locate impl block for UFCS Inherent"); ), (UfcsKnown, - DEBUG("UfcsKnown - " << ty); - if( pe.type->m_data.is_Path() && pe.type->m_data.as_Path().binding.is_Opaque() ) { - // - Opaque type, opaque result - DEBUG("Inner type opaque, assuming " << ty << " also opaque"); - e.binding = ::HIR::TypeRef::TypePathBinding::make_Opaque({}); - } - else if( pe.type->m_data.is_Generic() ) { - // - Generic type, opaque resut. (TODO: Sometimes these are known - via generic bounds) - e.binding = ::HIR::TypeRef::TypePathBinding::make_Opaque({}); - } - else { - ImplRef best_impl; - m_resolve.find_impl(sp, pe.trait.m_path, pe.trait.m_params, *pe.type, [&](auto impl, bool fuzzy) { - DEBUG("[visit_type] Found " << impl); - if(fuzzy) - TODO(sp, "What error should be used when an impl matches fuzzily in outer?"); - if( best_impl.more_specific_than(impl) ) - return false; - best_impl = mv$(impl); - if( ! best_impl.type_is_specialisable(pe.item.c_str()) ) - return true; - return false; - }); - if( best_impl.is_valid() ) { - // If the type is still specialisable, and there's geerics in the type. - if( best_impl.type_is_specialisable(pe.item.c_str()) && pe.type->contains_generics() ) { - // Mark it as opaque (because monomorphisation could change things) - DEBUG("Still-specialisable impl for " << ty << " also opaque"); - e.binding = ::HIR::TypeRef::TypePathBinding::make_Opaque({}); - } - else { - auto new_ty = best_impl.get_type(pe.item.c_str()); - if( new_ty == ::HIR::TypeRef() ) { - ERROR(sp, E0000, "Associated type '"<replace_equalities(input); + } + else { + DEBUG("Converted UfcsKnown - " << e.path << " = " << nt); + input = mv$(nt); + } return true; } }); -- cgit v1.2.3