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

SC: Access is forbidden for property-style access to getProperties() default Groovy method

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Closed
    • Major
    • Resolution: Fixed
    • 4.0.6
    • 4.0.7
    • Static compilation
    • None

    Description

      With Groovy 4.0.6, the following code does not compile:

      import groovy.transform.CompileStatic
      
      @CompileStatic
      class Person {
        String firstName
        String lastName  
      }
      
      @CompileStatic
      class Runner {
        static void runMe() {
          Person person = new Person(firstName: "First", lastName: "Last")
          println person.getProperties()
          println person.properties // -> Does not compile with an error "Access to Person#properties is forbidden"
        }
      }
      
      Runner.runMe()
      
      Person person = new Person(firstName: "First", lastName: "Last")
      println person.getProperties()
      println person.properties     
      

      If I comment/delete CompileStatic on the Runner class, the code works as expected.

      Similarly, and probably related to the issue, my own extension methods starting with "get" cannot be accessed too.

      Tnx.

      Attachments

        Issue Links

          Activity

            People

              emilles Eric Milles
              dmurat Damir Murat
              Votes:
              0 Vote for this issue
              Watchers:
              2 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved: