Details
-
Bug
-
Status: Closed
-
Major
-
Resolution: Fixed
-
4.0.0-beta-1
-
None
Description
I have the following Groovy program.
import java.util.function.Supplier; @groovy.transform.TypeChecked public class Main { public static Supplier<Integer> foo() { { -> 10} as Supplier<Integer> // works } public static Supplier<Integer> bar() { { -> 10} //fails } public static void main(String[] args) { Supplier<Integer> v1 = { -> 10} as Supplier<Integer> // works Supplier<Integer> v2 = { -> 10} // works Supplier<Integer> v3 = foo() Supplier<Integer> v4 = bar() } }
Actual Behavior
The program does not compile, and I get the following error.
Main.groovy: 10: [Static type checking] - Cannot return value of type groovy.lang.Closure<java.lang.Integer> on method returning type java.util.function.Supplier<java.lang.Integer> @ line 10, column 9. { -> 10} //fails ^ 1 error
Expected Behavior
Compile successfully.