super

super refers to the current instance of the class or interface that immediately contains the immediately containing class or interface (like this, but as if it were an instance of the intersection of the supertypes of the immediately containing class or interface.

Usage

This example shows super being used to distingush a member of the Inner class from a member of the same name in the Outer class:

class Example() extends Foo() satisfies Bar & Baz {
    shared actual Integer hash => 3 + super.hash;
}

Description

Type

The type of super is the intersection of the supertypes of the immediately containing class or interface. In the above example super has the type Foo&Bar&Baz.

Because super refers to the instance of the immediately containing class or interface it cannot be used in contexts where there is no such class or interface, such as in top level methods or values.

Of

Continuing the above example, if Bar and Baz both refined hash then super.hash would be an error (since it would be ambiguous). In such cases the of is used to clarify which supertype is intended:

shared actual Integer hash => 3 + (super of Bar).hash;

See also