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

Harsh Gupta updated GROOVY-8285:
--------------------------------
    Description: 
This snippet does not compile.

{quote}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; \}
}

{quote}
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
                       ^

  was:
This snippet does not compile.

{{ 
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;}
}
}}

Compilation errors:

{{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
                       ^
}}


> 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
>
> This snippet does not compile.
> {quote}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; \}
> }
> {quote}
> 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
>                        ^



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

Reply via email to