- if n_type.collect_text != v.toolcontext.place_holder_type_name then return
-
- var attr_name = "_" + n_expr.collect_text
- for mattrdef in v.mclassdef.mpropdefs do
- if mattrdef isa MAttributeDef and mattrdef.name == attr_name then
- var new_ntype = v.toolcontext.parse_something(mattrdef.static_mtype.to_s)
- n_type.replace_with new_ntype
- break
+ var deserializer_nclassdef = nmodule.deserializer_nclassdef
+ if deserializer_nclassdef == null then return
+ var deserializer_npropdef = deserializer_nclassdef.deserializer_npropdef
+ if deserializer_npropdef == null then return
+
+ # Collect local types expected to be deserialized
+ var types_to_deserialize = new Set[String]
+
+ ## Local serializable standard class without parameters
+ for nclassdef in nclassdefs do
+ var mclass = nclassdef.mclass
+ if mclass == null then continue
+
+ if mclass.arity == 0 and mclass.kind == concrete_kind then
+ types_to_deserialize.add mclass.name
+ end
+ end
+
+ ## Static parametized types on serializable attributes
+ for nclassdef in nmodule.n_classdefs do
+ if not nclassdef isa AStdClassdef then continue
+
+ for attribute in nclassdef.n_propdefs do
+ if not attribute isa AAttrPropdef then continue
+
+ var serialize_by_default = nclassdef.how_serialize
+ if serialize_by_default == null then continue
+ var per_attribute = not serialize_by_default
+
+ # Is `attribute` to be skipped?
+ if (per_attribute and not attribute.is_serialize) or
+ attribute.is_noserialize then continue
+
+ var mtype = attribute.mtype
+ if mtype == null then continue
+ if mtype isa MNullableType then mtype = mtype.mtype
+
+ if mtype isa MClassType and mtype.mclass.arity > 0 and
+ mtype.mclass.kind == concrete_kind and not mtype.need_anchor then
+
+ # Check is a `Serializable`
+ var mmodule = nmodule.mmodule
+ if mmodule == null then continue
+
+ var greaters = mtype.mclass.in_hierarchy(mmodule).greaters
+ var is_serializable = false
+ for sup in greaters do if sup.name == "Serializable" then
+ is_serializable = true
+ break
+ end
+
+ if is_serializable then types_to_deserialize.add mtype.to_s
+ end