@@ -3605,20 +3605,23 @@ type generic_info = rec(@ty.t item_type,
3605
3605
type lval_result = rec( result res,
3606
3606
bool is_mem,
3607
3607
option. t[ generic_info] generic,
3608
- option. t[ ValueRef ] llobj) ;
3608
+ option. t[ ValueRef ] llobj,
3609
+ option. t[ @ty. t] method_ty) ;
3609
3610
3610
3611
fn lval_mem( @block_ctxt cx, ValueRef val) -> lval_result {
3611
3612
ret rec( res=res( cx, val) ,
3612
3613
is_mem=true,
3613
3614
generic=none[ generic_info] ,
3614
- llobj=none[ ValueRef ] ) ;
3615
+ llobj=none[ ValueRef ] ,
3616
+ method_ty=none[ @ty. t] ) ;
3615
3617
}
3616
3618
3617
3619
fn lval_val( @block_ctxt cx, ValueRef val) -> lval_result {
3618
3620
ret rec( res=res( cx, val) ,
3619
3621
is_mem=false,
3620
3622
generic=none[ generic_info] ,
3621
- llobj=none[ ValueRef ] ) ;
3623
+ llobj=none[ ValueRef ] ,
3624
+ method_ty=none[ @ty. t] ) ;
3622
3625
}
3623
3626
3624
3627
fn trans_external_path( @block_ctxt cx, ast. def_id did,
@@ -3813,7 +3816,10 @@ fn trans_field(@block_ctxt cx, &ast.span sp, ValueRef v, @ty.t t0,
3813
3816
C_int ( ix as int) ) ) ;
3814
3817
3815
3818
auto lvo = lval_mem( r. bcx, v) ;
3816
- ret rec( llobj = some[ ValueRef ] ( r. val) with lvo) ;
3819
+ let @ty. t fn_ty = ty. method_ty_to_fn_ty( methods. ( ix) ) ;
3820
+ ret rec( llobj = some[ ValueRef ] ( r. val) ,
3821
+ method_ty = some[ @ty. t] ( fn_ty)
3822
+ with lvo) ;
3817
3823
}
3818
3824
case ( _) { cx. fcx. ccx. sess. unimpl( "field variant in trans_field") ; }
3819
3825
}
@@ -4426,6 +4432,11 @@ fn trans_call(@block_ctxt cx, @ast.expr f,
4426
4432
option. t[ ValueRef ] lliterbody,
4427
4433
vec[ @ast. expr] args,
4428
4434
& ast. ann ann) -> result {
4435
+
4436
+ // NB: 'f' isn't necessarily a function; it might be an entire self-call
4437
+ // expression because of the hack that allows us to process self-calls
4438
+ // with trans_call.
4439
+
4429
4440
auto f_res = trans_lval( cx, f) ;
4430
4441
auto faddr = f_res. res. val;
4431
4442
auto llenv = C_null ( T_opaque_closure_ptr ( cx. fcx. ccx. tn) ) ;
@@ -4449,7 +4460,21 @@ fn trans_call(@block_ctxt cx, @ast.expr f,
4449
4460
llenv = bcx. build. Load ( llclosure) ;
4450
4461
}
4451
4462
}
4452
- auto fn_ty = ty. expr_ty( f) ;
4463
+
4464
+ let @ty. t fn_ty;
4465
+ alt ( f_res. method_ty) {
4466
+ case ( some[ @ty. t] ( ?meth) ) {
4467
+ // self-call
4468
+ fn_ty = meth;
4469
+ }
4470
+
4471
+ case ( _) {
4472
+ fn_ty = ty. expr_ty( f) ;
4473
+
4474
+ }
4475
+
4476
+ }
4477
+
4453
4478
auto ret_ty = ty. ann_to_type( ann) ;
4454
4479
auto args_res = trans_args( f_res. res. bcx,
4455
4480
llenv, f_res. llobj,
0 commit comments