model: avoid full_name conflict with global properties
authorJean Privat <jean@pryen.org>
Sat, 23 Apr 2016 21:02:58 +0000 (17:02 -0400)
committerJean Privat <jean@pryen.org>
Wed, 27 Apr 2016 13:51:03 +0000 (09:51 -0400)
Signed-off-by: Jean Privat <jean@pryen.org>

src/model/model.nit

index ea1e025..2005fca 100644 (file)
@@ -1953,10 +1953,21 @@ abstract class MProperty
 
        # The canonical name of the property.
        #
-       # It is the short-`name` prefixed by the short-name of the class and the full-name of the module.
+       # It is currently the short-`name` prefixed by the short-name of the class and the full-name of the module.
        # Example: "my_package::my_module::MyClass::my_method"
+       #
+       # The full-name of the module is needed because two distinct modules of the same package can
+       # still refine the same class and introduce homonym properties.
+       #
+       # For public properties not introduced by refinement, the module name is not used.
+       #
+       # Example: `my_package::MyClass::My_method`
        redef var full_name is lazy do
-               return "{intro_mclassdef.mmodule.namespace_for(visibility)}::{intro_mclassdef.mclass.name}::{name}"
+               if intro_mclassdef.is_intro then
+                       return "{intro_mclassdef.mmodule.namespace_for(visibility)}::{intro_mclassdef.mclass.name}::{name}"
+               else
+                       return "{intro_mclassdef.mmodule.full_name}::{intro_mclassdef.mclass.name}::{name}"
+               end
        end
 
        redef var c_name is lazy do