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/18 14:59:00 UTC

[jira] [Resolved] (GROOVY-10601) Incompatible generic argument type when combining conditionals and bounded type parameters

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

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

https://github.com/apache/groovy/commit/2632e241b39692ce6fbc16a6198ab638ab316c13

> Incompatible generic argument type when combining conditionals and bounded type parameters
> ------------------------------------------------------------------------------------------
>
>                 Key: GROOVY-10601
>                 URL: https://issues.apache.org/jira/browse/GROOVY-10601
>             Project: Groovy
>          Issue Type: Bug
>          Components: Static Type Checker
>            Reporter: Thodoris Sotiropoulos
>            Assignee: Eric Milles
>            Priority: Major
>             Fix For: 5.0.0-alpha-1
>
>
> I have the following program
> {code}
> class Foo<X> {}
> class Test {
>   public static <T extends Foo<Number>> T test() {
>     T x = (T) null;
>     T y = (true) ? x : (T) null;
>     y
>   }
> }
> {code}
> h3. Actual behaviour
> The compiler rejects the program with
> {code}
> org.codehaus.groovy.control.MultipleCompilationErrorsException: startup failed:
> test.groovy: 8: [Static type checking] - Incompatible generic argument types. Cannot assign Foo<java.lang.Object> to: T
>  @ line 8, column 5.
>        y
>        ^
> 1 error
> {code}
> h3. Expected behaviour
> Compile successfully
> **NOTE:** This bug occurs only when `test` and `Foo` have type parameters with different names.
> Tested against master (commit: 5c468cd352f37fb5c599a3f51534ffcc55b339ed).



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