Details
-
Bug
-
Status: Closed
-
Major
-
Resolution: Fixed
-
2.4.5
-
Any
Description
Documentation: http://docs.groovy-lang.org/latest/html/gapi/groovy/lang/Lazy.html
The documentations describes the usage of @Lazy like:
@Lazy T x
I'm aware of that T means no primitive data types, but groovy allows it and generates the code - so why not.
class Super { boolean aBoolean = true int aInt = 5 } class Testing extends Super { @Lazy boolean aBoolean = { false }() @Lazy int aInt = { 5 * 5 }() } println new Testing().isaBoolean() println new Testing().getaBoolean() println new Testing().getaInt() println new Testing().aBoolean println new Testing().aInt
Result:
true false 25 true 25
The behavior is inconsistent.
boolean: results are from the super class
int: results are from the child class
Please fix it or throw a 'RuntimeException' when primitive data types are used.
Update:
Please let @Lazy implement _is_Boolean() instead of _get_Boolean() when using primitive data type boolean and document it or just throw a 'RuntimeException'.
Attachments
Issue Links
- links to