test/tools/javac/lambda/TargetType44.java

changeset 0
959103a6100f
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/test/tools/javac/lambda/TargetType44.java	Wed Apr 27 01:34:52 2016 +0800
     1.3 @@ -0,0 +1,27 @@
     1.4 +/*
     1.5 + * @test /nodynamiccopyright/
     1.6 + * @bug 8003280
     1.7 + * @summary Add lambda tests
     1.8 + *  compiler throw AssertionError while backtracing from speculative attribution round
     1.9 + * @compile/fail/ref=TargetType44.out -XDrawDiagnostics TargetType44.java
    1.10 + */
    1.11 +class TargetType44 {
    1.12 +
    1.13 +    interface Unary {
    1.14 +        void m(int i1);
    1.15 +    }
    1.16 +
    1.17 +    interface Binary {
    1.18 +        void m(int i1, int i2);
    1.19 +    }
    1.20 +
    1.21 +    void m(Unary u) { }
    1.22 +    void m(Binary u) { }
    1.23 +
    1.24 +    void test() {
    1.25 +        m(()-> { new Object() { }; }); //fail
    1.26 +        m(x -> { new Object() { }; }); //ok
    1.27 +        m((x, y) -> { new Object() { }; }); //ok
    1.28 +        m((x, y, z) -> { new Object() { }; }); //fail
    1.29 +    }
    1.30 +}

mercurial