From 2f986a5184ff85f8e7969c00c86af069d414cbd3 Mon Sep 17 00:00:00 2001 From: Jean Privat Date: Fri, 10 Apr 2015 12:13:39 +0700 Subject: [PATCH] engines: ANewExpr just return the plain instance if no callsite Signed-off-by: Jean Privat --- src/compiler/abstract_compiler.nit | 4 +++- src/interpreter/naive_interpreter.nit | 3 +++ 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/src/compiler/abstract_compiler.nit b/src/compiler/abstract_compiler.nit index 3956744..0baf216 100644 --- a/src/compiler/abstract_compiler.nit +++ b/src/compiler/abstract_compiler.nit @@ -3019,7 +3019,9 @@ redef class ANewExpr var recv = v.init_instance_or_extern(mtype) - var callsite = self.callsite.as(not null) + var callsite = self.callsite + if callsite == null then return recv + var args = v.varargize(callsite.mpropdef, recv, self.n_args.n_exprs) var res2 = v.compile_callsite(callsite, args) if res2 != null then diff --git a/src/interpreter/naive_interpreter.nit b/src/interpreter/naive_interpreter.nit index 272219f..2950bae 100644 --- a/src/interpreter/naive_interpreter.nit +++ b/src/interpreter/naive_interpreter.nit @@ -1799,6 +1799,9 @@ redef class ANewExpr var mtype = v.unanchor_type(self.recvtype.as(not null)) var recv: Instance = new MutableInstance(mtype) v.init_instance(recv) + var callsite = self.callsite + if callsite == null then return recv + var args = v.varargize(callsite.mpropdef, recv, self.n_args.n_exprs) if args == null then return null var res2 = v.callsite(callsite, args) -- 1.7.9.5