src: use `ASuperExpr::mpropdef` instead of asking the frame or visitors
[nit.git] / src / rapid_type_analysis.nit
index 3ee7b28..50e4563 100644 (file)
@@ -60,7 +60,7 @@ class RapidTypeAnalysis
        var live_classes = new HashSet[MClass]
 
        # The pool of types used to perform type checks (isa and as).
-       var live_cast_types = new HashSet[MClassType]
+       var live_cast_types = new HashSet[MType]
 
        # The pool of undesolved types used to perform type checks (isa and as).
        # They are globally resolved at the end of the analaysis
@@ -81,6 +81,12 @@ class RapidTypeAnalysis
        # The method definitions that remain to visit
        private var todo = new List[MMethodDef]
 
+       private fun force_alive(classname: String)
+       do
+               var classes = self.modelbuilder.model.get_mclasses_by_name(classname)
+               if classes != null then for c in classes do self.add_new(c.mclass_type, c.mclass_type)
+       end
+
        # Run the analysis until all visitable method definitions are visited.
        fun run_analysis
        do
@@ -96,9 +102,11 @@ class RapidTypeAnalysis
                        add_send(maintype, mainprop)
                end
 
-               # Force Bool
-               var classes = self.modelbuilder.model.get_mclasses_by_name("Bool")
-               if classes != null then for c in classes do self.add_new(c.mclass_type, c.mclass_type)
+               # Force primitive types
+               force_alive("Bool")
+               force_alive("Int")
+               force_alive("Float")
+               force_alive("Char")
 
                while not todo.is_empty do
                        var mmethoddef = todo.shift
@@ -150,7 +158,7 @@ class RapidTypeAnalysis
                                var auto_super_inits = npropdef.auto_super_inits
                                if auto_super_inits != null then
                                        for auto_super_init in auto_super_inits do
-                                               v.add_monomorphic_send(v.receiver, auto_super_init)
+                                               v.add_callsite(auto_super_init)
                                        end
                                end
                        else if npropdef isa AInternMethPropdef or
@@ -199,8 +207,6 @@ class RapidTypeAnalysis
                        for t in live_types do
                                if not ot.can_resolve_for(t, t, mainmodule) then continue
                                var rt = ot.anchor_to(mainmodule, t)
-                               if rt isa MNullableType then rt = rt.mtype
-                               assert rt isa MClassType
                                live_cast_types.add(rt)
                                #print "  {ot}/{t} -> {rt}"
                        end
@@ -253,11 +259,9 @@ class RapidTypeAnalysis
 
        fun add_cast(mtype: MType)
        do
-               if mtype isa MNullableType then mtype = mtype.mtype
                if mtype.need_anchor then
                        live_open_cast_types.add(mtype)
                else
-                       assert mtype isa MClassType
                        live_cast_types.add(mtype)
                end
        end
@@ -540,7 +544,7 @@ redef class ASuperExpr
                        return
                end
 
-               v.analysis.add_super_send(v.receiver, v.mpropdef.as(MMethodDef))
+               v.analysis.add_super_send(v.receiver, mpropdef.as(not null))
        end
 end