Eric Milles created GROOVY-11956:
------------------------------------
Summary: 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
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)