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

Static compilation of calling increment operator on Integer fails

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Closed
    • Critical
    • Resolution: Fixed
    • 2.0.1
    • 2.0.2
    • Static compilation
    • None

    Description

      in short: calling the ++ operator on an Integer does not increment the value when using static compilation.

      Example:

      class IntegerIncrementStaticCompilationBug {
      
          Integer index = 0
      
          @groovy.transform.CompileStatic
          void increment() {
      	index++
          }
      }
      
      def b = new IntegerIncrementStaticCompilationBug()
      b.increment(); b.increment(); b.increment()
      
      println b.index
      

      This script should print "3", but it prints "0".
      Works find when CompileStatic annotation is removed.

      Attachments

        Activity

          People

            melix Cédric Champeau
            peterd Peter Doornbosch
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: