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 2022/05/16 17:18:00 UTC

[jira] [Resolved] (GROOVY-10343) STC fails to infer dependent type variable

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

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

https://github.com/apache/groovy/commit/5e76d57b49ac783aa5ed9864ffcab45b6f61f55a

> STC fails to infer dependent type variable
> ------------------------------------------
>
>                 Key: GROOVY-10343
>                 URL: https://issues.apache.org/jira/browse/GROOVY-10343
>             Project: Groovy
>          Issue Type: Bug
>          Components: Static Type Checker
>            Reporter: Thodoris Sotiropoulos
>            Assignee: Eric Milles
>            Priority: Major
>             Fix For: 5.0.0-alpha-1
>
>         Attachments: screenshot-1.png
>
>
> I have the following program
> {code:java}
> class A<T1, T2 extends T1> {
>   T1 f;
>   A(T1 f) {
>     this.f = f;
>   }
>   T2 foo() { return null; }
> }
> class Test {
>   void test() {
>     Integer x = 1;
>     var y = new A<>(x).foo();
>     Integer z = y;
>   }
>   
> }
> {code}
> h3. Actual behavior
> {code}
> org.codehaus.groovy.control.MultipleCompilationErrorsException: startup failed:
> test.groovy: 14: [Static type checking] - Cannot assign value of type java.lang.Object to variable of type java.lang.Integer
>  @ line 14, column 17.
>        Integer z = y;
>                    ^
> 1 error
> {code}
> h3. Expected behaviour
> Compile successfully
> Note that the program above compiles as expected in javac.
> Tested against master (https://github.com/apache/groovy/commit/cee45d768bb65d1254a61a6dd4ce3c6a1f2ee3ca)



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