§2.1.2.(d) Base imports
If the main type in a file denotes a team, the modifier base
can be applied to a single import in order to specify that this type
should be imported for application as a base type only. Example:
1 |
import base some.pack.MyBase; |
2 |
public team class MyTeam { |
3 |
|
4 |
protected class MyRole playedBy MyBase { } |
5 |
MyBase illegalDeclaration; |
6 |
} |
Base imports cannot be on-demand imports (using the wildcard .*
).
Types imported by a base import can only be used in the same positions where also base class decapsulation (§2.1.2.(c))
is applicable.
It is recommended that a type mentioned after the keyword playedBy
is always imported with the base
modifier, otherwise the compiler
will give a warning.
Base imports create a scope that is disjoint from the normal scope. Thus, names that are imported as base will never clash
with normally visible names
(in contrast to §1.4). More specifically, it is not a problem to use a base class's name also for its role if a base import is used.