aboutsummaryrefslogtreecommitdiff
path: root/crates/hir_ty/src/infer
diff options
context:
space:
mode:
authorcynecx <[email protected]>2021-05-31 19:04:18 +0100
committercynecx <[email protected]>2021-05-31 19:26:38 +0100
commit759cb07891d6c9583095d7a1423619b36bc3d547 (patch)
treec0811e9bd561f44418da38a6ff4ca263ddcb3f3e /crates/hir_ty/src/infer
parent7c1d8ca63510bb719fd91bbf38692e45b19c04d6 (diff)
hir_ty: use correct receiver_ty in method resolution
Diffstat (limited to 'crates/hir_ty/src/infer')
-rw-r--r--crates/hir_ty/src/infer/expr.rs13
1 files changed, 2 insertions, 11 deletions
diff --git a/crates/hir_ty/src/infer/expr.rs b/crates/hir_ty/src/infer/expr.rs
index 41ef45326..f73bf43b2 100644
--- a/crates/hir_ty/src/infer/expr.rs
+++ b/crates/hir_ty/src/infer/expr.rs
@@ -890,7 +890,7 @@ impl<'a> InferenceContext<'a> {
890 method_name, 890 method_name,
891 ) 891 )
892 }); 892 });
893 let (derefed_receiver_ty, method_ty, substs) = match resolved { 893 let (receiver_ty, method_ty, substs) = match resolved {
894 Some((ty, func)) => { 894 Some((ty, func)) => {
895 let ty = canonicalized_receiver.decanonicalize_ty(ty); 895 let ty = canonicalized_receiver.decanonicalize_ty(ty);
896 let generics = generics(self.db.upcast(), func.into()); 896 let generics = generics(self.db.upcast(), func.into());
@@ -916,16 +916,7 @@ impl<'a> InferenceContext<'a> {
916 } 916 }
917 None => (self.err_ty(), Vec::new(), self.err_ty()), 917 None => (self.err_ty(), Vec::new(), self.err_ty()),
918 }; 918 };
919 // Apply autoref so the below unification works correctly 919 self.unify(&expected_receiver_ty, &receiver_ty);
920 // FIXME: return correct autorefs from lookup_method
921 let actual_receiver_ty = match self.resolve_ty_shallow(&expected_receiver_ty).as_reference()
922 {
923 Some((_, lifetime, mutability)) => {
924 TyKind::Ref(mutability, lifetime, derefed_receiver_ty).intern(&Interner)
925 }
926 _ => derefed_receiver_ty,
927 };
928 self.unify(&expected_receiver_ty, &actual_receiver_ty);
929 920
930 self.check_call_arguments(args, &param_tys); 921 self.check_call_arguments(args, &param_tys);
931 self.normalize_associated_types_in(ret_ty) 922 self.normalize_associated_types_in(ret_ty)