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

Fail to identify direct call of abstract method

    XMLWordPrintableJSON

Details

    Description

      I have the following ill-typed program

      interface A {
          int m();
      }
      
      class C implements A {
          public int m()  { return 1; }
          void test() {
              A.super.m();
          }
      }
      
      public class Test {
          public static void main(String[] args) {
              new C().test();
          }
      }
      

      Actual behavior

      The program compiles with and produces:

      Exception in thread "main" java.lang.AbstractMethodError: 'int A.m()'
              at C.test(Test.groovy:8)
              at Test.main(Test.groovy:14)
      

      Expected behavior

      Reject the program with:

      org.codehaus.groovy.control.MultipleCompilationErrorsException: startup failed:
      Test.groovy: 8: [Static type checking] - Abstract method m() cannot be called directly
       @ line 8, column 9.
                 A.super.m();
                 ^
      
      1 error
      

      Attachments

        Issue Links

          Activity

            People

              emilles Eric Milles
              theosot Thodoris Sotiropoulos
              Votes:
              0 Vote for this issue
              Watchers:
              2 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved: