<< §1.2.2.(a) Visibility | ↑ Table of Contents ↑ | §1.2.2.(c) Immutable anchor >> |
§1.2.2.(b) Declaration with anchored type
Outside a team role types are legal only if denoted relative to an existing team instance (further on called "anchored types"). The syntax is:
final MyTeam myTeam = expression; RoleClass<@myTeam> role = expression;
The syntax Type<@anchor>
is a special case of a parameterized type, more specifically a value dependent type (§9).
The type argument (i.e., the expression after the at-sign) can be a simple name or a path. It must refer to an instance
of a team class.
The role type is said to be anchored to this team instance.
The type-part of this syntax (in front of the angle brackets) must be the simple name of a role type directly contained
in the given team (including roles that are acquired by implicit inheritance).
Note:
Previous versions of the OTJLD used a different syntax for anchored types, where the role type was prefixed with the anchor expression, separated by a dot (anchor.Type
,
see §A.6.3). A compiler may still support that path syntax but it should be flagged as being deprecated.
<< §1.2.2.(a) Visibility | ↑ Table of Contents ↑ | §1.2.2.(c) Immutable anchor >> |