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

+= in CompileStatic dynamically sets property instead of using setter

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Closed
    • Minor
    • Resolution: Fixed
    • 2.5.1
    • 4.0.0-alpha-1, 3.0.1, 2.5.16
    • None
    • None

    Description

      Code:

      import groovy.transform.CompileStatic
      
      @CompileStatic
      class A {
        int num
      
        static main(args) {
          def a = new A()
          a.num = 5
          a.num += 10
        }
      }
      

      Main method compiles to:

      A a = new A();
      byte var2 = 5;
      a.setNum(var2);
      Object var10001 = null;
      ScriptBytecodeAdapter.setProperty(a.getNum() + 10, (Class)null, a, (String)"num");
      

      Attachments

        Issue Links

          Activity

            People

              emilles Eric Milles
              deathlord death lord
              Votes:
              0 Vote for this issue
              Watchers:
              3 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved:

                Time Tracking

                  Estimated:
                  Original Estimate - Not Specified
                  Not Specified
                  Remaining:
                  Remaining Estimate - 0h
                  0h
                  Logged:
                  Time Spent - 0.5h
                  0.5h