groovy-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Winnebeck, Jason" <>
Subject RE: type checked with generics issue
Date Wed, 26 Aug 2015 12:32:54 GMT
Whoever wrote that type inference documentation should be commended, it is very good and very
thorough. Very understandable and easy to read yet detailed enough even to satisfy the curiosity
of “how did they get that to work?”. In fact, since moving out of Codehaus wiki, the documentation
is far improved. From a user’s perspective I was concerned at first that a rewrite would
take forever, but it didn’t and these new docs continue to impress each time I open them.


From: Cédric Champeau []
Sent: Wednesday, August 26, 2015 4:19 AM
Subject: Re: type checked with generics issue

Hi Jamie,

for an explanation.

2015-08-26 10:14 GMT+02:00 Jamie Echlin <<>>:
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

This email message and any attachments are for the sole use of the intended recipient(s).
Any unauthorized review, use, disclosure or distribution is prohibited. If you are not the
intended recipient, please contact the sender by reply email and destroy all copies of the
original message and any attachments.
View raw message