[ 
https://issues.apache.org/jira/browse/GROOVY-11110?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel
 ]

Daniel Sun resolved GROOVY-11110.
---------------------------------
    Resolution: Fixed

> 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)

Reply via email to