typing: advice if a receiver is nullable
authorJean Privat <jean@pryen.org>
Wed, 27 May 2015 23:25:15 +0000 (19:25 -0400)
committerJean Privat <jean@pryen.org>
Wed, 27 May 2015 23:25:15 +0000 (19:25 -0400)
Signed-off-by: Jean Privat <jean@pryen.org>

src/semantize/typing.nit

index ada6160..10edaf1 100644 (file)
@@ -329,6 +329,8 @@ private class TypeVisitor
                if recvtype isa MNullType and not mproperty.is_null_safe then
                        self.error(node, "Error: method `{name}` called on `null`.")
                        return null
+               else if unsafe_type isa MNullableType and not mproperty.is_null_safe then
+                       modelbuilder.advice(node, "call-on-nullable", "Warning: method call on a nullable receiver `{recvtype}`.")
                end
 
                if is_toplevel_context and recv_is_self and not mproperty.is_toplevel then