[ 
https://issues.apache.org/jira/browse/GROOVY-11956?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=18077715#comment-18077715
 ] 

Paul King commented on GROOVY-11956:
------------------------------------

On GitHub actions JDKs 11-15 were failing with:

{noformat}
> Task :test

RecordTest > testCoerce() FAILED
    org.codehaus.groovy.control.MultipleCompilationErrorsException: startup 
failed:
    TestScript23.groovy: 34: [Static type checking] - Cannot set read-only 
property: age
     @ line 34, column 36.
                       PersonStatic p2 = [age: 37, name: 'Daniel']
                                          ^

    TestScript23.groovy: 34: [Static type checking] - Cannot set read-only 
property: name
     @ line 34, column 45.
                       PersonStatic p2 = [age: 37, name: 'Daniel']
                                                   ^

    TestScript23.groovy: 42: [Static type checking] - Cannot set read-only 
property: age
     @ line 42, column 37.
                       PersonDynamic p4 = [age: 37, name: 'Daniel']
                                           ^

    TestScript23.groovy: 42: [Static type checking] - Cannot set read-only 
property: name
     @ line 42, column 46.
                       PersonDynamic p4 = [age: 37, name: 'Daniel']
                                                    ^

    4 errors
{noformat}

> 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