From d037517b9442111eb9a65df2572f4b810d2cacf2 Mon Sep 17 00:00:00 2001 From: Jean Privat Date: Thu, 27 Nov 2014 15:29:32 -0500 Subject: [PATCH] modelize: do not warn `useless-type` for a covariant redefinition of a getter return type. Signed-off-by: Jean Privat --- src/modelize/modelize_property.nit | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) 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 -- 1.7.9.5