groovy-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Jamie Echlin <>
Subject type checked with generics issue
Date Wed, 26 Aug 2015 08:14:52 GMT
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 == "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

View raw message