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

STC: add error for write of private or package-private field of super class

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Resolved
    • Minor
    • Resolution: Fixed
    • None
    • 5.0.0-alpha-9, 4.0.22
    • None
    • None

    Description

      GROOVY-8999, GROOVY-9093, GROOVY-9136, GROOVY-9195, GROOVY-9288, GROOVY-9292, GROOVY-9293, GROOVY-9695 and others cover various scenarios where read access to a field should or should not be allowed. One scenario that is yet uncovered is writing to a private or package-private field from a super class.

      Consider the following:

      package p
      class C {
        private /*or @PackageScope*/ Object field
      }
      
      package q
      class D extends C {
        @groovy.transform.CompileStatic
        void test() {
          field = null // should be error
        }
      }
      

      Also need static, closure and inner class variants.

      I also think that @TypeChecked is not producing errors for any field access cases. Not sure if it is desirable to limit the checks to the SC path.

      Attachments

        Issue Links

          Activity

            People

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

              Dates

                Created:
                Updated:
                Resolved: