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

Implementing Groovy interface with default methods can cause compile issues.

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Closed
    • Minor
    • Resolution: Fixed
    • 3.0.0-beta-3
    • 3.0.10, 4.0.1
    • None
    • None

    Description

      Hello!

      Consider the following classes.

      test/JavaInterface.java
      package test;
      
      public interface JavaInterface {
      
          String doStuff();
      }
      
      test/GroovyInterface.groovy
      package test
      
      interface GroovyInterface extends JavaInterface {
      
          default doOtherStuff() {
              return 'doot'
          }
      }
      
      test/GroovyClass.groovy
      package test
      
      class GroovyClass implements GroovyInterface {
          @Override
          String doStuff() {
              return "otherDoot"
          }
      }
      

      This code compiles with an error:

      test/GroovyClass.groovy: 4: Method 'doStuff' from class 'test.GroovyClass' does not override method from its superclass or interfaces but is annotated with @Override.
       @ line 4, column 5.
             @Override
             ^
      

      However, removing the default method insideĀ GroovyInterface, OR, declaring GroovyClass to implement both GroovyInterface AND JavaInterface will make compilation succeed again.

      Apologies if this is some form of intended behavior, although I suspect it isn't due to the nature of this issue.

      Thank You for your time looking into this issue! also thanks for a fantastically flexible language!

      Attachments

        Issue Links

          Activity

            People

              emilles Eric Milles
              covers1624 covers1624
              Votes:
              1 Vote for this issue
              Watchers:
              4 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved: