groovy-notifications mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Paul King (JIRA)" <j...@apache.org>
Subject [jira] [Comment Edited] (GROOVY-8090) Incorrectly processing method-level type generics information
Date Sun, 26 Aug 2018 04:52:00 GMT

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

Paul King edited comment on GROOVY-8090 at 8/26/18 4:51 AM:
------------------------------------------------------------

Yes, the two other lines are to show cases that we currently "handle". Obviously the {{T}}
case although passing must only be partially "handling" since otherwise you'd expect the {{U}}
case to also work not just because we happened to use the same generic type name as used to
define {{Arrays#asList}}.


was (Author: paulk):
Yes, the two other lines are to show cases that we currently "handle". Obviously the {{T}}
case although passing must only be partially "handling" since otherwise you'd expect the {{U}}
case to also work not just because we happened to use the same generic type name as used to
define {{Arrays#asList}}..

> Incorrectly processing method-level type generics information
> -------------------------------------------------------------
>
>                 Key: GROOVY-8090
>                 URL: https://issues.apache.org/jira/browse/GROOVY-8090
>             Project: Groovy
>          Issue Type: Bug
>          Components: Static Type Checker
>    Affects Versions: 2.4.8
>            Reporter: Paul King
>            Priority: Major
>
> {code}
> import static java.util.Arrays.asList
> @groovy.transform.CompileStatic
> class Main {
>     final <T> Iterable<T> foo(T instance) { asList(instance) }
>     // next line fails with: [Static type checking] - Cannot call <T> java.util.Arrays#asList(T[])
with arguments [U]
>     final <U> Iterable<U> bar(U instance) { asList(instance) }
>     final Iterable<String> baz(String instance) { asList(instance) }
> }
> new Main().with {
>     assert foo('A') + bar('B') + baz('C') == ['A', 'B', 'C']
> }
> {code}



--
This message was sent by Atlassian JIRA
(v7.6.3#76005)

Mime
View raw message