[
https://issues.apache.org/jira/browse/GROOVY-7905?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=15418285#comment-15418285
]
ASF GitHub Bot commented on GROOVY-7905:
----------------------------------------
GitHub user paulk-asert opened a pull request:
https://github.com/apache/groovy/pull/383
GROOVY-7905: ListWithDefault DGM methods aren't type inference friendly
You can merge this pull request into a Git repository by running:
$ git pull https://github.com/paulk-asert/groovy groovy7905
Alternatively you can review and apply these changes as the patch at:
https://github.com/apache/groovy/pull/383.patch
To close this pull request, make a commit to your master/trunk branch
with (at least) the following in the commit message:
This closes #383
----
commit 1ad1fc35be20e2d9cd26c1162ae8de0578d4ae9c
Author: paulk <[email protected]>
Date: 2016-08-12T02:53:31Z
GROOVY-7905: ListWithDefault DGM methods aren't type inference friendly
----
> 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)