You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@groovy.apache.org by "Paul King (JIRA)" <ji...@apache.org> on 2015/06/01 14:39:18 UTC
[jira] [Updated] (GROOVY-7447) Special Map index notation not
supported via TypeChecked
[ https://issues.apache.org/jira/browse/GROOVY-7447?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]
Paul King updated GROOVY-7447:
------------------------------
Description:
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}
was:
As a follow-on from GROOVY-4255, 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}
> 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
> Assignee: Cédric Champeau
>
> 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
(v6.3.4#6332)