It seems that the correct type is inferred only in the simple way where assignment is made at the location of declaration. Maybe it can be improved?

It does not work, for example, when def variable is assigned in Spock's setup().
Related article from 2009: http://contraptionsforprogramming.blogspot.com/2009/11/how-type-inferencing-for-groovy-in.html
It seems that the correct type is inferred only in the simple way where assignment is made at the location of declaration. Maybe it can be improved?
It does not work, for example, when
defvariable is assigned in Spock'ssetup().Related article from 2009: http://contraptionsforprogramming.blogspot.com/2009/11/how-type-inferencing-for-groovy-in.html