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

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

    Details

    • Type: Bug
    • Status: Closed
    • Priority: Major
    • Resolution: Fixed
    • Affects Version/s: 2.4.4, 2.4.5
    • Fix Version/s: 2.4.6
    • Component/s: Static compilation
    • Labels:
      None
    • Environment:
      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

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

              Dates

              • Created:
                Updated:
                Resolved: