mixin: introduce -D option to redefine functions from the command-line
[nit.git] / src / rapid_type_analysis.nit
index 0820839..7cbdaf9 100644 (file)
 # It is quite efficient but the type set is global and pollutes each call site.
 module rapid_type_analysis
 
-import model
-import modelbuilder
-import typing
-import auto_super_init
+import semantize
 
-import csv # for live_types_to_csv
-import ordered_tree # for live_methods_to_tree
+private import csv # for live_types_to_csv
+private import ordered_tree # for live_methods_to_tree
 
 private import more_collections
 
 redef class ModelBuilder
+       # Performs a rapid-type-analysis on the program associated with `mainmodule`.
        fun do_rapid_type_analysis(mainmodule: MModule): RapidTypeAnalysis
        do
                var analysis = new RapidTypeAnalysis(self, mainmodule)
@@ -242,17 +240,13 @@ class RapidTypeAnalysis
                                if mmeth.name == "init" then
                                        var nclassdef = self.modelbuilder.mclassdef2nclassdef[mmethoddef.mclassdef]
                                        assert mmethoddef == nclassdef.mfree_init
-                                       var super_inits = nclassdef.super_inits
-                                       if super_inits != null then
-                                               #assert args.length == 1
-                                               for su in super_inits do
-                                                       v.add_monomorphic_send(v.receiver, su)
-                                               end
-                                       end
 
                                        if mmethoddef.mproperty.is_root_init and not mmethoddef.is_intro then
                                                self.add_super_send(v.receiver, mmethoddef)
                                        end
+                               else if mmethoddef.constant_value != null then
+                                       # Make the return type live
+                                       v.add_type(mmethoddef.msignature.return_mtype.as(MClassType))
                                else
                                        abort
                                end