- nclassdef.super_inits = combine
- var mprop = new MMethod(mclassdef, "init", mclassdef.mclass.visibility)
- var mpropdef = new MMethodDef(mclassdef, mprop, nclassdef.location)
- var mparameters = new Array[MParameter]
- var msignature = new MSignature(mparameters, null)
- mpropdef.msignature = msignature
- mprop.is_init = true
- nclassdef.mfree_init = mpropdef
- self.toolcontext.info("{mclassdef} gets a free empty constructor {mpropdef}{msignature}", 3)
- return
- end
-
- # Collect undefined attributes
- var mparameters = new Array[MParameter]
- for npropdef in nclassdef.n_propdefs do
- if npropdef isa AAttrPropdef and npropdef.n_expr == null then
- if npropdef.mpropdef == null then return # Skip broken attribute
- var paramname = npropdef.mpropdef.mproperty.name.substring_from(1)
- var ret_type = npropdef.mpropdef.static_mtype
- if ret_type == null then return
- var mparameter = new MParameter(paramname, ret_type, false)
- mparameters.add(mparameter)
+ if mparameters.is_empty and combine.length == 1 then
+ # No need to create a local init, the inherited one is enough
+ inhc = combine.first.intro_mclassdef.mclass
+ mclassdef.mclass.inherit_init_from = inhc
+ self.toolcontext.info("{mclassdef} inherits all constructors from {inhc}", 3)
+ return