[ 
https://issues.apache.org/jira/browse/GROOVY-7610?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=14935202#comment-14935202
 ] 

Shil Sinha commented on GROOVY-7610:
------------------------------------

The problem is explicit in the bytecode:

{code}
 L0
    LINENUMBER 6 L0
    ALOAD 1
    ALOAD 2
    IF_ACMPNE L1
    ICONST_1
    GOTO L2
   L1
    ICONST_0
   L2
    DUP
    IFNONNULL L3
    POP
    ICONST_0
    GOTO L4
{code}

The IFNONNULL instruction expects a reference but sees an int. 

> Null safe is call throws VerifyError when used as condition with CompileStatic
> ------------------------------------------------------------------------------
>
>                 Key: GROOVY-7610
>                 URL: https://issues.apache.org/jira/browse/GROOVY-7610
>             Project: Groovy
>          Issue Type: Bug
>          Components: Static compilation
>    Affects Versions: 2.4.4, 2.4.5
>         Environment: OS X 10.10, JDK 1.8.0_60
>            Reporter: Shil Sinha
>            Assignee: Cédric Champeau
>
> Here's an example:
> {code}
> 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()
> {code}
> The above code throws the following error:
> {code}
> java.lang.VerifyError: (class: A, method: ternaryCondition signature 
> (Ljava/lang/Object;Ljava/lang/Object;)V) Expecting to find object/array on 
> stack
> {code}
> This appears to be caused by the ?.is call expression being transformed to a 
> CompareIdentityExpression, which is semantically different.



--
This message was sent by Atlassian JIRA
(v6.3.4#6332)

Reply via email to