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

STC: mixed checking for access to non-public fields

    XMLWordPrintableJSON

    Details

    • Type: Bug
    • Status: Closed
    • Priority: Major
    • Resolution: Fixed
    • Affects Version/s: None
    • Fix Version/s: 3.0.0-rc-2
    • Component/s: None
    • Labels:
      None

      Description

      Follow up to GROOVY-8999, GROOVY-9093 and GROOVY-9136. Consider the following:

      class Foo {
        private String field = 'value'
      }
      class Bar {
        @groovy.transform.CompileStatic
        void test(Foo foo) {
          foo.with {
            field // Access to Foo#field is forbidden
          }
        }
      }
      
      class Foo {
        private String field = 'value'
      }
      class Bar {
        @groovy.transform.CompileStatic
        void test(Foo foo) {
          println foo.field
        }
      }
      new Bar().test(new Foo()) // prints "value"
      

      Since STC produces an error for access to Foo.field as variable expression, I would expect the same error for access to the field through property expression. Same goes for protected and package-private with the appropriate package separation of Foo and Bar.

        Attachments

          Issue Links

            Activity

              People

              • Assignee:
                emilles Eric Milles
                Reporter:
                emilles Eric Milles
              • Votes:
                0 Vote for this issue
                Watchers:
                1 Start watching this issue

                Dates

                • Created:
                  Updated:
                  Resolved:

                  Time Tracking

                  Estimated:
                  Original Estimate - Not Specified
                  Not Specified
                  Remaining:
                  Remaining Estimate - 0h
                  0h
                  Logged:
                  Time Spent - 40m
                  40m