Java Reference
In-Depth Information
that are known to be supertypes of T j . This will be our candidate invocation of G in
the bound we infer for T j .
Define CandidateInvocation( G ) = lci(Inv( G )), where lci, the least containing invocation, is
defined:
• lci( S ) = lci( e 1 , ..., e n ) where e i (1 ≤ i n ) in S
• lci( e 1 , ..., e n ) = lci(lci( e 1 , e 2 ), e 3 , ..., e n )
• lci( G < X 1 , ..., X n > , G < Y 1 , ..., Y n > ) = G < lcta( X 1 , Y 1 ), ..., lcta( X n , Y n ) >
• lci( G < X 1 , ..., X n > ) = G < lcta( X 1 ), ..., lcta( X n ) >
where lcta() is the least containing type argument function defined (assuming U and V are
type expressions) as:
• lcta( U , V ) = U if U = V , otherwise ? extends lub( U , V )
• lcta( U , ? extends V ) = ? extends lub( U , V )
• lcta( U , ? super V ) = ? super glb( U , V )
• lcta( ? extends U , ? extends V ) = ? extends lub( U , V )
• lcta( ? extends U , ? super V ) = U if U = V , otherwise ?
• lcta( ? super U , ? super V ) = ? super glb( U , V )
• lcta( U ) = ? if U 's upper bound is Object , otherwise ? extends lub( U , Object )
where glb() is as defined in § 5.1.10 .
Finally, we define a bound for T j based on on all the elements of the minimal erased
candidate set of its supertypes. If any of these elements are generic, we use the Can-
didateInvocation() function to recover the type argument information.
Define Candidate( W ) = CandidateInvocation( W ) if W is generic, W otherwise.
The inferred type for T j , lub( U 1 ... U k ), is Candidate( W 1 ) & ... & Candidate( W r ), where W i
(1 ≤ i r ) are the elements of MEC.
It is possible that the process above yields an infinite type. This is permissible, and a Java
compiler must recognize such situations and represent them appropriately using cyclic data
structures.
The possibility of an infinite type stems from the recursive calls to lub(). Readers fa-
miliar with recursive types should note that an infinite type is not the same as a re-
cursive type.
Search WWH ::




Custom Search