You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@groovy.apache.org by "Paul King (Jira)" <ji...@apache.org> on 2022/02/03 22:33:01 UTC
[jira] [Closed] (GROOVY-10128) Cannot assign closure with long as return type to java.util.function.Function
[ https://issues.apache.org/jira/browse/GROOVY-10128?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]
Paul King closed GROOVY-10128.
------------------------------
> Cannot assign closure with long as return type to java.util.function.Function<X, Number>
> ----------------------------------------------------------------------------------------
>
> Key: GROOVY-10128
> URL: https://issues.apache.org/jira/browse/GROOVY-10128
> Project: Groovy
> Issue Type: Bug
> Components: Static compilation, Static Type Checker
> Affects Versions: 3.0.8, 4.0.0-alpha-3
> Reporter: Stefanos Chaliasos
> Assignee: Eric Milles
> Priority: Major
> Fix For: 4.0.0-beta-2
>
>
> I have the following Groovy program.
> {code:groovy}
> 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;
> };
> }
> }
> {code}
> h2. Actual Behavior
> The program does not compile, and I get the following error.
> {code:java}
> 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
> {code}
> h2. Expected Behavior
> Compile successfully.
> h2. Comment
> Note that javac accepts this program.
> h2. Affected Version
> This programs have been tested with the compiler from the master (commit: 05a39632565bee88949c8db9d56b9f9598321fc2), 4.0.0-alpha-3, and 3.0.8.
--
This message was sent by Atlassian Jira
(v8.20.1#820001)