You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@groovy.apache.org by "Shil Sinha (JIRA)" <ji...@apache.org> on 2015/11/06 19:09:11 UTC
[jira] [Commented] (GROOVY-7658) Type inference on closures
implicitly coerced to Comparator doesn't work
[ https://issues.apache.org/jira/browse/GROOVY-7658?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=14994107#comment-14994107 ]
Shil Sinha commented on GROOVY-7658:
------------------------------------
[~pledbrook] This appears to be a duplicate of GROOVY-7061. Were you seeing a different error here?
> Type inference on closures implicitly coerced to Comparator doesn't work
> ------------------------------------------------------------------------
>
> Key: GROOVY-7658
> URL: https://issues.apache.org/jira/browse/GROOVY-7658
> Project: Groovy
> Issue Type: Bug
> Components: Static Type Checker
> Affects Versions: 2.4.3
> Environment: Mac OS X, JDK 7,8
> Reporter: Peter Ledbrook
> Assignee: Cédric Champeau
>
> The following example doesn't compile:
> {code}
> import groovy.transform.TypeChecked
> @TypeChecked
> def someMethod() {
> List<Integer> numbers = [1, 4, 56, 35]
> Collections.sort(numbers, { a, b -> a.abs() <=> b.abs() })
> }
> {code}
> It seems that the {{Comparator}} interface defines the {{equals()}} method, and so it's not treated as a Single Abstract Method contract, despite {{equals()}} being defined on {{Object}}.
> From the mailing list, it seems that {{Object}} methods should be ignored when determining whether an interface is a SAM one or not. This is what happens when you use the {{as Comparator}} syntax.
> PS No source code formatter for Groovy in JIRA? That makes me sad.
--
This message was sent by Atlassian JIRA
(v6.3.4#6332)