groovy-notifications mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Harsh Gupta (JIRA)" <j...@apache.org>
Subject [jira] [Created] (GROOVY-8285) Static compilation does not accept subclasses for generic arguments
Date Thu, 10 Aug 2017 21:37:00 GMT
Harsh Gupta created GROOVY-8285:
-----------------------------------

             Summary: 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.

```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
                       ^
````



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

Mime
View raw message