src: remove useless comparisons on null
[nit.git] / src / compiler / separate_compiler.nit
index 43d06c2..8c400f9 100644 (file)
@@ -1101,13 +1101,13 @@ class SeparateCompilerVisitor
                return table_send(mmethod, arguments, mmethod.const_color)
        end
 
-       # Handel common special cases before doing the effective method invocation
+       # Handle common special cases before doing the effective method invocation
        # This methods handle the `==` and `!=` methods and the case of the null receiver.
        # Note: a { is open in the generated C, that enclose and protect the effective method invocation.
        # Client must not forget to close the } after them.
        #
        # The value returned is the result of the common special cases.
-       # If not null, client must compine it with the result of their own effective method invocation.
+       # If not null, client must compile it with the result of their own effective method invocation.
        #
        # If `before_send` can shortcut the whole message sending, a dummy `if(0){`
        # is generated to cancel the effective method invocation that will follow
@@ -1762,7 +1762,7 @@ class SeparateCompilerVisitor
        redef fun calloc_array(ret_type, arguments)
        do
                var mclass = self.get_class("ArrayCapable")
-               var ft = mclass.mclass_type.arguments.first.as(MParameterType)
+               var ft = mclass.mparameters.first
                var res = self.native_array_instance(ft, arguments[1])
                self.ret(res)
        end
@@ -1972,7 +1972,12 @@ redef class MPropDef
        fun const_color: String do return "COLOR_{c_name}"
 end
 
-redef class AExternInitPropdef
+redef class AMethPropdef
        # The semi-global compilation does not support inlining calls to extern news
-       redef fun can_inline do return false
+       redef fun can_inline
+       do
+               var m = mpropdef
+               if m != null and m.mproperty.is_init and m.is_extern then return false
+               return super
+       end
 end