langtools/test/tools/javac/generics/odersky/BadTest4.java
author jjg
Mon, 18 Apr 2016 18:41:38 -0700
changeset 37636 6c6e6e25189d
parent 30721 1024d425d97e
permissions -rw-r--r--
8154504: javac tests fail after JDK API is deprecated Reviewed-by: darcy

/*
 * @test /nodynamiccopyright/
 * @bug 4736963
 * @summary Negative regression test from odersky
 * @author odersky
 *
 * @compile/fail/ref=BadTest4.out -XDrawDiagnostics -source 7 BadTest4.java
 * @compile BadTest4.java
 */

class BadTest4 {

    interface I {}
    interface J {}
    static class C implements I, J {}
    static class D implements I, J {}

    interface Ord {}

    static class Main {

        static C c = new C();
        static D d = new D();

        static <B> List<B> nil() { return new List<B>(); }
        static <A, B extends A> A f(A x, B y) { return x; }
        static <A, B extends A> B g(List<A> x, List<B> y) { return y.head; }

        static <A> List<A> cons(A x, List<A> xs) { return xs.prepend(x); }
        static <A> Cell<A> makeCell(A x) { return new Cell<A>(x); }
        static <A> A id(A x) { return x; }

        static Integer i = Integer.valueOf(1);
        static Number n = i;

        public static void main(String[] args) {
            Number x = f(n, i);
            x = f(i, n);
            f(cons("abc", nil()), nil());
            f(nil(), cons("abc", nil()));
        }
    }
}