[ https://issues.apache.org/jira/browse/GROOVY-7247 ]


    Eric Milles deleted comment on GROOVY-7247:
    -------------------------------------

was (Author: emilles):
The first case ({{Map<String,Integer> map = [\*:[A:1],\*:[B:2]]}}) works in 
4.0b2.  The second case is still an issue.

> 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
>            Assignee: Eric Milles
>            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.20.10#820010)

Reply via email to