about summary refs log tree commit diff
diff options
context:
space:
mode:
authorGraydon Hoare <graydon@mozilla.com>2011-02-08 17:05:53 -0800
committerGraydon Hoare <graydon@mozilla.com>2011-02-08 17:05:53 -0800
commit2f25d9c983c5730d79cc14278e666b8eb6531b10 (patch)
tree278091bbe46894e5a3862016de6d210d54b4f52c
parent74f71d387eceb4235bae89a400292ad6ecde8ca1 (diff)
downloadrust-2f25d9c983c5730d79cc14278e666b8eb6531b10.tar.gz
rust-2f25d9c983c5730d79cc14278e666b8eb6531b10.zip
Handle subtle view-shift on outptr in generic calls. Can construct generic objs now.
-rw-r--r--src/comp/middle/trans.rs8
1 files changed, 8 insertions, 0 deletions
diff --git a/src/comp/middle/trans.rs b/src/comp/middle/trans.rs
index 9e59cf5799b..4401f8852c7 100644
--- a/src/comp/middle/trans.rs
+++ b/src/comp/middle/trans.rs
@@ -2710,6 +2710,14 @@ fn trans_args(@block_ctxt cx,
     }
     if (ty.type_has_dynamic_size(retty)) {
         llargs += cx.build.PointerCast(llretslot, T_typaram_ptr());
+    } else if (ty.count_ty_params(retty) != 0u) {
+        // It's possible that the callee has some generic-ness somewhere in
+        // its return value -- say a method signature within an obj or a fn
+        // type deep in a structure -- which the caller has a concrete view
+        // of. If so, cast the caller's view of the restlot to the callee's
+        // view, for the sake of making a type-compatible call.
+        llargs += cx.build.PointerCast(llretslot,
+                                       T_ptr(type_of(cx.fcx.ccx, retty)));
     } else {
         llargs += llretslot;
     }