typing: factorize AEqExpr and ANeExpr into AEqFormExpr
[nit.git] / src / semantize / typing.nit
index 4aad2d2..4868fc9 100644 (file)
@@ -648,7 +648,7 @@ end
 
 redef class Variable
        # The declared type of the variable
-       var declared_type: nullable MType
+       var declared_type: nullable MType is writable
 
        # Was the variable type-adapted?
        # This is used to speedup type retrieval while it remains `false`
@@ -760,15 +760,15 @@ redef class AAttrPropdef
        do
                if not has_value then return
 
-               var mpropdef = self.mpropdef
-               if mpropdef == null then return # skip error
+               var mpropdef = self.mreadpropdef
+               if mpropdef == null or mpropdef.msignature == null then return # skip error
 
                var v = new TypeVisitor(modelbuilder, mpropdef.mclassdef.mmodule, mpropdef)
                self.selfvariable = v.selfvariable
 
                var nexpr = self.n_expr
                if nexpr != null then
-                       var mtype = self.mpropdef.static_mtype
+                       var mtype = self.mtype
                        v.visit_expr_subtype(nexpr, mtype)
                end
                var nblock = self.n_block
@@ -1304,7 +1304,8 @@ redef class AOrElseExpr
                end
 
                if t1 isa MNullType then
-                       v.error(n_expr, "Type Error: `or else` on `null`.")
+                       self.mtype = t2
+                       return
                else if v.check_can_be_null(n_expr, t1) then
                        t1 = t1.as_notnull
                end
@@ -1688,14 +1689,8 @@ redef class ABinopExpr
        redef fun property_name do return operator
        redef fun property_node do return n_op
 end
-redef class AEqExpr
-       redef fun accept_typing(v)
-       do
-               super
-               v.null_test(self)
-       end
-end
-redef class ANeExpr
+
+redef class AEqFormExpr
        redef fun accept_typing(v)
        do
                super