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

Eric Milles resolved GROOVY-10342.
----------------------------------
    Fix Version/s: 5.0.0-alpha-1
       Resolution: Fixed

https://github.com/apache/groovy/commit/006b5987a7d91c4a4754d9e4a1191484e43f9868

> STC is unable to infer type parameter of parameterized method call
> ------------------------------------------------------------------
>
>                 Key: GROOVY-10342
>                 URL: https://issues.apache.org/jira/browse/GROOVY-10342
>             Project: Groovy
>          Issue Type: Bug
>          Components: Static Type Checker
>            Reporter: Thodoris Sotiropoulos
>            Assignee: Eric Milles
>            Priority: Major
>             Fix For: 5.0.0-alpha-1
>
>
> I have the following program
> {code:java}
> class A<T> {
>   T f;
> }
> class Test {
>   static <T> T m() { return null; }
>   static <T extends Number> void test() {
>     String x = m(); // works
>     A<String> y = new A<>();
>     y.f = m(); // works
>     A<T> z = new A<T>();
>     z.f = m(); // does not work
>   }
> }
> {code}
> h3. Actual behaviour
> {code}
> org.codehaus.groovy.control.MultipleCompilationErrorsException: startup 
> failed:
> test.groovy: 15: [Static type checking] - Cannot assign value of type #T to 
> variable of type T
>  @ line 15, column 11.
>        z.f = m();
>              ^
> 1 error
> {code}
> h3. Expected behavior
> Compile successfully
> *NOTE*: Replacing `T extends Number` with `T` compiles code successfully.
> Tested against master.



--
This message was sent by Atlassian Jira
(v8.20.7#820007)

Reply via email to