model: add MClass::in_hierarchy
authorJean Privat <jean@pryen.org>
Tue, 6 Nov 2012 04:49:09 +0000 (23:49 -0500)
committerJean Privat <jean@pryen.org>
Tue, 6 Nov 2012 04:49:09 +0000 (23:49 -0500)
More usable than MModule::flatten_mclass_hierarchy.

Signed-off-by: Jean Privat <jean@pryen.org>

src/model/model.nit

index 3410d2f..30fa17f 100644 (file)
@@ -301,6 +301,15 @@ class MClass
                return mclassdefs.first
        end
 
+       # Return the class `self' in the class hierarchy of the module `mmodule'.
+       #
+       # SEE: MModule::flatten_mclass_hierarchy
+       # REQUIRE: mmodule.has_mclass(self)
+       fun in_hierarchy(mmodule: MModule): POSetElement[MClass]
+       do
+               return mmodule.flatten_mclass_hierarchy[self]
+       end
+
        # The principal static type of the class.
        #
        # For non-generic class, mclass_type is the only MClassType based