Java Reference
In-Depth Information
• For 1 ≤ j n , if T j is a type variable, then let T j ' be an interface whose members are
the same as the public members of T j ; otherwise, if T j is an interface, then let T j ' be
T j .
• Then the intersection type has the same members as a class type (§8) with an
empty body, direct superclass C k and direct superinterfaces T 1 ', ..., T n ', declared in
the same package in which the intersection type appears.
It is worth dwelling upon the distinction between intersection types and the
bounds of type variables. Every type variable bound induces an intersection
type. This intersection type is often trivial (i.e., consists of a single type). The
form of a bound is restricted (only the first element may be a class or type vari-
able, and only one type variable may appear in the bound) to preclude certain
awkward situations coming into existence. However, capture conversion can
lead to the creation of type variables whose bounds are more general (e.g., ar-
ray types).
4.10. Subtyping
The subtype and supertype relations are binary relations on types.
The supertypes of a type are obtained by reflexive and transitive closure over the direct
supertype relation, written S > 1 T , which is defined by rules given later in this section. We
write S :> T to indicate that the supertype relation holds between S and T .
S is a proper supertype of T , written S > T , if S :> T and S T .
The subtypes of a type T are all types U such that T is a supertype of U , and the null type.
We write T <: S to indicate that that the subtype relation holds between types T and S .
T is a proper subtype of S , written T < S , if T <: S and S T .
T is a direct subtype of S , written T < 1 S , if S > 1 T .
Subtyping does not extend through parameterized types: T <: S does not imply that C < T > <:
C < S > .
4.10.1. Subtyping among Primitive Types
The following rules define the direct supertype relation among the primitive types:
double > 1 float
float > 1 long
Search WWH ::




Custom Search