You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@groovy.apache.org by "Paul King (Jira)" <ji...@apache.org> on 2022/02/03 22:33:00 UTC

[jira] [Closed] (GROOVY-10280) Type variable substitution does not work well when running into chain of field accesses

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

Paul King closed GROOVY-10280.
------------------------------

> Type variable substitution does not work well when running into chain of field accesses
> ---------------------------------------------------------------------------------------
>
>                 Key: GROOVY-10280
>                 URL: https://issues.apache.org/jira/browse/GROOVY-10280
>             Project: Groovy
>          Issue Type: Bug
>          Components: Static Type Checker
>            Reporter: Thodoris Sotiropoulos
>            Assignee: Eric Milles
>            Priority: Major
>             Fix For: 4.0.0-beta-2
>
>
> I have the following program
> {code:java}
> class Foo<T> {
>   T foo() {
>     new Bar<T>().f1.f2.f3;
>   }
>   
> }
> class Bar<Y> {
>   Baz<Y> f1;
> }
> class Baz<T> {
>   Qux<T> f2;
> }
> class Qux<X> {
>   X f3;
> }
> {code}
> h3. Actual behavior
> {code}
> org.codehaus.groovy.control.MultipleCompilationErrorsException: startup failed:
> test.groovy: 3: [Static type checking] - Cannot return value of type Y on method returning type T
>  @ line 3, column 5.
>        new Bar<T>().f1.f2.f3;
>        ^
> 1 error
> {code}
> h3. Expected behavior
> Compile successfully
> Tested against master (https://github.com/apache/groovy/commit/0e8d0e26e3fe4f8cc21d58f1a1163ae29a8892db)



--
This message was sent by Atlassian Jira
(v8.20.1#820001)