langtools/test/tools/javac/lambda/MethodReference37.java
author mcimadamore
Wed, 17 Jul 2013 14:04:01 +0100
changeset 18909 8f9fc5d876e4
parent 14547 86d8d242b0c4
child 30998 9e8f3b991f97
permissions -rw-r--r--
8012242: Lambda compatibility and checked exceptions Summary: Inference variables in 'throws' clause with no constraints should be inferred as RuntimeException Reviewed-by: jjg, vromero

/*
 * @test /nodynamiccopyright/
 * @bug 8003280
 * @summary Add lambda tests
 *  spurious exceptions when checking references to inner constructors where
 *          the enclosing class is not defined in any outer context
 * @compile/fail/ref=MethodReference37.out -XDrawDiagnostics MethodReference37.java
 */

class MethodReference37 {

    interface SAM1<R> {
        R invoke();
    }

    interface SAM2<R, A> {
        R invoke(A a);
    }

    static class Outer {
        class Inner { }

        static void test1() {
            SAM2<Inner, Outer> sam = Inner::new;
        }

        void test2() {
            SAM1<Inner> sam0 = Inner::new;
            SAM2<Inner, Outer> sam1 = Inner::new;
        }
    }

    static void test1() {
        SAM2<Outer.Inner, Outer> sam = Outer.Inner::new;
    }

    void test2() {
        SAM2<Outer.Inner, Outer> sam1 = Outer.Inner::new;
    }
}