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

CompileStatic: cannot implicitly call double setter with BigDecimal literal

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Closed
    • Minor
    • Resolution: Fixed
    • 3.0.17
    • 3.0.20
    • Compiler
    • None

    Description

      When a class declares a double property and setter for it:

      class DoubleWithSetter {
          protected double myDouble
      
          void setMyDouble(double val) {
             this.myDouble = val
          }
      } 

      A statically-compiled subclass cannot "assign" a BigDecimal literal to that property:

      import groovy.transform.CompileStatic
      
      @CompileStatic
      class BigDecimalImplicitDoubleSetter extends DoubleWithSetter {
          void doStuff() {
             double doubleVar = 0.0 // works
             myDouble = doubleVar   // works
             myDouble = 0.0         // [Static type checking] - Cannot assign value of type java.math.BigDecimal to variable of type double
          }
      } 

      Attachments

        Activity

          People

            emilles Eric Milles
            jasongarrett Jason Garrett
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: