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

CompileStatic: long loses type when bitwise OR applied to it

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Closed
    • Major
    • Resolution: Fixed
    • 2.1.0-rc-1
    • 2.1.0-rc-3, 2.0.7
    • Static compilation
    • None

    Description

      This code:

      @groovy.transform.CompileStatic
      class Test {
        long[] data
        long topMask
          
        void doSomething() {
          long mask = 0
          mask = mask | 0x1L
          data[ 0 ] = data[ 0 ] | mask
        }
      }
      
      new Test()
      

      Gives the error:

      [Static type checking] - Cannot assign value of type java.lang.Number to variable of type long
      

      A workaround is to add a cast:

          data[ 0 ] = data[ 0 ] | (long)mask
      

      But I think that might cause GROOVY-5921 to rear its head again...

      Investigating

      Attachments

        Activity

          People

            melix Cédric Champeau
            tim_yates Tim Yates
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: