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

STC regression using increment/decrement operators on custom bean accessors in Groovy 3.0.0

    XMLWordPrintableJSON

    Details

      Description

      The following code works in Groovy 2.5.8 but fails compilation in 3.0.0:

      @groovy.transform.CompileStatic
      class MyProp {
          Integer myInt = 0
          Integer getMyInt() { return myInt }    // Custom getter
          void setMyInt(Integer i) { myInt = i } // Custom setter
      }
      
      @groovy.transform.CompileStatic
      class BugInGroovy300 {
          static void main() {
              new MyProp().myInt++ // This line cannot compile in Groovy 3.0.0
          }
      }
      

      The error is:

      [Static type checking] - Cannot find matching method java.lang.Object#next(). Please check if the declared type is correct and if the method exists.
       @ line 13, column 21.
                 new MyProp().myInt++ // This line cannot compile in Groovy 3.0.0

      If using the decrement operator (--), the type checker looks for a "#previous()" method instead.

      The code works in 3.0.0 if using CompileDynamic instead. Relying on the generated accessor methods by Groovy also works.

       

        Attachments

          Issue Links

            Activity

              People

              • Assignee:
                emilles Eric Milles
                Reporter:
                bjornvester Bjørn Mølgård Vester
              • Votes:
                0 Vote for this issue
                Watchers:
                2 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