You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@groovy.apache.org by "Eric Milles (Jira)" <ji...@apache.org> on 2023/12/11 19:10:00 UTC
[jira] [Updated] (GROOVY-11244) Cannot define Java-like lambda inside closure
[ https://issues.apache.org/jira/browse/GROOVY-11244?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]
Eric Milles updated GROOVY-11244:
---------------------------------
Component/s: parser-antlr4
(was: Static Type Checker)
> 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)