Merge branch 'annotations'
[nit.git] / src / rapid_type_analysis.nit
index 2a89d11..bb368ee 100644 (file)
@@ -173,10 +173,9 @@ class RapidTypeAnalysis
        fun add_monomorphic_send(mtype: MClassType, mmethod: MMethod)
        do
                assert self.live_types.has(mtype)
-               var defs = mmethod.lookup_definitions(self.mainmodule, mtype)
-               if defs.is_empty then return
-               assert defs.length == 1 else print "conflict on {mtype} for {mmethod}: {defs.join(" ")}"
-               self.add_static_call(mtype, defs.first)
+               if not mtype.has_mproperty(self.mainmodule, mmethod) then return
+               var def = mmethod.lookup_first_definition(self.mainmodule, mtype)
+               self.add_static_call(mtype, def)
        end
 
        # Add a customized_methoddefs to the pool
@@ -398,7 +397,14 @@ private class RapidTypeVisitor
        do
                if node == null then return
                node.accept_rapid_type_vistor(self)
-               node.visit_all(self)
+               if node isa AExpr then
+                       var implicit_cast_to = node.implicit_cast_to
+                       if implicit_cast_to != null then self.add_cast_type(implicit_cast_to)
+               end
+               # RTA does not enter in AAnnotations
+               if not node isa AAnnotations then
+                       node.visit_all(self)
+               end
        end
 
        # Force to get the primitive class named `name' or abort
@@ -586,15 +592,9 @@ redef class ASuperExpr
                        return
                end
 
-               #FIXME: we do not want an ugly static call!
-               var mpropdef = v.mpropdef
-               var mpropdefs = mpropdef.mproperty.lookup_super_definitions(mpropdef.mclassdef.mmodule, mpropdef.mclassdef.bound_mtype)
-               if mpropdefs.length != 1 then
-                       debug("MPRODFEFS for super {mpropdef} for {v.receiver}: {mpropdefs.join(", ")}")
-               end
-               var msuperpropdef = mpropdefs.first
-               assert msuperpropdef isa MMethodDef
-               v.analysis.add_static_call(v.receiver, msuperpropdef)
+               var mpropdef = v.mpropdef.lookup_next_definition(v.analysis.mainmodule, v.receiver)
+               assert mpropdef isa MMethodDef
+               v.analysis.add_static_call(v.receiver, mpropdef)
        end
 end