Uploaded image for project: 'Jenkins'
  1. Jenkins
  2. JENKINS-60599

Closure in CPS-transformed method fails to resolve automatic property getter which implements abstract method unless "this" qualifier is provided


      Sample code which demonstrates the issue:

      abstract class SuperBuild {
          // If I comment this out, the problem goes away
          abstract String getTestString()
      class Build extends SuperBuild {
          String testString = 'hello'
          // Replace above with this and it works
          //String getTestString() { 'hello' }
          // Adding @NonCPS annotation here also makes the problem go away
          void test() {
              // Works as expected
              assert testString == 'hello'
              Closure cl = {
                  // Works as expected
                  assert resolveStrategy == Closure.OWNER_FIRST
                  assert getOwner() instanceof Build
                  assert this.testString == 'hello'
                  // Fails with: No such field found: field org.jenkinsci.plugins.workflow.cps.CpsClosure2 testString
                  assert testString == 'hello'
      new Build().test()

      The same code works as expected when run directly with Groovy 2.4.12

            Unassigned Unassigned
            aaronm Aaron Miller
            1 Vote for this issue
            1 Start watching this issue