summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorJohn Hodge <tpg@mutabah.net>2016-09-21 20:16:16 +0800
committerJohn Hodge <tpg@mutabah.net>2016-09-21 20:16:16 +0800
commit099cc89cc8640121b7be1be4c8ba460e3ada7723 (patch)
tree6974ddcd3030f927a5aa6a38bf29240201287400 /src
parenta751bd155143c38a5ffd2b2499227a89c2628226 (diff)
downloadmrust-099cc89cc8640121b7be1be4c8ba460e3ada7723.tar.gz
HIR Typcheck Expr - Equate the `self` type for methods to propagate ivars into the path
Diffstat (limited to 'src')
-rw-r--r--src/hir_typeck/expr_cs.cpp12
1 files changed, 8 insertions, 4 deletions
diff --git a/src/hir_typeck/expr_cs.cpp b/src/hir_typeck/expr_cs.cpp
index 2f9bcaa8..843987c5 100644
--- a/src/hir_typeck/expr_cs.cpp
+++ b/src/hir_typeck/expr_cs.cpp
@@ -2079,14 +2079,15 @@ namespace {
}
DEBUG("- fcn_path=" << node.m_method_path);
- // Link arguments
- // 1+ because it's a method call (#0 is Self)
+ // --- Check and equate self/arguments/return
DEBUG("node.m_cache.m_arg_types = " << node.m_cache.m_arg_types);
+ // NOTE: `Self` is equated after autoderef and autoref
for(unsigned int i = 0; i < node.m_args.size(); i ++)
{
- this->context.equate_types_coerce(node.span(), node.m_cache.m_arg_types[1+i], node.m_args[i]);
+ // 1+ because it's a method call (#0 is Self)
+ this->context.equate_types_coerce(sp, node.m_cache.m_arg_types[1+i], node.m_args[i]);
}
- this->context.equate_types(node.span(), node.m_res_type, node.m_cache.m_arg_types.back());
+ this->context.equate_types(sp, node.m_res_type, node.m_cache.m_arg_types.back());
// Add derefs
if( deref_count > 0 )
@@ -2142,6 +2143,9 @@ namespace {
}
}
+ // Equate the type for `self` (to ensure that Self's type params infer correctly)
+ this->context.equate_types(sp, node.m_cache.m_arg_types[0], node.m_value->m_res_type);
+
this->m_completed = true;
}
}