Wed, 13 Aug 2014 14:50:00 -0700
Added tag jdk8u40-b01 for changeset bf89a471779d
aoqi@0 | 1 | /* |
aoqi@0 | 2 | * @test /nodynamiccopyright/ |
aoqi@0 | 3 | * @author mcimadamore |
aoqi@0 | 4 | * @bug 6714835 |
aoqi@0 | 5 | * @summary Safe cast is rejected (with warning) by javac |
aoqi@0 | 6 | * @compile/fail/ref=T6714835.out -Xlint:unchecked -Werror -XDrawDiagnostics T6714835.java |
aoqi@0 | 7 | */ |
aoqi@0 | 8 | |
aoqi@0 | 9 | import java.util.*; |
aoqi@0 | 10 | |
aoqi@0 | 11 | class T6714835 { |
aoqi@0 | 12 | void cast1(Iterable<? extends Integer> x) { |
aoqi@0 | 13 | Collection<? extends Number> x1 = (Collection<? extends Number>)x; //ok |
aoqi@0 | 14 | Collection<? super Integer> x2 = (Collection<? super Integer>)x; //warn |
aoqi@0 | 15 | } |
aoqi@0 | 16 | |
aoqi@0 | 17 | void cast2(Iterable<? super Number> x) { |
aoqi@0 | 18 | Collection<? super Integer> x1 = (Collection<? super Integer>)x; //ok |
aoqi@0 | 19 | Collection<? extends Number> x2 = (Collection<? extends Number>)x; //warn |
aoqi@0 | 20 | } |
aoqi@0 | 21 | } |