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] [Commented] (GROOVY-7753) regression of return type from ternary operator
Date Tue, 22 May 2018 23:27:00 GMT

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

Paul King commented on GROOVY-7753:
-----------------------------------

Hi Daniel, can you link the new issue to this one. Thanks.

> regression of return type from ternary operator
> -----------------------------------------------
>
>                 Key: GROOVY-7753
>                 URL: https://issues.apache.org/jira/browse/GROOVY-7753
>             Project: Groovy
>          Issue Type: Bug
>          Components: Static compilation, Static Type Checker
>    Affects Versions: 2.4.6
>            Reporter: Jason Winnebeck
>            Assignee: Daniel Sun
>            Priority: Major
>             Fix For: 2.6.0-alpha-4, 3.0.0-alpha-3, 2.5.0-rc-3
>
>
> In Groovy 2.4.5 the following code works, but in Groovy 2.4.6, it fails to compile:
> {code}
> @groovy.transform.Field
> String x = "X"
> @groovy.transform.CompileStatic
> public List<String> getStrings() {
> 	x ? [x] : Collections.emptyList()
> }
> getStrings()
> {code}
> In Groovy 2.4.6 the compile error is:
> {code}
> [Static type checking] - Incompatible generic argument types. Cannot assign java.util.List
<? extends java.lang.Object> to: java.util.List <String>
>  @ line 6, column 2.
>     x ? [x] : Collections.emptyList()
>     ^
> {code}
> Workaround is to cast the result of emptyList to the erased type, (List) in this case.



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

Mime
View raw message