[ https://issues.apache.org/jira/browse/GROOVY-8220?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=16177906#comment-16177906 ]
ASF GitHub Bot commented on GROOVY-8220: ---------------------------------------- GitHub user jwagenleitner opened a pull request: https://github.com/apache/groovy/pull/605 GROOVY-8220: SC GroovyCastException on parameter flow typing GROOVY-8157 introduced flow typing for parameters and this fix is required in order to track their assignments in `if` branches for temporary type assignments. You can merge this pull request into a Git repository by running: $ git pull https://github.com/jwagenleitner/groovy 8220-ParameterFlowTyping Alternatively you can review and apply these changes as the patch at: https://github.com/apache/groovy/pull/605.patch To close this pull request, make a commit to your master/trunk branch with (at least) the following in the commit message: This closes #605 ---- commit ad5074b4db073ebefd1af21676675671a62f6064 Author: John Wagenleitner <jwagenleit...@apache.org> Date: 2017-09-08T00:27:06Z GROOVY-8220: SC GroovyCastException on parameter flow typing GROOVY-8157 introduced flow typing for parameters and this fix is required in order to track their assignments in `if` branches for temporary type assignments. ---- > GroovyCastException with CompileStatic > -------------------------------------- > > Key: GROOVY-8220 > URL: https://issues.apache.org/jira/browse/GROOVY-8220 > Project: Groovy > Issue Type: Bug > Affects Versions: 2.5.0-beta-1, 2.4.12 > Reporter: paolo di tommaso > > {code} > @groovy.transform.CompileStatic > class Foo { > CharSequence makeEnv( env, StringBuilder result = new StringBuilder() ) { > if( env instanceof File ) { > env = env.toPath() > } > if( env instanceof String && env.contains('=') ) { > result << 'export ' << env << ';' > } > return result.toString() > } > } > assert new Foo().makeEnv('X=1') == 'export X=1;' > Exception thrown > org.codehaus.groovy.runtime.typehandling.GroovyCastException: Cannot cast > object 'X=1' with class 'java.lang.String' to class 'java.lang.Iterable' > at Foo.makeEnv(ConsoleScript5:10) > at Foo.makeEnv(ConsoleScript5:4) > at Foo$makeEnv.call(Unknown Source) > at ConsoleScript5.run(ConsoleScript5:20) > {code} > Without CompileStatic it works as expected. -- This message was sent by Atlassian JIRA (v6.4.14#64029)