[
https://issues.apache.org/jira/browse/GROOVY-10959?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel
]
Eric Milles updated GROOVY-10959:
---------------------------------
Priority: Minor (was: Major)
> Type checking fails when casting method references
> --------------------------------------------------
>
> Key: GROOVY-10959
> URL: https://issues.apache.org/jira/browse/GROOVY-10959
> Project: Groovy
> Issue Type: Bug
> Reporter: Thodoris Sotiropoulos
> Assignee: Eric Milles
> Priority: Minor
>
> Probably related to GROOVY-10270.
> I have the following program
> {code}
> import java.util.function.*;
> import java.util.stream.*;
> class Main {
> static final void test() {
> Foo<Object, String> x = null;
> Foo<String, String> y = null;
> BinaryOperator<String> z = null;
> final Object powdery = java.util.stream.Collectors.toConcurrentMap(
> x::m as Function<Object, String>,
> y::m as Function<String, String>,
> z
> );
> }
> }
> interface Foo<T1, T2> {
> T2 m(T1 x);
> }
> {code}
> h3. Actual behaviour
> {code}
> org.codehaus.groovy.control.MultipleCompilationErrorsException: startup
> failed:
> test.groovy: 11: [Static type checking] - Cannot call <T,K,U>
> java.util.stream.Collectors#toConcurrentMap(java.util.function.Function<?
> super T, ? extends K>, java.util.function.Function<? super T, ? extends U>,
> java.util.function.BinaryOperator<U>) with arguments
> [java.util.function.Function<java.lang.Object, java.lang.String>,
> java.util.function.Function<java.lang.String, java.lang.String>,
> java.util.function.BinaryOperator<java.lang.String>]
> @ line 11, column 28.
> final Object powdery = java.util.stream.Collectors.toConcurrentMap(
> ^
> 1 error
> {code}
> h3. Expected behaviour
> Compile successfully
> Notes: If a remove type casts, the code compiles as expected.
--
This message was sent by Atlassian Jira
(v8.20.10#820010)