[ 
https://issues.apache.org/jira/browse/GROOVY-11956?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel
 ]

Eric Milles resolved GROOVY-11956.
----------------------------------
    Fix Version/s: 5.0.6
       Resolution: Fixed

https://github.com/apache/groovy/commit/8b8687aedffb3a6c6c79ebd510fc79262724390b

> SC: mixed property definition and map-style constructor call
> ------------------------------------------------------------
>
>                 Key: GROOVY-11956
>                 URL: https://issues.apache.org/jira/browse/GROOVY-11956
>             Project: Groovy
>          Issue Type: Bug
>          Components: Static compilation
>            Reporter: Eric Milles
>            Assignee: Eric Milles
>            Priority: Major
>             Fix For: 5.0.6
>
>
> Consider the following:
> {code:java}
> package p;
> class C {
>   public String getFoo() { return "foo"; }
>   protected void setFoo(String foo) { /*...*/ }
> }
> {code}
> {code:groovy}
> @groovy.transform.CompileStatic
> void test() {
>   new p.C(foo:'bar')
> }
> {code}
> STC sees a read-only property because the setter is protected.  This falls 
> into {{checkGroovyConstructorMap}} with an empty {{propertyTypes}} set.  Then 
> an index OOB exception within {{UnionTypeClassNode#<init>}}.
> --------
> If C is modified slightly to add a private field "foo" then the OOB exception 
> is side-stepped.  However, an error "Cannot access method: 
> setFoo(java.lang.String) of class: p.C" comes on the first line of the source 
> file, far away from the ctor call or the property set line.



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

Reply via email to