groovy-notifications mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "ASF GitHub Bot (JIRA)" <j...@apache.org>
Subject [jira] [Commented] (GROOVY-7905) ListWithDefault DGM methods aren't type inference friendly
Date Sun, 18 Sep 2016 10:16:21 GMT

    [ https://issues.apache.org/jira/browse/GROOVY-7905?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=15500721#comment-15500721
] 

ASF GitHub Bot commented on GROOVY-7905:
----------------------------------------

Github user paulk-asert closed the pull request at:

    https://github.com/apache/groovy/pull/383


> ListWithDefault DGM methods aren't type inference friendly
> ----------------------------------------------------------
>
>                 Key: GROOVY-7905
>                 URL: https://issues.apache.org/jira/browse/GROOVY-7905
>             Project: Groovy
>          Issue Type: Improvement
>            Reporter: Paul King
>            Assignee: Paul King
>
> For the following script:
> {code}
> @groovy.transform.CompileStatic
> def method() {
>     def list = [].withDefault{ it.longValue() }
>     list[0] = list[3]
>     assert list[0] == 3 && list[0].class == Long
> }
> method()
> {code}
> The list access call {{list[3]}} doesn't funnel through the {{ListWithDefault.getAt(int)}}
method but instead the {{DGM.getAt(List, int)}} method since {{List}} is the inferred type.
The {{withDefault}} methods could instead return the more specific type and then the correct
type will be inferred and the expected behavior is observed.



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

Mime
View raw message