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

ASF GitHub Bot commented on GROOVY-7870:
----------------------------------------

GitHub user shils opened a pull request:

    https://github.com/apache/groovy/pull/362

    GROOVY-7870: BinaryExpressionTransformer: Set line numbers on transfo…

    …rmed binary expressions

You can merge this pull request into a Git repository by running:

    $ git pull https://github.com/shils/groovy GROOVY-7870

Alternatively you can review and apply these changes as the patch at:

    https://github.com/apache/groovy/pull/362.patch

To close this pull request, make a commit to your master/trunk branch
with (at least) the following in the commit message:

    This closes #362
    
----
commit 388a6ca39a709e60c245baa5705efd82de305dd9
Author: Shil Sinha <sh...@apache.org>
Date:   2016-07-02T15:29:21Z

    GROOVY-7870: BinaryExpressionTransformer: Set line numbers on transformed 
binary expressions

----


> Implicit returns of transformed binary expressions do not have line numbers 
> when statically compiled
> ----------------------------------------------------------------------------------------------------
>
>                 Key: GROOVY-7870
>                 URL: https://issues.apache.org/jira/browse/GROOVY-7870
>             Project: Groovy
>          Issue Type: Bug
>          Components: Static compilation
>    Affects Versions: 2.4.7
>            Reporter: Shil Sinha
>
> If certain transformed binary expressions (<=>, ==, <<,  >>, >>>) are 
> implicitly returned, their line numbers are not reported. Example:
> {code}
> @groovy.transform.CompileStatic
> def test() {
>     def l = []
>     l << 3
> }
> {code}
> The code above is compiled to the following bytecode (as seen using 
> GroovyConsole):
> {code}
>   public test()Ljava/lang/Object;
>    L0
>     LINENUMBER 3 L0
>     ICONST_0
>     ANEWARRAY java/lang/Object
>     INVOKESTATIC org/codehaus/groovy/runtime/ScriptBytecodeAdapter.createList 
> ([Ljava/lang/Object;)Ljava/util/List;
>     ASTORE 1
>    L1
>     ALOAD 1
>     POP
>     ALOAD 1
>     ICONST_3
>     INVOKESTATIC java/lang/Integer.valueOf (I)Ljava/lang/Integer;
>     INVOKESTATIC org/codehaus/groovy/runtime/DefaultGroovyMethods.leftShift 
> (Ljava/util/List;Ljava/lang/Object;)Ljava/util/List;
>     ARETURN
>    L2
>     ACONST_NULL
>     ARETURN
>     LOCALVARIABLE this Lscript1466525199339; L0 L2 0
>     LOCALVARIABLE l Ljava/util/List; L1 L2 1
>     MAXSTACK = 2
>     MAXLOCALS = 2
> {code}
> There is no line number corresponding to L1, which includes the leftShift 
> call (should be line number 4.)
> This is occurs because 1) BinaryExpressionTransformer does not copy the 
> source position of the original expression to the transformed expression in 
> some cases, and 2) ReturnAdder set the source position of the generated 
> return for an expression statement with that of the expression.



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

Reply via email to