compiler: accept `null` as a *maybenull* receiver
authorJean Privat <jean@pryen.org>
Mon, 5 Jan 2015 02:54:01 +0000 (21:54 -0500)
committerJean Privat <jean@pryen.org>
Mon, 5 Jan 2015 02:54:01 +0000 (21:54 -0500)
Signed-off-by: Jean Privat <jean@pryen.org>

src/compiler/separate_compiler.nit

index 54c51b2..e5f1bb9 100644 (file)
@@ -1112,7 +1112,7 @@ class SeparateCompilerVisitor
                var res: nullable RuntimeVariable = null
                var recv = arguments.first
                var consider_null = not self.compiler.modelbuilder.toolcontext.opt_no_check_null.value or mmethod.name == "==" or mmethod.name == "!="
-               var maybenull = recv.mcasttype isa MNullableType and consider_null
+               var maybenull = (recv.mcasttype isa MNullableType or recv.mcasttype isa MNullType) and consider_null
                if maybenull then
                        self.add("if ({recv} == NULL) \{")
                        if mmethod.name == "==" then