[ https://issues.apache.org/jira/browse/GROOVY-7447?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]
Eric Milles resolved GROOVY-7447. --------------------------------- Resolution: Fixed > Special Map index notation not supported via TypeChecked > -------------------------------------------------------- > > Key: GROOVY-7447 > URL: https://issues.apache.org/jira/browse/GROOVY-7447 > Project: Groovy > Issue Type: Bug > Components: Static Type Checker > Affects Versions: 2.4.3 > Reporter: Paul King > Priority: Major > > As a follow-on from GROOVY-4787, the following code: > {code} > @groovy.transform.ToString > class Person { String name; int age } > @groovy.transform.TypeChecked > def myMethod() { > assert Person[ name:'Dave', age:32 ].toString() == 'Person(Dave, 32)' > def timMap = [ name:'Tim', age:49 ] > assert Person[ *:timMap ].toString() == 'Person(Tim, 49)' > assert Person[ *:[ name:'John', age:29 ] ].toString() == > 'Person(John, 29)' > def ppl = [ [ name:'Tim', age:49 ], [ name:'Dave', age:32 ], [ > name:'Steve', age:18 ] ] > assert ppl.collect { Person [ *:it ] }*.age == [49, 32, 18] > } > myMethod() > {code} > fails compilation with the following errors" > {noformat} > [Static type checking] - Inconvertible types: cannot cast > java.util.LinkedHashMap <java.lang.String, java.io.Serializable> to Person > at line: 6, column: 16 > [Static type checking] - Inconvertible types: cannot cast > java.util.LinkedHashMap <java.lang.String, java.io.Serializable> to Person > at line: 9, column: 16 > [Static type checking] - Inconvertible types: cannot cast > java.util.LinkedHashMap <java.lang.String, java.io.Serializable> to Person > at line: 11, column: 16 > [Static type checking] - Inconvertible types: cannot cast > java.util.LinkedHashMap <K extends java.lang.Object, V extends > java.lang.Object> to Person > at line: 14, column: 30 > {noformat} -- This message was sent by Atlassian Jira (v8.20.10#820010)