[ 
https://issues.apache.org/jira/browse/GROOVY-10222?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=17413813#comment-17413813
 ] 

Eric Milles edited comment on GROOVY-10222 at 9/23/21, 2:48 PM:
----------------------------------------------------------------

Caused by 
https://github.com/apache/groovy/commit/1fcbd7ed874ee2a792870644276c7a89a

See also GROOVY-9952 and GROOVY-10127


was (Author: emilles):
See also GROOVY-9952 and GROOVY-10127

> Unable to infer the type parameter of a parameterized function
> --------------------------------------------------------------
>
>                 Key: GROOVY-10222
>                 URL: https://issues.apache.org/jira/browse/GROOVY-10222
>             Project: Groovy
>          Issue Type: Bug
>          Components: Static Type Checker
>            Reporter: Thodoris Sotiropoulos
>            Assignee: Eric Milles
>            Priority: Major
>
> I have the following program
> {code:java}
> class A {
>     static <T> T foo() {
>         return null;
>     }
> }
> class Test<T> {
>     void bar() {
>         T x = A.foo();
>     }
> }
> {code}
> h3. Actual Behaviour
> {code:java}
> org.codehaus.groovy.control.MultipleCompilationErrorsException: startup 
> failed:
> groovy11.groovy: 9: [Static type checking] - Cannot assign value of type #T 
> to variable of type T
>  @ line 9, column 15.
>            T x = A.foo();
>                  ^1 error
> {code}
> h3. Expected Behaviour
> Compile successfully
>  
> I don't know however, if this is a limitation of the inference engine of 
> groovyc or a bug. Note that the Java compiler compiles the above program 
> successfully. Also note that if I replace "T x = A.foo()" with "String x = 
> A.foo()", groovyc compiles the updated program.
>  



--
This message was sent by Atlassian Jira
(v8.3.4#803005)

Reply via email to