-
Notifications
You must be signed in to change notification settings - Fork 27
Description
Describe the bug
According to the OMG specification for OCL (section 7.5.8. for OCL 2.4),
whenever properties are redefined within a type, the property of the supertypes can be accessed using the oclAsType() operation. Whenever we have a class B as a subtype of class A, and a property p1 of both A and B, we can write:
context B inv:
self.oclAsType(A).p1 -- accesses the p1 property defined in A
self.p1 -- accesses the p1 property defined in B
USE does not implement this behavior.
To Reproduce
Load the following model:
model AsTypeIssue
class A
operations
op():Integer = 1
end
class B < A
operations
op():Integer = self.oclAsType(A).op() + 1
end
After creating an instance of class B, evaluate the following expression:
B.allInstances()->any(true).op()
USE currently reports an error:
C:\Temp\issue_oclAsTYpe.use:9:36: Target type A is not a subtype of the source expression's type B.
Expected behavior
The output should be 2: Integer.
Additional context
The specification does only talk about properties (called attributes in USE). It must be examined how this should be done for operations, because in general, a operation call on type A should call the overridden body of 'B'. My personal view on this is hybrid usage of oclAsType is somehow ugly.