Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Call of implementations in superclass not supported #69

Open
h-man2 opened this issue Aug 22, 2023 · 0 comments
Open

Call of implementations in superclass not supported #69

h-man2 opened this issue Aug 22, 2023 · 0 comments
Labels
bug Something isn't working

Comments

@h-man2
Copy link
Contributor

h-man2 commented Aug 22, 2023

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.

@h-man2 h-man2 added the bug Something isn't working label Aug 22, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

1 participant