test/langtools/tools/javac/var_implicit_lambda/VarInImplicitLambdaNegTest01.java
changeset 49152 e38b6a7f65ee
parent 48935 03ae177c26b0
child 52016 9ea22a0f9540
equal deleted inserted replaced
49151:a7d2f0dd9c1f 49152:e38b6a7f65ee
     1 /*
     1 /*
     2  * @test /nodynamiccopyright/
     2  * @test /nodynamiccopyright/
     3  * @bug 8198512
     3  * @bug 8198512 8199327
     4  * @summary compiler support for local-variable syntax for lambda parameters
     4  * @summary compiler support for local-variable syntax for lambda parameters
     5  * @compile/fail/ref=VarInImplicitLambdaNegTest01.out -XDrawDiagnostics VarInImplicitLambdaNegTest01.java
     5  * @compile/fail/ref=VarInImplicitLambdaNegTest01.out -XDrawDiagnostics VarInImplicitLambdaNegTest01.java
     6  */
     6  */
     7 
     7 
     8 import java.util.function.*;
     8 import java.util.function.*;
    12     IntBinaryOperator f2 = (var x, y) -> x + y;                              // error var and implicit
    12     IntBinaryOperator f2 = (var x, y) -> x + y;                              // error var and implicit
    13     IntBinaryOperator f3 = (int x, var y) -> x + y;                          // error var and explicit
    13     IntBinaryOperator f3 = (int x, var y) -> x + y;                          // error var and explicit
    14     IntBinaryOperator f4 = (int x, y) -> x + y;                              // error explicit and implicit
    14     IntBinaryOperator f4 = (int x, y) -> x + y;                              // error explicit and implicit
    15 
    15 
    16     BiFunction<String[], String, String> f5 = (var s1[], var s2) -> s2;      // error var and array
    16     BiFunction<String[], String, String> f5 = (var s1[], var s2) -> s2;      // error var and array
       
    17 
       
    18     // correct use
       
    19     IntBinaryOperator f6 = (var x, var y) -> x + y;                          // ok
    17     BiFunction<Function<String, String>, String, String> f = (Function<String, String> s1, String s2) -> s2; // ok
    20     BiFunction<Function<String, String>, String, String> f = (Function<String, String> s1, String s2) -> s2; // ok
    18 }
    21 }