[jira] [Commented] (GROOVY-7753) regression of return type from ternary operator

2017-02-07 Thread M. Justin (JIRA)

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

M. Justin commented on GROOVY-7753:
---

I have the same issue when I attempt to assign the value to a variable, as well 
as when I use the empty list literal instead of Collections.emptyList.  Is this 
the same issue, or should I open a new issue for it?

{code}List stringList1 = ['a'] ?: []
List stringList2 = true ? ['b'] : []{code}

This is one place where Java has @CompileStatic Groovy beat, as its type 
inference does a better job with this sort of thing.

> 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
>
> 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 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  to: java.util.List 
>  @ 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.15#6346)


[jira] [Commented] (GROOVY-7753) regression of return type from ternary operator

2017-11-20 Thread Paul King (JIRA)

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

Paul King commented on GROOVY-7753:
---

@mjjustin This should be fixed for assignments (GROOVY-8255) and field/property 
initializers (GROOVY-8382) but not currently for return types.

> 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
>
> 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 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  to: java.util.List 
>  @ 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.4.14#64029)


[jira] [Commented] (GROOVY-7753) regression of return type from ternary operator

2018-05-22 Thread Paul King (JIRA)

[ 
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 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  to: java.util.List 
>  @ 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)


[jira] [Commented] (GROOVY-7753) regression of return type from ternary operator

2016-02-22 Thread Shil Sinha (JIRA)

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

Shil Sinha commented on GROOVY-7753:


Changed the title to reflect that this issue is about the ternary operator and 
not the elvis.

> 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
>
> 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 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  to: java.util.List 
>  @ 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)