summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJohn Hodge <tpg@mutabah.net>2016-09-04 18:25:05 +0800
committerJohn Hodge <tpg@mutabah.net>2016-09-04 18:25:05 +0800
commit73f6bacc20dc8248654994d1d9a35e3aebcf7d0d (patch)
tree59d769f8701aa5c1c0ed77d33587211dece6382f
parent9b3f03150b5a4b09f5d9bf6a95bf863ba2a8b0e1 (diff)
downloadmrust-73f6bacc20dc8248654994d1d9a35e3aebcf7d0d.tar.gz
HIR Typecheck Expr - Hacky support for Box receivers
-rw-r--r--src/hir_typeck/expr_cs.cpp12
1 files changed, 10 insertions, 2 deletions
diff --git a/src/hir_typeck/expr_cs.cpp b/src/hir_typeck/expr_cs.cpp
index 350ac042..9cc1f1dd 100644
--- a/src/hir_typeck/expr_cs.cpp
+++ b/src/hir_typeck/expr_cs.cpp
@@ -1896,8 +1896,16 @@ namespace {
DEBUG("- Ref " << &*node_ptr << " -> " << ty);
node_ptr = NEWNODE(mv$(ty), span, _Borrow, bt, mv$(node_ptr) );
} break;
- case ::HIR::Function::Receiver::Box:
- TODO(sp, "Box method receiver calling - " << node.m_method_path);
+ case ::HIR::Function::Receiver::Box: {
+ // - Undo a deref (there must have been one?) and ensure that it leads to a Box<Self>
+ auto* deref_ptr = dynamic_cast< ::HIR::ExprNode_Deref*>(&*node_ptr);
+ ASSERT_BUG(sp, deref_ptr != nullptr, "Calling Box receiver method but no deref happened");
+ node_ptr = mv$(deref_ptr->m_value);
+ DEBUG("- Undo deref " << deref_ptr << " -> " << node_ptr->m_res_type);
+ // TODO: Triple-check that the input to the above Deref was a Box (lang="owned_box")
+ //TU_IFLET(::HIR::TypeRef::Data, node_ptr->m_res_type.m_data, Path, e,
+ //)
+ } break;
}
}