X-Git-Url: http://nitlanguage.org diff --git a/src/rapid_type_analysis.nit b/src/rapid_type_analysis.nit index e56951b..e2422aa 100644 --- a/src/rapid_type_analysis.nit +++ b/src/rapid_type_analysis.nit @@ -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 @@ -153,12 +161,16 @@ class RapidTypeAnalysis v.add_monomorphic_send(v.receiver, auto_super_init) end end - else if npropdef isa AInternMethPropdef or npropdef isa AExternMethPropdef then + else if npropdef isa AInternMethPropdef or + (npropdef isa AExternMethPropdef and npropdef.n_extern != null) then # UGLY: We force the "instantation" of the concrete return type if any var ret = mmethoddef.msignature.return_mtype if ret != null and ret isa MClassType and ret.mclass.kind != abstract_kind and ret.mclass.kind != interface_kind then v.add_type(ret) end + else if npropdef isa AExternMethPropdef then + var nclassdef = npropdef.parent.as(AClassdef) + v.enter_visit(npropdef) else if npropdef isa AExternInitPropdef then v.add_type(v.receiver) else