Hi Jamie,

See http://docs.groovy-lang.org/latest/html/documentation/#_variables_vs_fields_in_type_inference for an explanation.

2015-08-26 10:14 GMT+02:00 Jamie Echlin <jamie.echlin@gmail.com>:
I'm confused about the type checking in one instance. Take this:

class Foo {
    String getBar() { "bar" }

class TestFoo {

    def foo = new Foo()

    void test() {
        assert foo.bar == "bar"

If the def of foo is within the test() method it's fine, but where it is it seems not to be able to resolve the type (cannot resolve symbol "bar"). Why can't it infer the type - I don't see what will change the type between initialisation and the when the method is called.

cheers, jamie