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/09 12:22:26 UTC

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

Andrei Amariei created GROOVY-7622:
--------------------------------------

             Summary: 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 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}



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