Thodoris Sotiropoulos created GROOVY-11244:
----------------------------------------------
Summary: 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: Static Type Checker
Reporter: Thodoris Sotiropoulos
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)