Flow typing support is very basic at the moment. As the inference engine moves through the statements of a block, variable assignments overwrite the inferred type of the assigned variable. This does not consider conditional paths like nested closure blocks or blocks that return/throw.
def m1(def x) {
def cl = { ->
x = 1
}
x // type remains Object because Closure is not executed
}
def m2(def x) {
if (predicate()) {
x = 1
return 0
}
x // type remains Object because conditional block does not share path here
}
def m3(def x) {
if (x instanceof CharSequence) {
x = Integer.valueOf(x)
}
x // bug prevents assignment within instanceof guard from propagating type info
}
Flow typing support is very basic at the moment. As the inference engine moves through the statements of a block, variable assignments overwrite the inferred type of the assigned variable. This does not consider conditional paths like nested closure blocks or blocks that return/throw.