You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@groovy.apache.org by "Ilya Kuchmin (JIRA)" <ji...@apache.org> on 2016/03/23 21:02:26 UTC

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

Ilya Kuchmin created GROOVY-7799:
------------------------------------

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


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=A.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
(v6.3.4#6332)