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

    XMLWordPrintable

    Details

    • Similar Issues:

      Description

      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

        Attachments

          Activity

          There are no comments yet on this issue.

            People

            Assignee:
            Unassigned Unassigned
            Reporter:
            aaronm Aaron Miller
            Votes:
            1 Vote for this issue
            Watchers:
            1 Start watching this issue

              Dates

              Created:
              Updated: