test/tools/javac/cast/6714835/T6714835.java

Mon, 02 Sep 2013 22:38:36 +0100

author
vromero
date
Mon, 02 Sep 2013 22:38:36 +0100
changeset 2000
4a6acc42c3a1
parent 0
959103a6100f
permissions
-rw-r--r--

8016177: structural most specific and stuckness
Reviewed-by: jjg, vromero
Contributed-by: maurizio.cimadamore@oracle.com

     1 /*
     2  * @test /nodynamiccopyright/
     3  * @author mcimadamore
     4  * @bug     6714835
     5  * @summary Safe cast is rejected (with warning) by javac
     6  * @compile/fail/ref=T6714835.out -Xlint:unchecked -Werror -XDrawDiagnostics T6714835.java
     7  */
     9 import java.util.*;
    11 class T6714835 {
    12     void cast1(Iterable<? extends Integer> x) {
    13         Collection<? extends Number> x1 = (Collection<? extends Number>)x; //ok
    14         Collection<? super Integer> x2 = (Collection<? super Integer>)x; //warn
    15     }
    17     void cast2(Iterable<? super Number> x) {
    18         Collection<? super Integer> x1 = (Collection<? super Integer>)x; //ok
    19         Collection<? extends Number> x2 = (Collection<? extends Number>)x; //warn
    20     }
    21 }

mercurial