@@ -7829,7 +7829,7 @@ fn process_fwding_mthd(@local_ctxt cx, &span sp, @ty::method m,
7829
7829
ty:: t[ ] additional_field_tys) -> ValueRef {
7830
7830
7831
7831
// NB: self_ty (and llself_ty) is the type of the outer object;
7832
- // with_obj_ty (and llwith_obj_ty) is the type of the inner object.
7832
+ // with_obj_ty is the type of the inner object.
7833
7833
7834
7834
// The method m is being called on the outer object, but the outer object
7835
7835
// doesn't have that method; only the inner object does. So what we have
@@ -7870,6 +7870,11 @@ fn process_fwding_mthd(@local_ctxt cx, &span sp, @ty::method m,
7870
7870
auto llself_obj_ptr = alloca( bcx, llself_ty) ;
7871
7871
bcx. build. Store ( fcx. llenv, llself_obj_ptr) ;
7872
7872
7873
+ // Grab hold of the outer object so we can pass it into the inner object,
7874
+ // in case that inner object needs to make any self-calls. (Such calls
7875
+ // will need to dispatch back through the outer object.)
7876
+ auto llself_obj = bcx. build. Load ( llself_obj_ptr) ;
7877
+
7873
7878
// The 'llretptr' that will arrive in the forwarding function we're
7874
7879
// creating also needs to be the correct size. Cast it to the size of the
7875
7880
// method's return type, if necessary.
@@ -7961,11 +7966,10 @@ fn process_fwding_mthd(@local_ctxt cx, &span sp, @ty::method m,
7961
7966
7962
7967
// Set up the original method to be called.
7963
7968
auto orig_mthd_ty = ty:: method_ty_to_fn_ty( cx. ccx. tcx, * m) ;
7964
- auto llwith_obj_ty = val_ty( llwith_obj. val) ;
7965
7969
auto llorig_mthd_ty =
7966
7970
type_of_fn_full( bcx. fcx. lcx. ccx, sp,
7967
7971
ty:: ty_fn_proto( bcx. fcx. lcx. ccx. tcx, orig_mthd_ty) ,
7968
- some[ TypeRef ] ( llwith_obj_ty ) ,
7972
+ some[ TypeRef ] ( llself_ty ) ,
7969
7973
m. inputs,
7970
7974
m. output,
7971
7975
vec:: len[ ast:: ty_param] ( ty_params) ) ;
@@ -7976,7 +7980,7 @@ fn process_fwding_mthd(@local_ctxt cx, &span sp, @ty::method m,
7976
7980
// Set up the three implicit arguments to the original method we'll need
7977
7981
// to call.
7978
7982
let vec[ ValueRef ] llorig_mthd_args = [ llretptr, fcx. lltaskptr,
7979
- llwith_obj . val ] ;
7983
+ llself_obj ] ;
7980
7984
7981
7985
// Copy the explicit arguments that are being passed into the forwarding
7982
7986
// function (they're in fcx.llargs) to llorig_mthd_args.
0 commit comments