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/01/24 14:43:00 UTC
[jira] [Assigned] (GROOVY-10914) Method ambiguity error even if the given argument has an explicit type
[ https://issues.apache.org/jira/browse/GROOVY-10914?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]
Eric Milles reassigned GROOVY-10914:
------------------------------------
Assignee: Eric Milles
> Method ambiguity error even if the given argument has an explicit type
> ----------------------------------------------------------------------
>
> Key: GROOVY-10914
> URL: https://issues.apache.org/jira/browse/GROOVY-10914
> Project: Groovy
> Issue Type: Bug
> Components: Static Type Checker
> Reporter: Thodoris Sotiropoulos
> Assignee: Eric Milles
> Priority: Major
>
> I have the following code
> {code}
> import java.util.function.*;
> class Main {
> static final void test() {
> String str = "foo"
> LongConsumer y = str.chars().asLongStream().summaryStatistics();
> str.chars().asLongStream().summaryStatistics().andThen(y); // Does not work
> str.chars().asLongStream().summaryStatistics().andThen((LongConsumer) y); // it works
> }
> }
> {code}
> h3. Actual behavior
> {code}
> org.codehaus.groovy.control.MultipleCompilationErrorsException: startup failed:
> Main.groovy: 8: [Static type checking] - Reference to method is ambiguous. Cannot choose between [java.util.function.IntConsumer java.util.function.IntConsumer#andThen(java.util.function.IntConsumer), java.util.function.LongConsumer java.util.function.LongConsumer#andThen(java.util.function.LongConsumer)]
> @ line 8, column 5.
> str.chars().asLongStream().summaryStatistics().andThen(y); // Does not work
> ^
> 1 error
> {code}
> h3. Expected behavior
> Compile successfully
> Tested against master (commit: 5a5726342adeb37a6fbaa8cdcbe2d47dee8dc56c)
--
This message was sent by Atlassian Jira
(v8.20.10#820010)