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

@Memoized ignored in trait methods

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Closed
    • Major
    • Resolution: Fixed
    • 2.4.0
    • 4.0.0-alpha-3
    • groovy-runtime
    • None

    Description

      import groovy.transform.Memoized
      
      trait Mem{
          @Memoized
          long traitLongComputation(int seed) {
              System.nanoTime()
          }
      }
      
      class CMem{
          @Memoized
          long classLongComputation(int seed) {
              System.nanoTime()
          }   
      }
      
      def m = new CMem() as Mem
      
      assert m.classLongComputation(1) == m.classLongComputation(1)
      assert m.traitLongComputation(1) == m.traitLongComputation(1)
      
      Assertion failed: 
      
      assert m.traitLongComputation(1) == m.traitLongComputation(1)
             | |                       |  | |
             | 277756345937226         |  | 277756346056532
             CMem9_groovyProxy@3ef440d5|  CMem9_groovyProxy@3ef440d5
                                       false
      

      Attachments

        Activity

          People

            emilles Eric Milles
            hubbitus Pavel Alexeev
            Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: