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

++ or -- doesn't respect final modifier

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Closed
    • Major
    • Resolution: Fixed
    • 1.8.8, 2.0.6, 2.1.1
    • 2.5.0-alpha-1
    • Compiler
    • None

    Description

      Groovy respects final modifier for fields and method parameters, but using ++ or -- is still allowed:

      class A {
          final foo = 42
          def incrementField() { ++foo }
          def incrementParam(final a) { ++a }
      }
      
      def a = new A()
      assert a.incrementField() == 43
      assert a.incrementParam(1) == 2
      

      However, a.foo++ throws ReadOnlyPropertyException.

      Attachments

        Activity

          People

            Unassigned Unassigned
            dsrkoc Dinko Srkoc
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: