[
https://issues.apache.org/jira/browse/GROOVY-11110?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=18149211#comment-18149211
]
Daniel Sun commented on GROOVY-11110:
-------------------------------------
Fixed on master; added a regression test in
85857e771f9c2b5e10780feb58bf7abe64dc3fa6
(https://github.com/apache/groovy/commit/85857e771f9c2b5e10780feb58bf7abe64dc3fa6).
> 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
> Assignee: Daniel Sun
> Priority: Minor
> Labels: bounded-polymorphism
> Fix For: 7.0.0-alpha-1
>
>
> 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
(v10.3.26#10030026)