non-wildcard parameterization
Stephan Herrmann
stephan.herrmann at berlin.de
Thu Feb 6 08:44:54 PST 2014
I don't understand the javac behavior for the following example:
interface I<T, S extends X<T>> {
T foo(S p);
}
public class X<T> {
public void bar() {
I<Object, ? extends X<Object>> f = (p) -> p;
}
}
javac accepts, but I don't see how the non-wildcard parameterization of I
can be determined for this case.
I believe compilation should fail during this sentence from 9.8:
"If Ai is a wildcard, and the corresponding type parameter bound, Bi,
mentions one of P1...Pn, then Ti is undefined and there is no function type."
From the LHS of the assignment:
F<A1...An> = I<Object,? extends X<Object>>
A1 = Object
A2 = ? extends X<Object>
From the declaration of I:
P1 = T
P2 = S extends X<T>
B1 = n/a
B2 = X<T>
A2 (? extends X<Object>) is a wildcard, and the corresponding bound, B2 (X<T>),
mentions P1 (T), hence Ti is undefined and there is no function type.
is my interpretation of the spec correct?
thanks,
Stephan
More information about the lambda-spec-experts
mailing list