You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@groovy.apache.org by "Cédric Champeau (JIRA)" <ji...@apache.org> on 2015/07/17 12:27:04 UTC

[jira] [Commented] (GROOVY-7505) Change In cast operator precedence

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

Cédric Champeau commented on GROOVY-7505:
-----------------------------------------

I don't expect that we rollback the change. After all it's a bugfix, so even if it is a breaking change, it means that the code was relying on a bug. The operator precedence is now the same as Java, which should be more natural.

However the decision is not definitive, so we don't close this ticket. if you think it should be rolled back in a dot release, feel free to start a thread on the dev@ list. 

> Change In cast operator precedence
> ----------------------------------
>
>                 Key: GROOVY-7505
>                 URL: https://issues.apache.org/jira/browse/GROOVY-7505
>             Project: Groovy
>          Issue Type: Bug
>          Components: Static compilation
>            Reporter: Jeff Scott Brown
>            Assignee: Cédric Champeau
>
> The following code compiles with Groovy 2.4.3 and will not compile with Groovy 2.4.4.
> {code:title=Demo.groovy|borderStyle=solid}
> import groovy.transform.CompileStatic
> @CompileStatic
> class Demo {
>     String[] getStrings(boolean b) {
>         (String[]) b ? methodOne() : methodTwo()
>     }
>     String[] methodOne() {
>         ['Chris Squire'] as String[]
>     }
>     String[] methodTwo() {
>         ['Chris Squire'] as String[]
>     }
> }
> {code}
> {noformat}
> /Users/jeff/expressionquestion/src/main/groovy/demo/Demo.groovy: 9: [Static type checking] - Inconvertible types: cannot cast boolean to java.lang.String[]
>  @ line 9, column 9.
>            (String[]) b ? methodOne() : methodTwo()
>            ^
> 1 error
> :compileGroovy FAILED
> FAILURE: Build failed with an exception.
> {noformat}
> Is that intentional?



--
This message was sent by Atlassian JIRA
(v6.3.4#6332)