You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@groovy.apache.org by "Paul King (Jira)" <ji...@apache.org> on 2022/04/27 08:34:00 UTC
[jira] [Closed] (GROOVY-10589) TypeChecked/CompileStatic Incompatible generic argument types regression for List.sort(boolean, Comparator)
[ https://issues.apache.org/jira/browse/GROOVY-10589?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]
Paul King closed GROOVY-10589.
------------------------------
> TypeChecked/CompileStatic Incompatible generic argument types regression for List.sort(boolean, Comparator)
> -----------------------------------------------------------------------------------------------------------
>
> Key: GROOVY-10589
> URL: https://issues.apache.org/jira/browse/GROOVY-10589
> Project: Groovy
> Issue Type: Bug
> Components: Static compilation, Static Type Checker
> Affects Versions: 4.0.1
> Reporter: Leonard Brünings
> Priority: Major
> Fix For: 4.0.2
>
>
> {code:groovy}
> import groovy.transform.*
> import java.time.Instant
> @CompileStatic
> class Reproducer {
> static final Comparator<Record> RECORD_COMPARATOR = { Record a, Record b -> a.timestamp <=> b.timestamp }
>
> List<Record> records = []
>
>
> List<Record> getSortedRecords() {
> records.sort(false, RECORD_COMPARATOR)
> }
> }
> @TupleConstructor
> @CompileStatic
> class Record {
> final Instant timestamp
> }
> {code}
> fails with
> {noformat}
> [Static type checking] - Incompatible generic argument types. Cannot assign java.util.List<? extends Record> to: java.util.List<Record>
> @ line 12, column 9.
> {noformat}
> [Groovy Web Console|https://gwc-experiment.appspot.com/?g=groovy_4_0&codez=eJx1UMtqwzAQvOsr9piUVF-QmAa3h0KLi5JbKWUjy0FFssRKDpTgf68suWkgdA567Wh2Z7T1jiIcybnTN4-EfegcWX7HdKl84Ql51Fbx5z5E7CNjD7WzXhu1ixi1ZNJgCCCUJ9cOUhGcGSSEXIVO92hg-oGE0dFaKOmorUA81Y14_Kyb17et2O4bARs4Q6kCrn5PB7ivoEyQFK2H9aaCw9V9zN3y8qJDvOhT3kNSff_4o9zyjiruklHVloewWM4GJswiPCTGokMT1Op28GWmj2xM0ewHb1TtUlQ0yGT3v7Cyt9ynBDSHCxdfkxpc4QfhEYct]
--
This message was sent by Atlassian Jira
(v8.20.7#820007)