You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@groovy.apache.org by "Andrei Amariei (JIRA)" <ji...@apache.org> on 2015/10/12 23:08:05 UTC

[jira] [Updated] (GROOVY-7622) no auto-conversion to generic type argument

     [ https://issues.apache.org/jira/browse/GROOVY-7622?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Andrei Amariei updated GROOVY-7622:
-----------------------------------
    Description: 
Generic type argument doesn't force type conversion, leading to runtime exceptions. Two such cases are included in the test below.

{code}
class AutoConvertingToGenericTypeArguments {
    @Test
    void "value in map constructor parameter converted to generic type argument"() {
        Person p = new Person(id: 1);
        assert p.id.class == Long
    }

    @Test
    //@CompileStatic unintuitively makes the test pass
    void "setter parameter converted to generic type argument"() {
        Person p = new Person();
        p.id = 1
        assert p.id.class == Long
    }

    class Entity<ID> { ID id; }
    class Person extends Entity<Long> {}
}
{code}

  was:
Generic type argument is doesn't force conversion, leading to runtime exceptions. Two such cases are included in the test below.

{code}
class AutoConvertingToGenericTypeArguments {
    @Test
    void "value in map constructor parameter converted to generic type argument"() {
        Person p = new Person(id: 1);
        assert p.id.class == Long
    }

    @Test
    //@CompileStatic unintuitively makes the test pass
    void "setter parameter converted to generic type argument"() {
        Person p = new Person();
        p.id = 1
        assert p.id.class == Long
    }

    class Entity<ID> { ID id; }
    class Person extends Entity<Long> {}
}
{code}


> no auto-conversion to generic type argument
> -------------------------------------------
>
>                 Key: GROOVY-7622
>                 URL: https://issues.apache.org/jira/browse/GROOVY-7622
>             Project: Groovy
>          Issue Type: Bug
>    Affects Versions: 2.4.5
>            Reporter: Andrei Amariei
>
> Generic type argument doesn't force type conversion, leading to runtime exceptions. Two such cases are included in the test below.
> {code}
> class AutoConvertingToGenericTypeArguments {
>     @Test
>     void "value in map constructor parameter converted to generic type argument"() {
>         Person p = new Person(id: 1);
>         assert p.id.class == Long
>     }
>     @Test
>     //@CompileStatic unintuitively makes the test pass
>     void "setter parameter converted to generic type argument"() {
>         Person p = new Person();
>         p.id = 1
>         assert p.id.class == Long
>     }
>     class Entity<ID> { ID id; }
>     class Person extends Entity<Long> {}
> }
> {code}



--
This message was sent by Atlassian JIRA
(v6.3.4#6332)