Details
-
Bug
-
Status: Closed
-
Major
-
Resolution: Fixed
-
3.0.8, 4.0.0-alpha-3
-
None
Description
I have the following Groovy program.
import java.util.function.Function; @groovy.transform.TypeChecked class Main { public static void main(String[] args) { Function<String, Number> x = { y -> final long d = 1; return d; }; } }
Actual Behavior
The program does not compile, and I get the following error.
org.codehaus.groovy.control.MultipleCompilationErrorsException: startup failed: Main.groovy: 6: [Static type checking] - Incompatible generic argument types. Cannot assign java.util.function.Function <java.lang.String, java.lang.Long> to: java.util.function.Function <String, Number> @ line 6, column 36. Function<String, Number> x = { y -> ^ 1 error
Expected Behavior
Compile successfully.
Comment
Note that javac accepts this program.
Affected Version
This programs have been tested with the compiler from the master (commit: 05a39632565bee88949c8db9d56b9f9598321fc2), 4.0.0-alpha-3, and 3.0.8.