Details
-
Bug
-
Status: Open
-
Minor
-
Resolution: Unresolved
-
None
-
None
Description
I have the following program
import java.util.stream.*; class Main { static final <T extends Number>void test() { java.util.function.BiConsumer<T, T> func = null; Stream<String> stream = null; T res = stream.<T>collect(() -> (T) null, (T finisher, String hijacking) -> { }, func); } }
Actual behavior
org.codehaus.groovy.control.MultipleCompilationErrorsException: startup failed: Main.groovy: 8: [Static type checking] - Cannot assign value of type java.lang.String to variable of type T @ line 8, column 13. T res = stream.<T>collect(() -> (T) null, (T finisher, String hijacking) -> { }, func); ^ 1 error
Expected behavior
Compile successfully
Notes
To trigger the bug, the type parameter of method test() should be bounded with name T.