typing: make `CallSite` a `MEntity` so that `is_broken` can be used
[nit.git] / src / semantize / typing.nit
index b5f5d0c..66b47db 100644 (file)
@@ -540,7 +540,7 @@ private class TypeVisitor
 
        fun error(node: ANode, message: String)
        do
-               self.modelbuilder.toolcontext.error(node.hot_location, message)
+               self.modelbuilder.error(node, message)
        end
 
        fun get_variable(node: AExpr, variable: Variable): nullable MType
@@ -621,6 +621,8 @@ end
 
 # A specific method call site with its associated informations.
 class CallSite
+       super MEntity
+
        # The associated node for location
        var node: ANode
 
@@ -659,6 +661,7 @@ class CallSite
        do
                var map = v.check_signature(self.node, args, self.mproperty, self.msignature)
                signaturemap = map
+               if map == null then is_broken = true
                return map == null
        end
 end
@@ -781,6 +784,9 @@ private class PostTypingVisitor
        redef fun visit(n) do
                n.visit_all(self)
                n.accept_post_typing(type_visitor)
+               if n isa AExpr and n.mtype == null and not n.is_typed then
+                       n.is_broken = true
+               end
        end
 end
 
@@ -1389,6 +1395,16 @@ redef class AIntegerExpr
                        mclass = v.get_mclass(self, "Byte")
                else if value isa Int then
                        mclass = v.get_mclass(self, "Int")
+               else if value isa Int8 then
+                       mclass = v.get_mclass(self, "Int8")
+               else if value isa Int16 then
+                       mclass = v.get_mclass(self, "Int16")
+               else if value isa UInt16 then
+                       mclass = v.get_mclass(self, "UInt16")
+               else if value isa Int32 then
+                       mclass = v.get_mclass(self, "Int32")
+               else if value isa UInt32 then
+                       mclass = v.get_mclass(self, "UInt32")
                end
                if mclass == null then return # Forward error
                self.mtype = mclass.mclass_type