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

static compiler fails to eliminate dynamic property lookup

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Closed
    • Major
    • Resolution: Fixed
    • None
    • 2.4.1
    • Static compilation
    • None

    Description

      class Foo {
          private i = 1
          @groovy.transform.CompileStatic
          def m() { new String().with {i}}
      }
      assert new Foo().m() == 1
      class Bar extends Foo {}
      assert new Bar().m() == 1

      For this code the static compiler is supposed to create a bridge method in Foo and provide access to the private field "i" through that, as well as calling the method directly from within the with-block. Instead the compiler works using dynamic property access, which will cause the property not being found in the second assert because of MOP limitations

      Attachments

        Issue Links

          Activity

            People

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

              Dates

                Created:
                Updated:
                Resolved: