groovy-notifications mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Paul King (JIRA)" <j...@apache.org>
Subject [jira] [Updated] (GROOVY-7447) Special Map index notation not supported via TypeChecked
Date Mon, 01 Jun 2015 12:39:18 GMT

     [ 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)

Mime
View raw message