Uploaded image for project: 'Groovy'
  1. Groovy
  2. GROOVY-7940

Inconsistent handling of undocumented primitive data types at the @Lazy annotation under use of extends

    XMLWordPrintableJSON

    Details

      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

            Activity

              People

              • Assignee:
                jwagenleitner John Wagenleitner
                Reporter:
                MaikIgloffstein Maik Igloffstein
              • Votes:
                0 Vote for this issue
                Watchers:
                4 Start watching this issue

                Dates

                • Created:
                  Updated:
                  Resolved: