language-lawyerumlocl

OCL keyword 'self' and UML Classifier::inheritedMember()


This is defined on page 176 of the PDF file for the UML 2.5.1 specification:

Classifier (section 9.9.4.7 "Operations"):

• inheritedMember() : NamedElement [0..*]
The inheritedMember association is derived by inheriting the inheritable members of the parents.

body: inherit(parents()->collect(inheritableMembers(self))->asSet())
                                                    ^^^^

Does the keyword self refer to an element in the parents() set, or to the Classifier which defines the inheritedMember() operation? From the textual description, I would think it would be the element of the parents() collection, but I'm not sure. The other option doesn't really make sense to me.


Solution

  • After further reading, I believe that 'self' as used here does indeed refer to the usual context of the object invoking the operation, as self is defined in the OCL reference. Looking at the implementation of inheritableMembers(), which merely checks to make sure that its members are visible to the Classifier argument (i.e. no private members can be inherited), it now makes sense to me.