From: Jean Privat Date: Thu, 27 Nov 2014 20:29:32 +0000 (-0500) Subject: modelize: do not warn `useless-type` for a covariant redefinition of a getter return... X-Git-Tag: v0.6.11~4^2~2 X-Git-Url: http://nitlanguage.org modelize: do not warn `useless-type` for a covariant redefinition of a getter return type. Signed-off-by: Jean Privat --- diff --git a/src/modelize/modelize_property.nit b/src/modelize/modelize_property.nit index 81b3245..440f245 100644 --- a/src/modelize/modelize_property.nit +++ b/src/modelize/modelize_property.nit @@ -945,11 +945,13 @@ redef class AAttrPropdef if mtype == null then return end + var inherited_type: nullable MType = null # Inherit the type from the getter (usually an abstract getter) - if mtype == null and mreadpropdef != null and not mreadpropdef.is_intro then + if mreadpropdef != null and not mreadpropdef.is_intro then var msignature = mreadpropdef.mproperty.intro.msignature if msignature == null then return # Error, thus skipped - mtype = msignature.return_mtype + inherited_type = msignature.return_mtype + if mtype == null then mtype = inherited_type end var nexpr = self.n_expr @@ -981,7 +983,7 @@ redef class AAttrPropdef if mtype == null then return end - else if ntype != null then + else if ntype != null and inherited_type == mtype then if nexpr isa ANewExpr then var xmtype = modelbuilder.resolve_mtype(mmodule, mclassdef, nexpr.n_type) if xmtype == mtype then