Details
-
Bug
-
Status: Closed
-
Major
-
Resolution: Fixed
-
None
-
None
Description
Our tree-building code is a bit more than this, but I was able to trim back and still produce the run-time exception:
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'] )
Changing the type of "one" from "List" to "def" stops the madness.