<< §2.4.2.(b) Bound roles | ↑ Table of Contents ↑ |
§2.4.2.(c) Super-call for bound roles
Instead of or prior to calling base(..)
a constructor of a bound role explicitly or implicitly calls a super constructor.
Which constructor is applicable depends on the super role and its playedBy
clause.
- If the super role is bound to the same base class as the current role is,
- not writing a super-call causes the lifting constructor of the super role to be invoked.
- explicitly calling a super constructor requires the super constructor to either
- create a role instance using a base constructor call (directly or indirectly), or
- be a lifting constructor receiving a base instance, which the current role must provide as the argument.
- If the super role is bound but the current role refines the
playedBy
relationship (cf. §2.1.(c)),- a lifting constructor must be called explicitly passing a base object as the argument.
- If the role has an explicit or implicit super role which is unbound the constructor may optionally
call a super constructor (using
super(..)
ortsuper(..)
) prior to callingbase(..)
. Otherwise the default constructor is implicitly invoked.
When invoking a lifting constructor of a super role the base object can optionally be obtained by using a base constructor call as an expression:
super(base(<args>));
<< §2.4.2.(b) Bound roles | ↑ Table of Contents ↑ |