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

This issue is archived. You can view it, but you can't modify it. Learn more

XMLWordPrintable

      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

            Assignee:
            Unassigned
            Reporter:
            Aaron Miller
            Archiver:
            Jenkins Service Account

              Created:
              Updated:
              Archived: