Eric Milles created GROOVY-11353:
------------------------------------

             Summary: 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


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