model: select_most_specific behave correctly when given comparable propdefs
authorJean Privat <jean@pryen.org>
Tue, 18 Feb 2014 20:26:59 +0000 (15:26 -0500)
committerJean Privat <jean@pryen.org>
Tue, 18 Feb 2014 20:37:21 +0000 (15:37 -0500)
Keep all occurences of comparable but distinct propdefs.
This case should not occurs in sane usage of the function.
But having a good behavior is good nevertheless.

Reported-by: Lucas Bajolet <lucas.bajolet@hotmail.com
Signed-off-by: Jean Privat <jean@pryen.org>

src/model/model.nit

index b19e124..ad1c325 100644 (file)
@@ -1612,12 +1612,12 @@ abstract class MProperty
                                var cd2 = pd2.mclassdef
                                var c2 = cd2.mclass
                                if c2.mclass_type == c1.mclass_type then
-                                       if cd2.mmodule.in_importation <= cd1.mmodule then
+                                       if cd2.mmodule.in_importation < cd1.mmodule then
                                                # cd2 refines cd1; therefore we skip pd1
                                                keep = false
                                                break
                                        end
-                               else if cd2.bound_mtype.is_subtype(mmodule, null, cd1.bound_mtype) then
+                               else if cd2.bound_mtype.is_subtype(mmodule, null, cd1.bound_mtype) and cd2.bound_mtype != cd1.bound_mtype then
                                        # cd2 < cd1; therefore we skip pd1
                                        keep = false
                                        break