diff options
author | John Hodge <tpg@ucc.asn.au> | 2017-09-10 22:55:28 +0800 |
---|---|---|
committer | John Hodge <tpg@ucc.asn.au> | 2017-09-10 22:55:28 +0800 |
commit | e77dc7e4bae197664dacd8e14fd688b80875a5c4 (patch) | |
tree | d35b8a378d388f27aabf9228eecac90be43e7815 /src | |
parent | 319bffddc2e4467fc00efa0a19cf8f2472f3158e (diff) | |
download | mrust-e77dc7e4bae197664dacd8e14fd688b80875a5c4.tar.gz |
Typecheck Expressions - Extract bounds from function values
Diffstat (limited to 'src')
-rw-r--r-- | src/hir_typeck/expr_cs.cpp | 13 |
1 files changed, 12 insertions, 1 deletions
diff --git a/src/hir_typeck/expr_cs.cpp b/src/hir_typeck/expr_cs.cpp index e796b3b1..61f2b568 100644 --- a/src/hir_typeck/expr_cs.cpp +++ b/src/hir_typeck/expr_cs.cpp @@ -1581,7 +1581,11 @@ namespace { ft.m_arg_types.push_back( monomorphise_type_with(sp, arg.second, monomorph_cb) ); } + // Apply bounds + apply_bounds_as_rules(this->context, sp, f.m_params, monomorph_cb); + auto ty = ::HIR::TypeRef( ::HIR::TypeRef::Data::make_Function(mv$(ft)) ); + DEBUG("> " << node.m_path << " = " << ty); this->context.equate_types(sp, node.m_res_type, ty); } break; case ::HIR::ExprNode_PathValue::STRUCT_CONSTR: { @@ -1599,6 +1603,7 @@ namespace { { ft.m_arg_types.push_back( monomorphise_type(sp, s.m_params, e.m_params, arg.ent) ); } + //apply_bounds_as_rules(this->context, sp, s.m_params, monomorph_cb); auto ty = ::HIR::TypeRef( ::HIR::TypeRef::Data::make_Function(mv$(ft)) ); this->context.equate_types(sp, node.m_res_type, ty); @@ -1622,6 +1627,7 @@ namespace { { ft.m_arg_types.push_back( monomorphise_type(sp, enm.m_params, e.m_params, arg.ent) ); } + //apply_bounds_as_rules(this->context, sp, enm.m_params, monomorph_cb); auto ty = ::HIR::TypeRef( ::HIR::TypeRef::Data::make_Function(mv$(ft)) ); this->context.equate_types(sp, node.m_res_type, ty); @@ -1678,6 +1684,7 @@ namespace { }; for(const auto& arg : ie.m_args) ft.m_arg_types.push_back( monomorphise_type_with(sp, arg.second, monomorph_cb) ); + apply_bounds_as_rules(this->context, sp, ie.m_params, monomorph_cb); auto ty = ::HIR::TypeRef(mv$(ft)); this->context.equate_types(node.span(), node.m_res_type, ty); @@ -1785,7 +1792,9 @@ namespace { } }; - // TODO: Impl/method type bounds + // Bounds (both impl and fn) + apply_bounds_as_rules(this->context, sp, impl_ptr->m_params, monomorph_cb); + apply_bounds_as_rules(this->context, sp, fcn_ptr->m_params, monomorph_cb); ::HIR::FunctionType ft { fcn_ptr->m_unsafe, fcn_ptr->m_abi, @@ -1800,11 +1809,13 @@ namespace { } else // !fcn_ptr, ergo const_ptr { + assert(const_ptr); auto monomorph_cb = monomorphise_type_get_cb(sp, &*e.type, &impl_params, &e.params); ::HIR::TypeRef tmp; const auto& ty = ( monomorphise_type_needed(const_ptr->m_type) ? tmp = monomorphise_type_with(sp, const_ptr->m_type, monomorph_cb) : const_ptr->m_type ); + apply_bounds_as_rules(this->context, sp, impl_ptr->m_params, monomorph_cb); this->context.equate_types(node.span(), node.m_res_type, ty); } ) |