Whenever features are redefined within a type, the feature of the supertypes can be accessed using the oclAsType() operation. Whenever you have a class B as a subtype of class A , and a feature f1 of both A and B , you can write context B inv : self.oclAsType(A).f1 -- accesses the f1 feature defined in A inv : self.f1 -- accesses the f1 feature defined in B Figure 10-3 shows an example where such a construct is needed. This model fragment contains an ambiguity in the following OCL expression on class Dependency : context Dependency inv : self.source <> self Figure 10-3. Accessing overridden features example
This can mean either normal association navigation, which is inherited from ModelElement , or it might mean navigation through the dotted line as an association class. Both possible navigations use the same rolename, so this is always ambiguous. Using oclAsType(), you can distinguish between them with context Dependency inv : self.oclAsType(Dependency).source <> self or context Dependency inv : self.oclAsType(ModelElement).source <> self |