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:25:04 UTC

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

     [ https://issues.apache.org/jira/browse/GROOVY-7505?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Cédric Champeau updated GROOVY-7505:
------------------------------------
    Summary: Change In cast operator precedence  (was: Change In Static Compiler Behavior)

> 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)