diff options
-rw-r--r-- | src/hir_typeck/expr_context.cpp | 97 | ||||
-rw-r--r-- | src/hir_typeck/expr_cs.cpp | 3 |
2 files changed, 5 insertions, 95 deletions
diff --git a/src/hir_typeck/expr_context.cpp b/src/hir_typeck/expr_context.cpp index 9623db6c..97b65f54 100644 --- a/src/hir_typeck/expr_context.cpp +++ b/src/hir_typeck/expr_context.cpp @@ -40,6 +40,7 @@ void typeck::TypecheckContext::dump() const void typeck::TypecheckContext::compact_ivars() { TRACE_FUNCTION; + //m_ivars.compact_ivars([&](const ::HIR::TypeRef& t)->auto{ return this->expand_associated_types(Span(), t.clone); }); unsigned int i = 0; for(auto& v : m_ivars.m_ivars) { @@ -279,101 +280,7 @@ bool typeck::TypecheckContext::types_equal(const ::HIR::TypeRef& rl, const ::HIR void typeck::TypecheckContext::print_type(::std::ostream& os, const ::HIR::TypeRef& tr) const { - struct H { - static void print_pp(const TypecheckContext& ctxt, ::std::ostream& os, const ::HIR::PathParams& pps) { - if( pps.m_types.size() > 0 ) { - os << "<"; - for(const auto& pp_t : pps.m_types) { - ctxt.print_type(os, pp_t); - os << ","; - } - os << ">"; - } - } - }; - const auto& ty = this->get_type(tr); - TU_MATCH(::HIR::TypeRef::Data, (ty.m_data), (e), - (Infer, - os << ty; - ), - (Primitive, - os << ty; - ), - (Diverge, os << ty; ), - (Generic, os << ty; ), - (Path, - TU_MATCH(::HIR::Path::Data, (e.path.m_data), (pe), - (Generic, - os << pe.m_path; - H::print_pp(*this, os, pe.m_params); - ), - (UfcsKnown, - os << "<"; - this->print_type(os, *pe.type); - os << " as " << pe.trait.m_path; - H::print_pp(*this, os, pe.trait.m_params); - os << ">::" << pe.item; - H::print_pp(*this, os, pe.params); - ), - (UfcsInherent, - os << "<"; - this->print_type(os, *pe.type); - os << ">::" << pe.item; - H::print_pp(*this, os, pe.params); - ), - (UfcsUnknown, - BUG(Span(), "UfcsUnknown"); - ) - ) - ), - (Borrow, - os << "&"; - this->print_type(os, *e.inner); - ), - (Pointer, - os << "*"; - this->print_type(os, *e.inner); - ), - (Slice, - os << "["; - this->print_type(os, *e.inner); - os << "]"; - ), - (Array, - os << "["; - this->print_type(os, *e.inner); - os << "; " << e.size_val << "]"; - ), - (Closure, - //for(const auto& arg : e.m_arg_types) - // if( type_contains_ivars(arg) ) - // return true; - //return type_contains_ivars(*e.m_rettype); - ), - (Function, - //for(const auto& arg : e.m_arg_types) - // if( type_contains_ivars(arg) ) - // return true; - //return type_contains_ivars(*e.m_rettype); - ), - (TraitObject, - os << "(" << e.m_trait.m_path.m_path; - H::print_pp(*this, os, e.m_trait.m_path.m_params); - for(const auto& marker : e.m_markers) { - os << "+" << marker.m_path; - H::print_pp(*this, os, marker.m_params); - } - os << ")"; - ), - (Tuple, - os << "("; - for(const auto& st : e) { - this->print_type(os, st); - os << ","; - } - os << ")"; - ) - ) + m_ivars.print_type(os, tr); } /// diff --git a/src/hir_typeck/expr_cs.cpp b/src/hir_typeck/expr_cs.cpp index 572c0b63..7175e2dc 100644 --- a/src/hir_typeck/expr_cs.cpp +++ b/src/hir_typeck/expr_cs.cpp @@ -1265,6 +1265,9 @@ void Context::add_binding(const Span& sp, ::HIR::Pattern& pat, ::HIR::TypeRef& t void Context::equate_types_coerce(const Span& sp, const ::HIR::TypeRef& l, ::HIR::ExprNodeP& node_ptr) { // - Just record the equality + this->link_coerce.push_back(Coercion { + l.clone(), node_ptr + }); } void Context::equate_types_assoc(const Span& sp, const ::HIR::TypeRef& l, const ::HIR::SimplePath& trait, const ::std::vector< ::HIR::TypeRef>& ty_args, const ::HIR::TypeRef& impl_ty, const char *name) { |