Eric Milles created GROOVY-11870:
------------------------------------
Summary: STC: setter call list and dynamic-type addition
Key: GROOVY-11870
URL: https://issues.apache.org/jira/browse/GROOVY-11870
Project: Groovy
Issue Type: Bug
Components: Static Type Checker
Reporter: Eric Milles
Assignee: Eric Milles
Consider the following:
{code:groovy}
class Pogo {
List<Long> getList() {
}
void setList(List<Long> longs) {
}
}
@TypeChecked m(List<Pogo> pogos) {
for (pogo in pogos) {
pogo.list = [] // Cannot assign java.util.ArrayList<java.lang.Object> to:
java.util.List<java.lang.Long>
def item = 42L
pogo.list.add(item)
}
}
{code}
When the property expression "pogo.list" is backed by getter and setter (not
property), the addition of a dynamic-typed item "def item = ..." causes an
error on the init line "pogo.list = []".
Changing the the of {{item}} to {{Long}} and the error goes away.
--
This message was sent by Atlassian Jira
(v8.20.10#820010)