test/tools/javac/lambda/LambdaExpr10.java

changeset 0
959103a6100f
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/test/tools/javac/lambda/LambdaExpr10.java	Wed Apr 27 01:34:52 2016 +0800
     1.3 @@ -0,0 +1,37 @@
     1.4 +/*
     1.5 + * @test /nodynamiccopyright/
     1.6 + * @bug 8003280
     1.7 + * @summary Add lambda tests
     1.8 + *  check that lambda in array initializers (with wrong type) are correctly rejected
     1.9 + * @compile/fail/ref=LambdaExpr10.out -XDrawDiagnostics LambdaExpr10.java
    1.10 + */
    1.11 +
    1.12 +class LambdaExpr10 {
    1.13 +
    1.14 +    interface Block<T> {
    1.15 +       void m(T t);
    1.16 +    }
    1.17 +
    1.18 +    void apply(Object[] obj_arr) { }
    1.19 +
    1.20 +    void test1() {
    1.21 +        Object[] arr1 =  { t -> { } };
    1.22 +        Object[][] arr2 =  { { t -> { } } };
    1.23 +    }
    1.24 +
    1.25 +    void test2() {
    1.26 +        Object[] arr1 =  new Object[]{ t -> { } };
    1.27 +        Object[][] arr2 =  new Object[][]{ { t -> { } } };
    1.28 +    }
    1.29 +
    1.30 +    void test3() {
    1.31 +        apply(new Object[]{ t -> { } });
    1.32 +        apply(new Object[][]{ { t -> { } } });
    1.33 +    }
    1.34 +
    1.35 +    void test4() {
    1.36 +        Block<?>[] arr1 =  { t -> t };
    1.37 +        Block<?>[] arr2 =  new Block<?>[]{ t -> t };
    1.38 +        apply(new Block<?>[]{ t -> { }, t -> { } });
    1.39 +    }
    1.40 +}

mercurial