You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@groovy.apache.org by "Daniel Sun (JIRA)" <ji...@apache.org> on 2017/12/13 04:56:02 UTC
[jira] [Closed] (GROOVY-7061) Type inference not working for
Collections.sort()
[ https://issues.apache.org/jira/browse/GROOVY-7061?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]
Daniel Sun closed GROOVY-7061.
------------------------------
Resolution: Fixed
Assignee: Daniel Sun
Fix Version/s: 3.0.0-alpha-2
2.4.14
2.6.0-alpha-3
2.5.0-beta-3
Fixed by https://github.com/apache/groovy/commit/bd5191d9a8858945a4d83df58e261eb56bec0ab7
> Type inference not working for Collections.sort()
> -------------------------------------------------
>
> Key: GROOVY-7061
> URL: https://issues.apache.org/jira/browse/GROOVY-7061
> Project: Groovy
> Issue Type: Bug
> Components: Static Type Checker
> Affects Versions: 2.3.6, 2.4.5
> Reporter: Peter Ledbrook
> Assignee: Daniel Sun
> Fix For: 2.5.0-beta-3, 2.6.0-alpha-3, 2.4.14, 3.0.0-alpha-2
>
>
> In this example:
> {code}
> import groovy.transform.TypeChecked
> doIt()
> @TypeChecked
> void doIt() {
> List<Integer> nums = [1, 2, 3, -2, -5, 6]
> // nums.sort { a, b -> a.abs() <=> b.abs() }
> Collections.sort(nums, { a, b -> a.abs() <=> b.abs() })
> }
> {code}
> the type checking fails on the closure arguments (no method {{abs()}} on type {{Object}}). Interestingly, it works fine for the line that's commented out.
--
This message was sent by Atlassian JIRA
(v6.4.14#64029)