You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@groovy.apache.org by "Jason Winnebeck (JIRA)" <ji...@apache.org> on 2016/02/10 21:47:18 UTC
[jira] [Updated] (GROOVY-7753) 2.4.6-SNAPSHOT regression of return
type from ?: operator
[ https://issues.apache.org/jira/browse/GROOVY-7753?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]
Jason Winnebeck updated GROOVY-7753:
------------------------------------
Component/s: Static compilation
> 2.4.6-SNAPSHOT regression of return type from ?: 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
>
> 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
(v6.3.4#6332)