test/langtools/tools/javac/generics/odersky/BadTest4.java
author darcy
Thu, 12 Jul 2018 14:13:15 -0700
changeset 51047 860a3648c494
parent 47216 71c04702a3d5
permissions -rw-r--r--
8028563: Remove javac support for 6/1.6 source and target values Reviewed-by: jjg, erikj, henryjen
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
10
06bc494ca11e Initial load
duke
parents:
diff changeset
     1
/*
30721
1024d425d97e 8074425: Group 13b: golden files for tests in tools/javac/generics dir
sogoel
parents: 22448
diff changeset
     2
 * @test /nodynamiccopyright/
1024d425d97e 8074425: Group 13b: golden files for tests in tools/javac/generics dir
sogoel
parents: 22448
diff changeset
     3
 * @bug 4736963
10
06bc494ca11e Initial load
duke
parents:
diff changeset
     4
 * @summary Negative regression test from odersky
06bc494ca11e Initial load
duke
parents:
diff changeset
     5
 * @author odersky
06bc494ca11e Initial load
duke
parents:
diff changeset
     6
 *
51047
860a3648c494 8028563: Remove javac support for 6/1.6 source and target values
darcy
parents: 47216
diff changeset
     7
 * @compile/fail/ref=BadTest4.out -XDrawDiagnostics -source 7 -Xlint:-options BadTest4.java
15717
ab55670d2e62 8007464: Add graph inference support
mcimadamore
parents: 5520
diff changeset
     8
 * @compile BadTest4.java
10
06bc494ca11e Initial load
duke
parents:
diff changeset
     9
 */
06bc494ca11e Initial load
duke
parents:
diff changeset
    10
06bc494ca11e Initial load
duke
parents:
diff changeset
    11
class BadTest4 {
06bc494ca11e Initial load
duke
parents:
diff changeset
    12
06bc494ca11e Initial load
duke
parents:
diff changeset
    13
    interface I {}
06bc494ca11e Initial load
duke
parents:
diff changeset
    14
    interface J {}
06bc494ca11e Initial load
duke
parents:
diff changeset
    15
    static class C implements I, J {}
06bc494ca11e Initial load
duke
parents:
diff changeset
    16
    static class D implements I, J {}
06bc494ca11e Initial load
duke
parents:
diff changeset
    17
06bc494ca11e Initial load
duke
parents:
diff changeset
    18
    interface Ord {}
06bc494ca11e Initial load
duke
parents:
diff changeset
    19
06bc494ca11e Initial load
duke
parents:
diff changeset
    20
    static class Main {
06bc494ca11e Initial load
duke
parents:
diff changeset
    21
06bc494ca11e Initial load
duke
parents:
diff changeset
    22
        static C c = new C();
06bc494ca11e Initial load
duke
parents:
diff changeset
    23
        static D d = new D();
06bc494ca11e Initial load
duke
parents:
diff changeset
    24
06bc494ca11e Initial load
duke
parents:
diff changeset
    25
        static <B> List<B> nil() { return new List<B>(); }
06bc494ca11e Initial load
duke
parents:
diff changeset
    26
        static <A, B extends A> A f(A x, B y) { return x; }
06bc494ca11e Initial load
duke
parents:
diff changeset
    27
        static <A, B extends A> B g(List<A> x, List<B> y) { return y.head; }
06bc494ca11e Initial load
duke
parents:
diff changeset
    28
06bc494ca11e Initial load
duke
parents:
diff changeset
    29
        static <A> List<A> cons(A x, List<A> xs) { return xs.prepend(x); }
06bc494ca11e Initial load
duke
parents:
diff changeset
    30
        static <A> Cell<A> makeCell(A x) { return new Cell<A>(x); }
06bc494ca11e Initial load
duke
parents:
diff changeset
    31
        static <A> A id(A x) { return x; }
06bc494ca11e Initial load
duke
parents:
diff changeset
    32
37636
6c6e6e25189d 8154504: javac tests fail after JDK API is deprecated
jjg
parents: 30721
diff changeset
    33
        static Integer i = Integer.valueOf(1);
10
06bc494ca11e Initial load
duke
parents:
diff changeset
    34
        static Number n = i;
06bc494ca11e Initial load
duke
parents:
diff changeset
    35
06bc494ca11e Initial load
duke
parents:
diff changeset
    36
        public static void main(String[] args) {
06bc494ca11e Initial load
duke
parents:
diff changeset
    37
            Number x = f(n, i);
06bc494ca11e Initial load
duke
parents:
diff changeset
    38
            x = f(i, n);
06bc494ca11e Initial load
duke
parents:
diff changeset
    39
            f(cons("abc", nil()), nil());
06bc494ca11e Initial load
duke
parents:
diff changeset
    40
            f(nil(), cons("abc", nil()));
06bc494ca11e Initial load
duke
parents:
diff changeset
    41
        }
06bc494ca11e Initial load
duke
parents:
diff changeset
    42
    }
06bc494ca11e Initial load
duke
parents:
diff changeset
    43
}