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

Impossible to override method with generic array of Java class.

    XMLWordPrintableJSON

    Details

    • Type: Bug
    • Status: Closed
    • Priority: Major
    • Resolution: Fixed
    • Affects Version/s: 2.2.2, 2.3.8, 2.4.6
    • Fix Version/s: 2.4.8
    • Component/s: Compiler
    • Environment:
      groovy 2.2.2 (tried with 2.3.8)
      java openjdk 1.7.0_65

      maven 3.2.2
      maven-compiler-plugin 3.1
      groovy-eclipse-compiler 2.8.0-01
      groovy-eclipse-batch 2.1.5-03

      Description

      Java classes:

      public interface A<T> {
          T[] process();
      }
      
      public class B implements A<String> {
          @Override
          public String[] process() {
              return new String[0];
          }
      }
      

      Groovy class:

      class C extends B {
          @Override
          String[] process() {
              return super.process()
          }
      }
      

      I've got following error during compilation:

      Groovy:The return type of [Ljava.lang.String; process() in temp.C is incompatible with [Ljava.lang.Object; process() in temp.B
      

      BTW, I can't convert classes A and B to Groovy because it's library's classes (not mine).

        Attachments

          Issue Links

            Activity

              People

              • Assignee:
                shils Shil Sinha
                Reporter:
                abeletsky Andrey Beletsky
              • Votes:
                0 Vote for this issue
                Watchers:
                2 Start watching this issue

                Dates

                • Created:
                  Updated:
                  Resolved: