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

Incorrect order of calling super.method when depth more than two and first class is generic

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Closed
    • Major
    • Resolution: Fixed
    • None
    • 5.0.0-alpha-2
    • None
    • None

    Description

      I have following code:

      A.groovy
      package test.groovy
      
      class A<T> {
          protected String getText(T arg){
              System.out.println( "A does something else");
              return "Class A. -> ";
          }
      }
      
      B.groovy
      package test.groovy
      
      class B extends A<String> {
          @Override
          protected String getText(String arg) {
              System.out.println("B does something else");
              return super.getText(arg) + "Class B. -> ";
          }
      }
      
      C.groovy
      package test.groovy
      
      class C extends B {
          @Override
          protected String getText(String arg) {
              System.out.println("C does something else");
              return super.getText(arg) + "Class C. ";
          }
      
          public static void main(String[] args) {
              def c = new C()
              println(c.getText(null))
          }
      }
      

      I expected to receive next result:

      Expected output
      C does something else
      B does something else
      A does something else
      Class A. -> Class B. -> Class C. 
      

      But got the following output:

      Actual output
      C does something else
      A does something else
      Class A. -> Class C. 
      

      This issue might have same cause and can duplicate GROOVY-6653 issue.

      Attachments

        Activity

          People

            emilles Eric Milles
            alehbich Aleh Bich
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: