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

Compiler doesn't recognize covariant array of generics

    XMLWordPrintableJSON

    Details

    • Type: Bug
    • Status: Closed
    • Priority: Major
    • Resolution: Fixed
    • Affects Version/s: 2.2.2, 2.3.0-rc-1
    • Fix Version/s: 2.3.0-rc-2
    • Component/s: None
    • Labels:
      None

      Description

      The following code fails to compile:

      abstract class Top<Elem,Result> {
          abstract Result exec(Elem... elems)
      }
      
      class Bottom extends Top<Integer, String> {
          @Override
          String exec(Integer... elems) {
              "$elems"
          }
      }
      

      Under 2.3.0-rc-1, it produces:

      2 compilation errors:
      
      Can't have an abstract method in a non-abstract class. The class 'Bottom' must be declared abstract or the method 'java.lang.Object exec(java.lang.Object[])' must be implemented.
       at line: 5, column: 1
      
      Method 'exec' from class 'Bottom' does not override method from its superclass or interfaces but is annotated with @Override.
       at line: 6, column: 5
      

      Under 2.2.2:

      1 compilation error:
      
      Can't have an abstract method in a non-abstract class. The class 'Bottom' must be declared abstract or the method 'java.lang.Object exec(java.lang.Object[])' must be implemented.
       at line: 5, column: 1
      

        Attachments

          Activity

            People

            • Assignee:
              melix Cédric Champeau
              Reporter:
              melix Cédric Champeau
            • Votes:
              0 Vote for this issue
              Watchers:
              1 Start watching this issue

              Dates

              • Created:
                Updated:
                Resolved: