global_compiler: Add contract phase dependency
[nit.git] / src / compiler / global_compiler.nit
index 2d2e6f2..737ec48 100644 (file)
@@ -30,7 +30,7 @@ redef class ToolContext
        # option --global
        var opt_global = new OptionBool("Use global compilation", "--global")
 
-       var global_compiler_phase = new GlobalCompilerPhase(self, null)
+       var global_compiler_phase = new GlobalCompilerPhase(self, [contracts_phase])
 
        redef init do
                super
@@ -463,8 +463,9 @@ class GlobalCompilerVisitor
                self.add("{recv}[{i}]={val};")
        end
 
-        redef fun routine_ref_instance(routine_mclass_type, recv, mmethoddef)
+        redef fun routine_ref_instance(routine_mclass_type, recv, callsite)
         do
+               var mmethoddef = callsite.mpropdef
                 var method = new CustomizedRuntimeFunction(mmethoddef, recv.mcasttype.as(MClassType))
                 var my_recv = recv
                 if recv.mtype.is_c_primitive then
@@ -475,8 +476,8 @@ class GlobalCompilerVisitor
                 thunk.polymorph_call_flag = not my_recv.is_exact
                 compiler.todo(method)
                 compiler.todo(thunk)
-
-                var res = self.new_expr("NEW_{routine_mclass_type.c_name}({my_recv}, &{thunk.c_name})", routine_mclass_type)
+               var ret_type = self.anchor(routine_mclass_type).as(MClassType)
+                var res = self.new_expr("NEW_{ret_type.c_name}({my_recv}, &{thunk.c_name})", ret_type)
                 return res
         end