groovy-notifications mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Xiaoguang Wang (JIRA)" <j...@apache.org>
Subject [jira] [Updated] (GROOVY-8452) @CompileStatic, generic with 'extends' bug: Expected parameter of type ? but got A
Date Thu, 23 Aug 2018 04:21:00 GMT

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

Xiaoguang Wang updated GROOVY-8452:
-----------------------------------
    Affects Version/s: 3.0.0-alpha-3
                       2.5.2

> @CompileStatic, generic with 'extends' bug:  Expected parameter of type ? but got A
> -----------------------------------------------------------------------------------
>
>                 Key: GROOVY-8452
>                 URL: https://issues.apache.org/jira/browse/GROOVY-8452
>             Project: Groovy
>          Issue Type: Bug
>          Components: Compiler
>    Affects Versions: 2.4.13, 3.0.0-alpha-3, 2.5.2
>            Reporter: Xiaoguang Wang
>            Priority: Major
>
>  
> The inferred type of a generic List<? extends X> is wrong.
> The minimal reproduceable code is:
> {code:java}
> import groovy.transform.CompileStatic
> class A {}
> class B extends A {}
> @CompileStatic
> class TestClassSort {
>     void test() {
>         //List<? extends A> a  // without ` = null`, this compiles OK
>         List<? extends A> a = null
>         if(false) {
>             a = new ArrayList<A>()
>         } else {
>             a = new ArrayList<B>()
>         }
>         //BUG: Error: Groovyc: Expected parameter of type ? but got A
>         a.sort({ A v1, A v2 -> return 0 })
>     }
>     static void main(String []a) {
>         new TestClassSort().test()
>     }
> }
> {code}
>  



--
This message was sent by Atlassian JIRA
(v7.6.3#76005)

Mime
View raw message