test/langtools/tools/javac/generics/odersky/BadTest.java
author erikj
Tue, 12 Sep 2017 19:03:39 +0200
changeset 47216 71c04702a3d5
parent 30721 langtools/test/tools/javac/generics/odersky/BadTest.java@1024d425d97e
permissions -rw-r--r--
8187443: Forest Consolidation: Move files to unified layout Reviewed-by: darcy, ihse
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: 5520
diff changeset
     2
 * @test /nodynamiccopyright/
10
06bc494ca11e Initial load
duke
parents:
diff changeset
     3
 * @summary Negative regression test from odersky
06bc494ca11e Initial load
duke
parents:
diff changeset
     4
 * @author odersky
06bc494ca11e Initial load
duke
parents:
diff changeset
     5
 *
30721
1024d425d97e 8074425: Group 13b: golden files for tests in tools/javac/generics dir
sogoel
parents: 5520
diff changeset
     6
 * @compile/fail/ref=BadTest.out -XDrawDiagnostics  BadTest.java
10
06bc494ca11e Initial load
duke
parents:
diff changeset
     7
 */
06bc494ca11e Initial load
duke
parents:
diff changeset
     8
06bc494ca11e Initial load
duke
parents:
diff changeset
     9
class BadTest {
06bc494ca11e Initial load
duke
parents:
diff changeset
    10
    static class Main {
06bc494ca11e Initial load
duke
parents:
diff changeset
    11
06bc494ca11e Initial load
duke
parents:
diff changeset
    12
        static <B> List<B> nil() { return new List<B>(); }
06bc494ca11e Initial load
duke
parents:
diff changeset
    13
        static <A> List<A> cons(A x, List<A> xs) { return xs.prepend(x); }
06bc494ca11e Initial load
duke
parents:
diff changeset
    14
        static <A> Cell<A> makeCell(A x) { return new Cell<A>(x); }
06bc494ca11e Initial load
duke
parents:
diff changeset
    15
        static <A> A id(A x) { return x; }
06bc494ca11e Initial load
duke
parents:
diff changeset
    16
06bc494ca11e Initial load
duke
parents:
diff changeset
    17
        public static void main(String[] args) {
06bc494ca11e Initial load
duke
parents:
diff changeset
    18
            List<Cell<String>> as = nil().prepend(makeCell(null));
06bc494ca11e Initial load
duke
parents:
diff changeset
    19
            List<Cell<String>> bs = cons(makeCell(null), nil());
06bc494ca11e Initial load
duke
parents:
diff changeset
    20
            List<String> xs = id(nil());
06bc494ca11e Initial load
duke
parents:
diff changeset
    21
            List<String> ys = cons("abc", id(nil()));
06bc494ca11e Initial load
duke
parents:
diff changeset
    22
            List<String> zs = id(nil()).prepend("abc");
06bc494ca11e Initial load
duke
parents:
diff changeset
    23
            List<Cell<String>> us = id(nil()).prepend(makeCell(null));
06bc494ca11e Initial load
duke
parents:
diff changeset
    24
            List<Cell<String>> vs = cons(makeCell(null), id(nil()));
06bc494ca11e Initial load
duke
parents:
diff changeset
    25
            System.out.println(nil() instanceof List<String>);
06bc494ca11e Initial load
duke
parents:
diff changeset
    26
            nil();
06bc494ca11e Initial load
duke
parents:
diff changeset
    27
        }
06bc494ca11e Initial load
duke
parents:
diff changeset
    28
06bc494ca11e Initial load
duke
parents:
diff changeset
    29
    }
06bc494ca11e Initial load
duke
parents:
diff changeset
    30
}