[ https://issues.apache.org/jira/browse/GROOVY-11244?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=17798786#comment-17798786 ]
Eric Milles commented on GROOVY-11244: -------------------------------------- Is it possible to prefer a local variable declaration if open brace is followed by newline? Then user could escape the newline to get back to parameter interpretation. Just brain-storming an idea here. > Cannot define Java-like lambda inside closure > --------------------------------------------- > > Key: GROOVY-11244 > URL: https://issues.apache.org/jira/browse/GROOVY-11244 > Project: Groovy > Issue Type: Bug > Components: parser-antlr4 > Reporter: Thodoris Sotiropoulos > Priority: Minor > > I have the following program > {code} > import java.util.function.Function; > class Test { > void test() { > Closure<String> clo = { > Function<Integer, Integer> x = (z) -> 1 + z; > return "f"; > } > } > } > {code} > h3. Actual behavior > {code} > org.codehaus.groovy.control.MultipleCompilationErrorsException: startup > failed: > test.groovy: 6: [Static type checking] - The variable [z] is undeclared. > @ line 6, column 49. > eger, Integer> x = (z) -> 1 + z; > ^ > test.groovy: 6: [Static type checking] - Cannot find matching method > int#plus(java.lang.Object). Please check if the declared type is correct and > if the method exists. > @ line 6, column 45. > <Integer, Integer> x = (z) -> 1 + z; > ^ > test.groovy: 6: [Static type checking] - The variable [z] is undeclared. > @ line 6, column 38. > Function<Integer, Integer> x = (z) -> 1 + z; > ^ > 3 errors > {code} > h3. Expected behavior > Compile successfully -- This message was sent by Atlassian Jira (v8.20.10#820010)