Super class implementation for inherited attribute

Issue #273 new
Jesper Mattsson created an issue

It would be very useful to be able to explicitly call the superclass implementation of an inherited attribute (without using internal JastAdd APIs).

Something like:

inh int A.x();
eq B.getChild().x() = <some calculation>;
eq C.getChild().x() = <some condition> ? <some other calculation> : super.getChild().x();

Where C is a subclass of B.

JModelica.org has quite a few places where a subclass needs to override an inherited attribute only if some condition is fulfilled. Currently you must then duplicate the superclass implementation, with all the problems code duplication brings.

For those cases, it would work just as well to be able to add a conditional for the equation, kind of like for rewrites. That would solve what seems to me like the most common issue, but wouldn't be as general. I guess that would be easier to fit into the current implementation, since it already uses if-else-if for what children to define the attribute for.

For that version, maybe something like:

inh int A.x();
eq B.getChild().x() = <some calculation>;
eq C.getChild().x() when (<some condition>) = <some other calculation>;

Comments (1)

  1. Log in to comment