You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@groovy.apache.org by "Eric Milles (Jira)" <ji...@apache.org> on 2026/03/07 16:46:00 UTC
[jira] [Resolved] (GROOVY-11870) STC: setter call list and dynamic-type addition
[ https://issues.apache.org/jira/browse/GROOVY-11870?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]
Eric Milles resolved GROOVY-11870.
----------------------------------
Fix Version/s: 5.0.5
Resolution: Fixed
https://github.com/apache/groovy/commit/d99e5fd4d5b5628c1bf4c508a7baa82fd6cd7248
> 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)