test/tools/javac/generics/diamond/neg/Neg03.java

Mon, 21 Jan 2013 20:13:56 +0000

author
mcimadamore
date
Mon, 21 Jan 2013 20:13:56 +0000
changeset 1510
7873d37f5b37
parent 914
ca32f2986301
child 2525
2eb010b6cb22
permissions
-rw-r--r--

8005244: Implement overload resolution as per latest spec EDR
Summary: Add support for stuck expressions and provisional applicability
Reviewed-by: jjg

mcimadamore@537 1 /*
mcimadamore@537 2 * @test /nodynamiccopyright/
mcimadamore@914 3 * @bug 6939620 7020044
mcimadamore@537 4 *
mcimadamore@914 5 * @summary Check that diamond fails when inference violates declared bounds
mcimadamore@914 6 * (test with inner class, qualified/simple type expressions)
mcimadamore@537 7 * @author mcimadamore
mcimadamore@537 8 * @compile/fail/ref=Neg03.out Neg03.java -XDrawDiagnostics
mcimadamore@537 9 *
mcimadamore@537 10 */
mcimadamore@537 11
mcimadamore@537 12 class Neg03<U> {
mcimadamore@537 13
mcimadamore@537 14 class Foo<V extends Number> {
mcimadamore@537 15 Foo(V x) {}
mcimadamore@537 16 <Z> Foo(V x, Z z) {}
mcimadamore@537 17 }
mcimadamore@537 18
mcimadamore@537 19 void testSimple() {
mcimadamore@537 20 Foo<String> f1 = new Foo<>("");
mcimadamore@537 21 Foo<? extends String> f2 = new Foo<>("");
mcimadamore@537 22 Foo<?> f3 = new Foo<>("");
mcimadamore@537 23 Foo<? super String> f4 = new Foo<>("");
mcimadamore@537 24
mcimadamore@914 25 Foo<String> f5 = new Foo<>("", "");
mcimadamore@914 26 Foo<? extends String> f6 = new Foo<>("", "");
mcimadamore@914 27 Foo<?> f7 = new Foo<>("", "");
mcimadamore@914 28 Foo<? super String> f8 = new Foo<>("", "");
mcimadamore@537 29 }
mcimadamore@537 30
mcimadamore@537 31 void testQualified_1() {
mcimadamore@537 32 Foo<String> f1 = new Neg03<U>.Foo<>("");
mcimadamore@537 33 Foo<? extends String> f2 = new Neg03<U>.Foo<>("");
mcimadamore@537 34 Foo<?> f3 = new Neg03<U>.Foo<>("");
mcimadamore@537 35 Foo<? super String> f4 = new Neg03<U>.Foo<>("");
mcimadamore@537 36
mcimadamore@914 37 Foo<String> f5 = new Neg03<U>.Foo<>("", "");
mcimadamore@914 38 Foo<? extends String> f6 = new Neg03<U>.Foo<>("", "");
mcimadamore@914 39 Foo<?> f7 = new Neg03<U>.Foo<>("", "");
mcimadamore@914 40 Foo<? super String> f8 = new Neg03<U>.Foo<>("", "");
mcimadamore@537 41 }
mcimadamore@537 42
mcimadamore@537 43 void testQualified_2(Neg03<U> n) {
mcimadamore@537 44 Foo<String> f1 = n.new Foo<>("");
mcimadamore@537 45 Foo<? extends String> f2 = n.new Foo<>("");
mcimadamore@537 46 Foo<?> f3 = n.new Foo<>("");
mcimadamore@537 47 Foo<? super String> f4 = n.new Foo<>("");
mcimadamore@537 48
mcimadamore@914 49 Foo<String> f5 = n.new Foo<>("", "");
mcimadamore@914 50 Foo<? extends String> f6 = n.new Foo<>("", "");
mcimadamore@914 51 Foo<?> f7 = n.new Foo<>("", "");
mcimadamore@914 52 Foo<? super String> f8 = n.new Foo<>("", "");
mcimadamore@537 53 }
mcimadamore@537 54 }

mercurial