You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@groovy.apache.org by "Damir Murat (Jira)" <ji...@apache.org> on 2022/11/07 14:40:00 UTC

[jira] [Created] (GROOVY-10815) [STC] Access is forbidden for property-style access to getProperties() default Groovy method

Damir Murat created GROOVY-10815:
------------------------------------

             Summary: [STC] Access is forbidden for property-style access to getProperties() default Groovy method
                 Key: GROOVY-10815
                 URL: https://issues.apache.org/jira/browse/GROOVY-10815
             Project: Groovy
          Issue Type: Bug
          Components: Static compilation
    Affects Versions: 4.0.6
            Reporter: Damir Murat


With Groovy 4.0.6, the following code does not compile:
{code:java}
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     
{code}

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.



--
This message was sent by Atlassian Jira
(v8.20.10#820010)