Java Reference
In-Depth Information
Here, we have A = G <? super V > << G <? extends U > . In general, we cannot con-
clude anything in this case. However, it is not necessarily an error. It may be
that U will eventually be inferred to be Object , in which case the call may in-
deed be valid. Therefore, we simply refrain from placing any constraint on U .
• If F has the form G < ..., Y k-1 , ? super U , Y k+1 , ... > , where U involves T j , then if A has
a supertype that is one of:
G < ..., X k-1 , V , X k+1 , ... > . Then this algorithm is applied recursively to the con-
straint V >> U .
As usual, we consider only the case where G has a single type argument.
A << F in this case means A << G <? super U > . As above, it must be the case
that A is a subtype of some invocation of G . A may now be a subtype of either
G < V > , or G <? extends V > , or G <? super V > . We examine these cases in turn. The
first variation is described (generalized to multiple arguments) by the sub-bul-
let directly above. We therefore have A = G < V > << G <? super U > . The rules of
subtyping for wildcards imply that V >> U .
G < ..., X k-1 , ? super V , X k+1 , ... > . Then this algorithm is applied recursively to the
constraint V >> U .
We have A = G <? super V > << G <? super U > . The rules of subtyping for lower-
bounded wildcards again imply that V >> U .
♦ Otherwise, no constraint is implied on T j .
Here, we have A = G <? extends V > << G <? super U > . In general, we cannot con-
clude anything in this case. However, it is not necessarily an error. It may be
that U will eventually be inferred to the null type, in which case the call may
indeed be valid. Therefore, we simply refrain from placing any constraint on
U .
• Otherwise, no constraint is implied on T j .
3. Otherwise, if the constraint has the form A = F :
• If F = T j , then the constraint T j = A is implied.
• If F = U [] where the type U involves T j , then if A is an array type V [] , or a type
variable with an upper bound that is an array type V [] , where V is a reference type,
this algorithm is applied recursively to the constraint V = U .
If the array types U [] and V [] are the same, their component types must be the
same.
Search WWH ::




Custom Search