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

Null safe is call throws VerifyError when used as condition with CompileStatic

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Closed
    • Major
    • Resolution: Fixed
    • 2.4.4, 2.4.5
    • 2.4.6
    • Static compilation
    • None
    • OS X 10.10, JDK 1.8.0_60

    Description

      Here's an example:

      import groovy.transform.CompileStatic
      
      @CompileStatic
      class A {
          void ifCondition(Object x, Object y) {
              if (x?.is(y))
                  return
          }
      
          void ternaryCondition(Object x, Object y) {
                x?.is(y) ? 'foo' : 'bar'
          }
      }
      new A()
      

      The above code throws the following error:

      java.lang.VerifyError: (class: A, method: ternaryCondition signature (Ljava/lang/Object;Ljava/lang/Object;)V) Expecting to find object/array on stack
      

      This appears to be caused by the ?.is call expression being transformed to a CompareIdentityExpression, which is semantically different.

      Attachments

        Activity

          People

            melix Cédric Champeau
            shils Shil Sinha
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: