[
https://issues.apache.org/jira/browse/GROOVY-11870?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel
]
Paul King closed GROOVY-11870.
------------------------------
> 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
> Priority: Major
> Fix For: 5.0.5
>
>
> 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)