sepcomp: fix compilation of NativeArray[] in an inlined context.
authorJean Privat <jean@pryen.org>
Fri, 27 Feb 2015 13:58:55 +0000 (20:58 +0700)
committerJean Privat <jean@pryen.org>
Fri, 27 Feb 2015 13:58:55 +0000 (20:58 +0700)
Signed-off-by: Jean Privat <jean@pryen.org>

src/compiler/separate_compiler.nit

index da2ed1e..667c196 100644 (file)
@@ -1852,7 +1852,10 @@ class SeparateCompilerVisitor
                var nclass = self.get_class("NativeArray")
                var recv = "((struct instance_{nclass.c_name}*){arguments[0]})->values"
                if pname == "[]" then
-                       self.ret(self.new_expr("{recv}[{arguments[1]}]", ret_type.as(not null)))
+                       # Because the objects are boxed, return the box to avoid unnecessary (or broken) unboxing/reboxing
+                       var res = self.new_expr("{recv}[{arguments[1]}]", compiler.mainmodule.object_type)
+                       res.mcasttype = ret_type.as(not null)
+                       self.ret(res)
                        return
                else if pname == "[]=" then
                        self.add("{recv}[{arguments[1]}]={arguments[2]};")