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

static compiler fails to eliminate dynamic property lookup

    XMLWordPrintableJSON

    Details

    • Type: Bug
    • Status: Closed
    • Priority: Major
    • Resolution: Fixed
    • Affects Version/s: None
    • Fix Version/s: 2.4.1
    • Component/s: Static compilation
    • Labels:
      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

              • Assignee:
                melix C├ędric Champeau
                Reporter:
                blackdrag Jochen Theodorou
              • Votes:
                0 Vote for this issue
                Watchers:
                1 Start watching this issue

                Dates

                • Created:
                  Updated:
                  Resolved: