- for mtype in rta.live_types do
- # We are only interested in instanciated generics, subtypes of Serializable
- # and which are visibles.
- if mtype isa MGenericType and
- mtype.is_subtype(mmodule, null, serializable_type) and
- mtype.is_visible_from(mmodule) then
-
- nit_module.content.add """
+ var compiled_types = new Array[MType]
+ for m in target_modules do
+ nit_module.content.add """
+ # Module: {{{m.to_s}}}"""
+
+ var rta = modelbuilder.do_rapid_type_analysis(m)
+
+ for mtype in rta.live_types do
+ # We are only interested in instanciated generics, subtypes of Serializable
+ # and which are visible.
+ if mtype isa MGenericType and
+ mtype.is_subtype(m, null, serializable_type) and
+ mtype.mclass.kind == concrete_kind and
+ not compiled_types.has(mtype) then
+
+ # Intrude import the modules declaring private classes
+ var related_mclasses = mtype.related_mclasses(mmodule)
+ for mclass in related_mclasses do
+ if not mmodule.is_visible(mclass.intro_mmodule, mclass.visibility) then
+ var intro_mmodule = mclass.intro_mmodule
+ var intro_mgroup = intro_mmodule.mgroup
+
+ var to_import = intro_mmodule.full_name
+ if intro_mgroup == null or intro_mgroup.default_mmodule == intro_mmodule then
+ to_import = intro_mmodule.name
+ end
+
+ nit_module.imports.add "intrude import {to_import}"
+ end
+ end
+
+ compiled_types.add mtype
+ nit_module.content.add """