groovy-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From C├ędric Champeau <cedric.champ...@gmail.com>
Subject Re: type checked with generics issue
Date Wed, 26 Aug 2015 08:19:23 GMT
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" }
> }
>
> @TypeChecked
> 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
>
>

Mime
View raw message