mcimadamore@1415: /* mcimadamore@1415: * @test /nodynamiccopyright/ mcimadamore@1415: * @bug 8003280 mcimadamore@1415: * @summary Add lambda tests mcimadamore@1415: * check that that void compatibility affects overloading as expected mcimadamore@1415: * @compile/fail/ref=VoidCompatibility.out -XDrawDiagnostics VoidCompatibility.java mcimadamore@1415: */ mcimadamore@1415: class VoidCompatibility { mcimadamore@1415: mcimadamore@1415: interface Runnable { void run(); } //1 mcimadamore@1415: interface Thunk { T get(); } //2 mcimadamore@1415: mcimadamore@1415: void schedule(Runnable r) { } mcimadamore@1415: void schedule(Thunk t) { } mcimadamore@1415: mcimadamore@1415: void test() { mcimadamore@1415: schedule(() -> System.setProperty("done", "true")); //2 mcimadamore@1415: schedule(() -> { System.setProperty("done", "true"); }); //1 mcimadamore@1415: schedule(() -> { return System.setProperty("done", "true"); }); //2 mcimadamore@1415: schedule(() -> System.out.println("done")); //1 mcimadamore@1415: schedule(() -> { System.out.println("done"); }); //1 mcimadamore@1415: schedule(Thread::yield); //1 mcimadamore@1415: schedule(Thread::getAllStackTraces); //ambiguous mcimadamore@1415: schedule(Thread::interrupted); //1 (most specific) mcimadamore@1415: } mcimadamore@1415: }