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

Compile-error when implementing a method from a generic interface

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Closed
    • Major
    • Resolution: Fixed
    • 1.6-beta-1, 1.5.7, 1.6-beta-2
    • 1.6-rc-1, 1.5.8, 1.7-beta-1
    • None
    • None
    • sun java 1.6.0_u10, Linux (2.6.24)

    Description

      This code works under 1.5.6 but not with newer versions.

      Test-Code:

      class Test {
          static void main( args ) {
              Task t = new Task()
              List l = t.myCall()
              println l.dump()
          }
      }
      
      interface MyCallable<T> {
          T myCall() throws Exception;
      }
      
      class Task implements MyCallable<List> {
          List myCall() throws Exception {
              return [ 42 ]
          }
      }
      

      results in:

      org.codehaus.groovy.control.MultipleCompilationErrorsException: startup failed, /home/lukas/temp/groovytest2.groovy: 14: the return type is incompatible with java.lang.Object myCall() in MyCallable.
      Node: org.codehaus.groovy.ast.MethodNode. At [14:5]  @ line 14, column 5.
             List myCall() throws Exception {
             ^
      

      Attachments

        Activity

          People

            roshandawrani Roshan Dawrani
            lukas_ruetz Lukas Ruetz
            Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: