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

Paul King closed GROOVY-11353.
------------------------------

> SC: variable initialized to null and assigned primitive value in loop
> ---------------------------------------------------------------------
>
>                 Key: GROOVY-11353
>                 URL: https://issues.apache.org/jira/browse/GROOVY-11353
>             Project: Groovy
>          Issue Type: Bug
>          Components: Static compilation
>            Reporter: Eric Milles
>            Assignee: Eric Milles
>            Priority: Major
>             Fix For: 4.0.23, 5.0.0-alpha-10
>
>
> Consider the following:
> {code:groovy}
> @CompileStatic
> void test() {
>   def foo = null // GroovyCastException: Cannot cast object 'null' with class 
> 'null' to class 'int'
>   for (int i = 0; i < 1; i += 1) {
>     foo = i
>   }
>   print foo
> }
> test()
> {code}
> STC works out the type of "foo" to be {{int}} and so the initialization to 
> {{null}} produces a cast exception.



--
This message was sent by Atlassian Jira
(v8.20.10#820010)

Reply via email to