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

CompileStatic: long loses type when bitwise OR applied to it

    XMLWordPrintableJSON

    Details

    • Type: Bug
    • Status: Closed
    • Priority: Major
    • Resolution: Fixed
    • Affects Version/s: 2.1.0-rc-1
    • Fix Version/s: 2.1.0-rc-3, 2.0.7
    • Component/s: Static compilation
    • Labels:
      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

            • Assignee:
              melix C├ędric Champeau
              Reporter:
              tim_yates Tim Yates
            • Votes:
              0 Vote for this issue
              Watchers:
              2 Start watching this issue

              Dates

              • Created:
                Updated:
                Resolved: