You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@groovy.apache.org by "Paul King (Jira)" <ji...@apache.org> on 2023/12/22 11:39:00 UTC

[jira] [Closed] (GROOVY-11189) STC LUB of List and Set is not Collection for Java 21

     [ https://issues.apache.org/jira/browse/GROOVY-11189?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Paul King closed GROOVY-11189.
------------------------------

> STC LUB of List and Set is not Collection for Java 21
> -----------------------------------------------------
>
>                 Key: GROOVY-11189
>                 URL: https://issues.apache.org/jira/browse/GROOVY-11189
>             Project: Groovy
>          Issue Type: Bug
>          Components: Static Type Checker
>    Affects Versions: 5.0.0-alpha-2, 4.0.15
>            Reporter: Eric Milles
>            Assignee: Eric Milles
>            Priority: Major
>             Fix For: 5.0.0-alpha-3, 4.0.16
>
>
> The new {{SequencedCollection}} interface introduced in Java 21 has altered the type inference results for mixed use of {{List}} and {{Set}}.  Consider the following:
> {code:groovy}
> def x
> x = [] as List
> if (predicate()) {
>   x = [] as Set
> }
> x
> {code}
> Under STC, the inferred type of the last occurrence of "x" has changed from {{Collection}} to {{Object}}.



--
This message was sent by Atlassian Jira
(v8.20.10#820010)