[
https://issues.apache.org/jira/browse/GROOVY-10089?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel
]
Paul King closed GROOVY-10089.
------------------------------
> SC: GroovyCastException for map value as constructor for Collection
> -------------------------------------------------------------------
>
> Key: GROOVY-10089
> URL: https://issues.apache.org/jira/browse/GROOVY-10089
> Project: Groovy
> Issue Type: Bug
> Components: Static compilation
> Reporter: Eric Milles
> Assignee: Eric Milles
> Priority: Major
> Fix For: 4.0.0-beta-1
>
>
> Our tree-building code is a bit more than this, but I was able to trim back
> and still produce the run-time exception:
> {code:groovy}
> def test(... attributes) {
> List one = [
> [id:'x', options:[count:1]]
> ]
> List two = attributes.collect {
> def node = Collections.singletonMap('children', one)
> if (node) {
> node = node.get('children').find { child -> child['id'] == 'x' }
> }
> // inferred type of node must be something like Map<String,List<...>>
> [id: it['id'], name: node['name'], count: node['options']['count']]
> // ^^^^^^^^^^^^^^^
> GroovyCastException (map ctor for Collection)
> }
> two
> }
> test( [id:'x'] )
> {code}
> Changing the type of "one" from "List" to "def" stops the madness.
--
This message was sent by Atlassian Jira
(v8.20.1#820001)