File: BadTest.java

package info (click to toggle)
libnb-javaparser-java 9%2B2018-2
  • links: PTS, VCS
  • area: main
  • in suites: bookworm, forky, sid, trixie
  • size: 65,320 kB
  • sloc: java: 440,096; xml: 6,359; sh: 865; makefile: 314
file content (30 lines) | stat: -rw-r--r-- 1,035 bytes parent folder | download | duplicates (9)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
/*
 * @test /nodynamiccopyright/
 * @summary Negative regression test from odersky
 * @author odersky
 *
 * @compile/fail/ref=BadTest.out -XDrawDiagnostics  BadTest.java
 */

class BadTest {
    static class Main {

        static <B> List<B> nil() { return new List<B>(); }
        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; }

        public static void main(String[] args) {
            List<Cell<String>> as = nil().prepend(makeCell(null));
            List<Cell<String>> bs = cons(makeCell(null), nil());
            List<String> xs = id(nil());
            List<String> ys = cons("abc", id(nil()));
            List<String> zs = id(nil()).prepend("abc");
            List<Cell<String>> us = id(nil()).prepend(makeCell(null));
            List<Cell<String>> vs = cons(makeCell(null), id(nil()));
            System.out.println(nil() instanceof List<String>);
            nil();
        }

    }
}