aboutsummaryrefslogtreecommitdiff
path: root/gcc
diff options
context:
space:
mode:
Diffstat (limited to 'gcc')
-rw-r--r--gcc/rust/typecheck/rust-hir-type-check-expr.h7
-rw-r--r--gcc/rust/typecheck/rust-tyty-call.h9
-rw-r--r--gcc/rust/typecheck/rust-tyty.cc2
3 files changed, 14 insertions, 4 deletions
diff --git a/gcc/rust/typecheck/rust-hir-type-check-expr.h b/gcc/rust/typecheck/rust-hir-type-check-expr.h
index 99696ae..d5d12b4 100644
--- a/gcc/rust/typecheck/rust-hir-type-check-expr.h
+++ b/gcc/rust/typecheck/rust-hir-type-check-expr.h
@@ -295,6 +295,10 @@ public:
return;
}
+ // Get the adjusted self
+ Adjuster adj (receiver_tyty);
+ TyTy::BaseType *adjusted_self = adj.adjust_type (adjustments);
+
// store the adjustments for code-generation to know what to do
context->insert_autoderef_mappings (expr.get_mappings ().get_hirid (),
std::move (adjustments));
@@ -401,7 +405,8 @@ public:
}
TyTy::BaseType *function_ret_tyty
- = TyTy::TypeCheckMethodCallExpr::go (lookup, expr, context);
+ = TyTy::TypeCheckMethodCallExpr::go (lookup, expr, adjusted_self,
+ context);
if (function_ret_tyty == nullptr
|| function_ret_tyty->get_kind () == TyTy::TypeKind::ERROR)
{
diff --git a/gcc/rust/typecheck/rust-tyty-call.h b/gcc/rust/typecheck/rust-tyty-call.h
index c11fd4d..3080427 100644
--- a/gcc/rust/typecheck/rust-tyty-call.h
+++ b/gcc/rust/typecheck/rust-tyty-call.h
@@ -88,9 +88,10 @@ class TypeCheckMethodCallExpr : private TyVisitor
public:
// Resolve the Method parameters and return back the return type
static BaseType *go (BaseType *ref, HIR::MethodCallExpr &call,
+ TyTy::BaseType *adjusted_self,
Resolver::TypeCheckContext *context)
{
- TypeCheckMethodCallExpr checker (call, context);
+ TypeCheckMethodCallExpr checker (call, adjusted_self, context);
ref->accept_vis (checker);
return checker.resolved;
}
@@ -125,13 +126,15 @@ public:
private:
TypeCheckMethodCallExpr (HIR::MethodCallExpr &c,
+ TyTy::BaseType *adjusted_self,
Resolver::TypeCheckContext *context)
- : resolved (nullptr), call (c), context (context),
- mappings (Analysis::Mappings::get ())
+ : resolved (nullptr), call (c), adjusted_self (adjusted_self),
+ context (context), mappings (Analysis::Mappings::get ())
{}
BaseType *resolved;
HIR::MethodCallExpr &call;
+ TyTy::BaseType *adjusted_self;
Resolver::TypeCheckContext *context;
Analysis::Mappings *mappings;
};
diff --git a/gcc/rust/typecheck/rust-tyty.cc b/gcc/rust/typecheck/rust-tyty.cc
index 378416f..add4dbe 100644
--- a/gcc/rust/typecheck/rust-tyty.cc
+++ b/gcc/rust/typecheck/rust-tyty.cc
@@ -2786,6 +2786,8 @@ TypeCheckCallExpr::visit (FnPtr &type)
void
TypeCheckMethodCallExpr::visit (FnType &type)
{
+ adjusted_self->unify (type.get_self_type ());
+
// +1 for the receiver self
size_t num_args_to_call = call.num_params () + 1;
if (num_args_to_call != type.num_params ())