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

Calling super.foo() from a closure fails if code is statically compiled

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Closed
    • Major
    • Resolution: Fixed
    • 2.3.7
    • 2.3.8, 2.4.0-beta-4
    • None
    • None

    Description

      The following code will fail at runtime with a VerifyError:

      class Top {
         int x() { 1 }
      }
      
      @groovy.transform.CompileStatic
      class Bottom extends Top {
         int x() {
            Thread.start { println(super.x()) }
            2
         }
      }
      
      new Bottom().x()
      

      Removing @CompileStatic fixes the issue. The problem is very likely that the static compiler interprets "super" as the super from the closure instead of the super from the owner. Which also means a bridge method might be needed.

      Attachments

        Activity

          People

            melix Cédric Champeau
            melix Cédric Champeau
            Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: