<< §1.3.1 Acquisition and implicit inheritance of role classes | ↑ Table of Contents ↑ |
§1.3.2 Regular role inheritance
In addition to implicit inheritance, roles may also inherit using
the standard Java keyword extends
. These restrictions apply:
(a) Super-class restrictions
If the super-class of a role is again a role it must be a direct role of
an enclosing team
This rule is simply enforced by disallowing type anchors in the
extends
clause
(see §1.2.2.(g)).
As an effect, the super-class may never be more deeply nested than the sub-class.
(b) Inheriting and overriding the extends clause
If a role overrides another role by implicit inheritance, it may
change the inherited extends
clause
(see §1.3.1.(g) above) only if the new super-class
is a sub-class of the class in the overridden extends clause.
I.e., an implicit sub-role may specialize the extends clause of its
implicit super-role.
(c) Constructors and overridden 'extends'
Each constructor of a role class that overrides the extends clause of its
implicit super-role must invoke a constructor of this newly introduced
explicit super-class. Thus it may not use a tsuper
constructor
(see §2.4.2).
(d) Adding implemented interfaces
implements
declarations are additive, i.e., an implicit
sub-role may add more interfaces but has to implement all interfaces of
its implicit super-role, too.
(e) Visibility of inherited methods
When a role inherits non-public methods from a regular class (as its super class),
these methods are considered as private for the role, i.e., they can only be
accessed in an unqualified method call m()
using the implicit receiver this
.
<< §1.3.1 Acquisition and implicit inheritance of role classes | ↑ Table of Contents ↑ |