Details
-
Bug
-
Status: Open
-
Minor
-
Resolution: Unresolved
-
None
-
None
-
None
-
None
Description
Probably related to GROOVY-10270.
I have the following program
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); }
Actual behaviour
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
Expected behaviour
Compile successfully
Notes: If a remove type casts, the code compiles as expected.
Attachments
Issue Links
- is related to
-
GROOVY-9998 Wildcards with a lower bound fail static type checking
- Closed