From dcd65fac199d3caac4b1019304ef5e1b480f31ff Mon Sep 17 00:00:00 2001 From: Patrick Walton Date: Thu, 24 Feb 2011 13:51:53 -0800 Subject: Cast more aggressively to the callee type when calling generic functions. Add a test-case for this, and XFAIL it in rustboot. --- src/comp/middle/trans.rs | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) (limited to 'src/comp/middle') diff --git a/src/comp/middle/trans.rs b/src/comp/middle/trans.rs index 30f3cdc4..a3a1d83f 100644 --- a/src/comp/middle/trans.rs +++ b/src/comp/middle/trans.rs @@ -3091,6 +3091,12 @@ fn trans_args(@block_ctxt cx, } // ... then explicit args. + + // First we figure out the caller's view of the types of the arguments. + // This will be needed if this is a generic call, because the callee has + // to cast her view of the arguments to the caller's view. + auto arg_tys = type_of_explicit_args(cx.fcx.ccx, args); + auto i = 0u; for (@ast.expr e in es) { auto mode = args.(i).mode; @@ -3132,9 +3138,9 @@ fn trans_args(@block_ctxt cx, bcx = re.bcx; } - if (ty.type_has_dynamic_size(args.(i).ty)) { - val = bcx.build.PointerCast(val, - T_typaram_ptr(cx.fcx.ccx.tn)); + if (ty.count_ty_params(args.(i).ty) > 0u) { + auto lldestty = arg_tys.(i); + val = bcx.build.PointerCast(val, lldestty); } llargs += val; -- cgit v1.2.3