You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@groovy.apache.org by "Harsh Gupta (JIRA)" <ji...@apache.org> on 2017/08/11 21:32:00 UTC

[jira] [Closed] (GROOVY-8285) Static compilation does not accept subclasses for generic arguments

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

Harsh Gupta closed GROOVY-8285.
-------------------------------
    Resolution: Invalid

> Static compilation does not accept subclasses for generic arguments
> -------------------------------------------------------------------
>
>                 Key: GROOVY-8285
>                 URL: https://issues.apache.org/jira/browse/GROOVY-8285
>             Project: Groovy
>          Issue Type: Bug
>         Environment: Groovy Version: 2.4.12 JVM: 1.8.0_121 Vendor: Oracle Corporation OS: Mac OS X
>            Reporter: Harsh Gupta
>            Priority: Critical
>
> This snippet does not compile.
> {code:Java}import groovy.transform.CompileStatic
> @CompileStatic
> class Scratch {
>     public static void main(String[] args) {
>         List<bar> listA
>         List<foo> listB = new ArrayList<>()
>         listB.add(new foo())
>         listA = listB
>     }
> }
> class bar {
>     public int blah() { return 12; }
> }
> class foo extends bar {
>     public int boo() { return 42; }
> }
> {code}
> Compilation errors:
> {quote}
> repro.groovy: 10: \[Static type checking\] - Incompatible generic argument types. Cannot assign java.util.ArrayList <foo> to: java.util.List <bar>
>  @ line 10, column 21.
>                listA = listB
> {quote}



--
This message was sent by Atlassian JIRA
(v6.4.14#64029)