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 2021/10/22 15:06:00 UTC

[jira] [Updated] (GROOVY-7247) spreadMap type inference is incorrect and STC reports on valid code

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

Eric Milles updated GROOVY-7247:
--------------------------------
    Environment:     (was: groovy --version
Groovy Version: 2.4.0-rc-2 JVM: 1.8.0_25 Vendor: Oracle Corporation OS: Mac OS X)

> spreadMap type inference is incorrect and STC reports on valid code
> -------------------------------------------------------------------
>
>                 Key: GROOVY-7247
>                 URL: https://issues.apache.org/jira/browse/GROOVY-7247
>             Project: Groovy
>          Issue Type: Bug
>          Components: Static Type Checker
>            Reporter: UEHARA Junji
>            Priority: Major
>
> STC reports false error on spreadMap operation:
> {code}
> @groovy.transform.TypeChecked
> def f() {
>     Map<String, Integer> map1 = [ *:[A:1], *:[B:2]] // [Static type checking] - Incompatible generic argument types. Cannot assign java.util.LinkedHashMap <java.util.Map, java.util.LinkedHashMap> to: java.util.Map <String, Integer>
>     assert map1  == [A:1, B:2]
>     println map1
>     Map<String, Integer> submap1 = [A: 1]
>     Map<String, Integer> submap2 = [B: 2]
>     Map<String, Integer> map2 = [*:submap1, *:submap2] // [Static type checking] - Incompatible generic argument types. Cannot assign java.util.LinkedHashMap <java.util.Map, java.util.LinkedHashMap> to: java.util.Map <String, Integer>
>     assert map2  == [A:1, B:2]
>     println map2
> }
> f()
> {code}



--
This message was sent by Atlassian Jira
(v8.3.4#803005)