Thodoris Sotiropoulos created GROOVY-11110:
----------------------------------------------
Summary: STC mixes names of bounded type parameters
Key: GROOVY-11110
URL: https://issues.apache.org/jira/browse/GROOVY-11110
Project: Groovy
Issue Type: Bug
Components: Static Type Checker
Reporter: Thodoris Sotiropoulos
I have the following program
{code}
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);
}
}
{code}
h3. Actual behavior
{code}
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
{code}
h3. Expected behavior
Compile successfully
h3. Notes
To trigger the bug, the type parameter of method test() should be bounded with
name T.
--
This message was sent by Atlassian Jira
(v8.20.10#820010)