Details
-
Bug
-
Status: Closed
-
Major
-
Resolution: Won't Fix
-
1.8.0
-
None
-
None
-
Windows 7
Description
See the example
class Book { String title def service String toString() { return "$service $title" } } Book.metaClass.getService = {-> return "hello"} Book b = new Book() //This doesnt work either - b. metaClass.getService = {-> return "hello"} println b //prints null null assert 'hello' == b.serviceâ //passes ââââââââââââââââââââââââââââââââââââââââââââââââââââââââââââââââââââââââââââââââââââââââââââââââââââââââââââââââââââââââââââââââââââââââââââââââââââââââââââââââââââââââââââââââââââââââââââââââââââââââââââââââââââââââââââââââââââââââââââââââââââââââââââââââââââââââââââââââââââââââââââââââââââââââââââââââââââââââââââ âââââââââââââââââââââââââââââââââââââââââââââ
So apparently when property is referenced within class it doesn't use the getter provided by metaClass.
This is really inconsistent behavior - how can the property be different when accessed from within and from using the reference of the class.
I think the language should be consistent no matter what way the property is being accessed.