Interfaces can be nested. An interface can include one or more interfaces as components, which can contain interfaces themselves. An interface that includes another interface is called a compound interface. An interface nested within an interface is called a component interface. An interface that does not contain any compound interfaces is called an elementary interface.
All interface components of a compound interface have the same level. If a compound interface i3 contains another compound interface i2, its interface component i1 becomes interface component of i3. A compound interface includes each interface component exactly once. A component interface exists only once even if it is used again as a component of another component interface.
The statement INTERFACES is used for nesting interfaces within an interface definition:
Here the interface i3 consists of its components and the interfaces i1 and i2. In the compound interface the components of the component interfaces are visible using the interface component selector (~). Within the above definition of i3, expressions such as i1~comp or i2~comp are possible. However, you can define your own names using the ALIASES statement.
Within interface definitions, the statement ALIASES can be used to assign alias names to the components of component interfaces, and therefore make those nested to a depth greater than one level visible within the interface definition.
Reference variables typed with reference to a compound interface can be assigned reference variables typed with reference to one of the component interfaces ( up cast). The latter can be used to address the components of the component interfaces. The opposite case cannot be checked statically and must take place with the casting casting operator (?=) (down cast).
When a nested interface is implemented in a class, all associated interfaces are implemented in the class at the same level irrespective of their nesting hierarchy and the class must implement all methods only once.
You can always assign reference variables using up cast. Class reference variables for classes that implement a compound interface can be assigned to all interface references that are typed with reference to an associated interface component. In the class, the interface reference variables know only the components of their respective interfaces. Similarly, interface reference variables that are typed using one compound interface can be assigned to all interface reference variables that are typed with one of these component interfaces. It is possible to access components using the interface component selector, but this is not recommended. Compound expressions such as cref->i3~i2~comp2 or cref->i3~i2~i3~comp3 are not possible.