test/tools/javac/lambda/VoidCompatibility.java

changeset 1415
01c9d4161882
child 1510
7873d37f5b37
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/test/tools/javac/lambda/VoidCompatibility.java	Sat Nov 17 19:01:03 2012 +0000
     1.3 @@ -0,0 +1,26 @@
     1.4 +/*
     1.5 + * @test /nodynamiccopyright/
     1.6 + * @bug 8003280
     1.7 + * @summary Add lambda tests
     1.8 + *  check that that void compatibility affects overloading as expected
     1.9 + * @compile/fail/ref=VoidCompatibility.out -XDrawDiagnostics VoidCompatibility.java
    1.10 + */
    1.11 +class VoidCompatibility {
    1.12 +
    1.13 +    interface Runnable { void run(); } //1
    1.14 +    interface Thunk<T> { T get(); } //2
    1.15 +
    1.16 +    void schedule(Runnable r) { }
    1.17 +    void schedule(Thunk<?> t) { }
    1.18 +
    1.19 +    void test() {
    1.20 +        schedule(() -> System.setProperty("done", "true")); //2
    1.21 +        schedule(() -> { System.setProperty("done", "true"); }); //1
    1.22 +        schedule(() -> { return System.setProperty("done", "true"); }); //2
    1.23 +        schedule(() -> System.out.println("done")); //1
    1.24 +        schedule(() -> { System.out.println("done"); }); //1
    1.25 +        schedule(Thread::yield); //1
    1.26 +        schedule(Thread::getAllStackTraces); //ambiguous
    1.27 +        schedule(Thread::interrupted); //1 (most specific)
    1.28 +    }
    1.29 +}

mercurial