Details
-
Bug
-
Status: Closed
-
Major
-
Resolution: Information Provided
-
None
-
None
-
None
Description
I have the following 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 } }
Actual behavior
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
Expected behavior
Compile successfully
Tested against master (commit: 5a5726342adeb37a6fbaa8cdcbe2d47dee8dc56c)
Attachments
Issue Links
- is related to
-
GROOVY-7763 Various problems with type inference in Groovy 2.4.6
- Closed
-
GROOVY-9064 STC: explicit declared variable type ignored in favor of assigned value type(s)
- Closed
-
GROOVY-10360 STC ignores declared type of variable
- Closed