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

RuntimeError when implementing interfaces with conflicting default methods

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Closed
    • Minor
    • Resolution: Duplicate
    • None
    • None
    • Static Type Checker
    • None

    Description

      I have the following program

      interface A {
        default void m() {
          System.out.println("here");
        }
      }
      
      interface B {
        default void m() {
          System.out.println("there")
        }
      }
      
      interface C extends B, A {}
      
      class Test implements C {
        public void test() {
          this.m();
        }
      
        public static void main(String[] args) {
          Test x = new Test();
          x.test();
        }
      } 

      Actual behavior

      The code compiles, but there's a runtime error

      Exception in thread "main" java.lang.AbstractMethodError: Receiver class Test does not define or inherit an implementation of the resolved method 'void m()' of interface B.
              at Test.test(groovy109.groovy:17)
              at Test.main(groovy109.groovy:22)
       

      Expected behavior

      The code should have been rejected

      Attachments

        Issue Links

          Activity

            People

              Unassigned Unassigned
              theosot Thodoris Sotiropoulos
              Votes:
              0 Vote for this issue
              Watchers:
              2 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved: