Uploaded image for project: 'Groovy'
  1. Groovy
  2. GROOVY-7799

Extended generic types with var args isn't compiled if they contains in different files

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Closed
    • Major
    • Resolution: Fixed
    • 2.4.6
    • 4.0.0-rc-2
    • Compiler
    • None
    • Oracle JRE 1.8_66

    Description

      Hi

      I created two files.

      A.groovy
      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
          }
      }
      
      ABC.groovy
      package example;
      
      class ABC<T extends EE> extends AB<T> {}
      

      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:

      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
      

      I can remove var args methods or replace "T extends EE" on T. It is workaround for compiler. Code will be compiled.

      Attachments

        Activity

          People

            emilles Eric Milles
            ikuchmin Ilya Kuchmin
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: