From 627b8de583d0fa56540b1c09ed9bdcaf1eedd6ce Mon Sep 17 00:00:00 2001 From: Jean Privat Date: Fri, 27 Feb 2015 20:58:55 +0700 Subject: [PATCH] sepcomp: fix compilation of NativeArray[] in an inlined context. Signed-off-by: Jean Privat --- src/compiler/separate_compiler.nit | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/compiler/separate_compiler.nit b/src/compiler/separate_compiler.nit index da2ed1e..667c196 100644 --- a/src/compiler/separate_compiler.nit +++ b/src/compiler/separate_compiler.nit @@ -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]};") -- 1.7.9.5