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:50:00 UTC

[jira] [Closed] (GROOVY-10268) Unable to assign variable in parameterized class with bounded polymorphism

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

Paul King closed GROOVY-10268.
------------------------------

> Unable to assign variable in parameterized class with bounded polymorphism 
> ---------------------------------------------------------------------------
>
>                 Key: GROOVY-10268
>                 URL: https://issues.apache.org/jira/browse/GROOVY-10268
>             Project: Groovy
>          Issue Type: Bug
>          Components: Static compilation, Static Type Checker
>    Affects Versions: 4.0.0-beta-1
>            Reporter: Stefanos Chaliasos
>            Priority: Major
>
> I have the following Groovy program.
> {code:groovy}
> @groovy.transform.TypeChecked
> class Cls<T, Z extends T> {
>   public final Z foo
>   public Upbeat(Z foo) {
>     this.foo = foo
>   }
> }
> {code}
> h2. Actual Behavior
> The program does not compile, and I get the following error.
> {code:java}
> org.codehaus.groovy.control.MultipleCompilationErrorsException: startup failed:
> Main.groovy: 5: [Static type checking] - Cannot assign value of type T to variable of type Z
>  @ line 5, column 16.
>        this.foo = foo
>                   ^
> 1 error
> {code}
> h2. Expected Behavior
> Compile successfully.
> h2. Comment
> This is a regression bug. The program compiles with 4.0.0-alpha-x. It doesn't compile with 4.0.0-beta-1 and master (commit: 9a642c928fbf5dc430dbe2c67357a26033b12c55).



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