-
Bug
-
Resolution: Unresolved
-
P4
-
8
Following code fails to compile:
public class Test10 {
interface Iface<T extends U, U> { }
public static void main(String argv[]) {
Iface<? extends Integer, ? super Number> i = null;
}
}
however according to JLS8 4.5:
"A parameterized type C<T1,...,Tn> is well-formed if ... when subjected to capture conversion (§5.1.10) resulting in the type C<X1,...,Xn>, each type argument Xi is a subtype of S[F1:=X1,...,Fn:=Xn] for each bound type S in Bi."
In this case, given 'CAP1 extends Integer' and 'CAP2 super Number', Iface<CAP1, CAP2> is within its bounds -- CAP1 is a subtype of CAP2.
Swapping T and U causes compilation to succeed:
public class Test11 {
interface Iface2<U, T extends U > { }
public static void main(String argv[]) {
Iface2<? super Number, ? extends Integer> i2 = null;
}
}
The code above is attached.
public class Test10 {
interface Iface<T extends U, U> { }
public static void main(String argv[]) {
Iface<? extends Integer, ? super Number> i = null;
}
}
however according to JLS8 4.5:
"A parameterized type C<T1,...,Tn> is well-formed if ... when subjected to capture conversion (§5.1.10) resulting in the type C<X1,...,Xn>, each type argument Xi is a subtype of S[F1:=X1,...,Fn:=Xn] for each bound type S in Bi."
In this case, given 'CAP1 extends Integer' and 'CAP2 super Number', Iface<CAP1, CAP2> is within its bounds -- CAP1 is a subtype of CAP2.
Swapping T and U causes compilation to succeed:
public class Test11 {
interface Iface2<U, T extends U > { }
public static void main(String argv[]) {
Iface2<? super Number, ? extends Integer> i2 = null;
}
}
The code above is attached.
- is blocked by
-
JDK-8039222 5.1.10: Define glb for non-class types
-
- Open
-
-
JDK-8043351 4.5: Capture to check well-formedness of a parameterized type may be undefined
-
- Open
-