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 2021/12/19 19:14:00 UTC

[jira] [Updated] (GROOVY-7799) Extended generic types with var args isn't compiled if they contains in different files

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

Eric Milles updated GROOVY-7799:
--------------------------------
    Fix Version/s:     (was: 4.0.0-rc-2)

> Extended generic types with var args isn't compiled if they contains in different files
> ---------------------------------------------------------------------------------------
>
>                 Key: GROOVY-7799
>                 URL: https://issues.apache.org/jira/browse/GROOVY-7799
>             Project: Groovy
>          Issue Type: Bug
>          Components: Compiler
>    Affects Versions: 2.4.6
>         Environment: Oracle JRE 1.8_66
>            Reporter: Ilya Kuchmin
>            Assignee: Eric Milles
>            Priority: Major
>
> Hi
> I created two files.
> {code:title=A.groovy|borderStyle=solid}
> package example;
> interface EE {
> }
> interface A<T extends EE> {
>     A<T> method(T args)
>     A<T> method(T[] args)
>     A<T> method(Collection<T> args)
> }
> class AB<T extends EE> implements A<T> {
>     @Override
>     AB<T> method(T args) {
>         return null
>     }
>     @Override
>     AB<T> method(T[] args) {
>         return this
>     }
>     @Override
>     AB<T> method(Collection<T> args) {
>         return this
>     }
> }
> {code}
> {code:title=ABC.groovy|borderStyle=solid}
> package example;
> class ABC<T extends EE> extends AB<T> {}
> {code}
> If you would like get bug that you should compile A.groovy and then compile ABC.groovy. For second file you should use compiled classes from file A.groovy. For second file compile throw exception: 
> {noformat}
> org.codehaus.groovy.control.MultipleCompilationErrorsException: startup failed:
> ABC.groovy: 3: Can't have an abstract method in a non-abstract class. The class 'example.ABC' must be declared abstract or the method 'example.A method(java.lang.Object[])' must be implemented.
>  @ line 3, column 1.
>    class ABC<T extends EE> extends AB<T> {}
>    ^
> 1 error
> {noformat}
> I can remove var args methods or replace "T extends EE" on T. It is workaround for compiler. Code will be compiled.



--
This message was sent by Atlassian Jira
(v8.20.1#820001)