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

Wed, 27 Apr 2016 01:34:52 +0800

author
aoqi
date
Wed, 27 Apr 2016 01:34:52 +0800
changeset 0
959103a6100f
permissions
-rw-r--r--

Initial load
http://hg.openjdk.java.net/jdk8u/jdk8u/langtools/
changeset: 2573:53ca196be1ae
tag: jdk8u25-b17

     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