X-Git-Url: http://nitlanguage.org diff --git a/src/modelize/modelize_property.nit b/src/modelize/modelize_property.nit index 7e1a93a..0d2e3a6 100644 --- a/src/modelize/modelize_property.nit +++ b/src/modelize/modelize_property.nit @@ -631,7 +631,7 @@ redef class AMethPropdef modelbuilder.error(node, "Redef error: {mpropdef} redefines {mpropdef.mproperty.intro} with {param_names.length} parameter(s), {msignature.arity} expected. Signature is {mpropdef}{msignature}") return end - else if mpropdef.mproperty.is_init then + else if mpropdef.mproperty.is_init and not mpropdef.mproperty.is_new then # FIXME UGLY: inherit signature from a super-constructor for msupertype in mclassdef.supertypes do msupertype = msupertype.anchor_to(mmodule, mclassdef.bound_mtype) @@ -671,6 +671,9 @@ redef class AMethPropdef mparameters.add(mparameter) end + # In `new`-factories, the return type is by default the classtype. + if ret_type == null and mpropdef.mproperty.is_new then ret_type = mclassdef.mclass.mclass_type + msignature = new MSignature(mparameters, ret_type) mpropdef.msignature = msignature mpropdef.is_abstract = self.get_single_annotation("abstract", modelbuilder) != null