You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@groovy.apache.org by "Eric Milles (Jira)" <ji...@apache.org> on 2021/11/04 14:10:00 UTC

[jira] [Assigned] (GROOVY-10342) STC is unable to infer type parameter of parameterized method call

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

Eric Milles reassigned GROOVY-10342:
------------------------------------

    Assignee: Eric Milles

> 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
>
> This bug may be related to GROOVY-10222.
> 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.3.4#803005)