You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@groovy.apache.org by jwagenleitner <gi...@git.apache.org> on 2017/07/08 17:39:17 UTC

[GitHub] groovy pull request #559: GROOVY-8222: Setting Source Position in newly crea...

Github user jwagenleitner commented on a diff in the pull request:

    https://github.com/apache/groovy/pull/559#discussion_r126286728
  
    --- Diff: src/main/org/codehaus/groovy/classgen/AsmClassGenerator.java ---
    @@ -1251,11 +1251,13 @@ private void processClassVariable(String name) {
                 mv.visitInsn(DUP);
     
                 loadThisOrOwner();
    -            mv.visitLdcInsn(name);
    +            mv.visitLdcInsn(expression.getName());
     
                 mv.visitMethodInsn(INVOKESPECIAL, "org/codehaus/groovy/runtime/ScriptReference", "<init>", "(Lgroovy/lang/Script;Ljava/lang/String;)V", false);
             } else {
    -            PropertyExpression pexp = new PropertyExpression(new VariableExpression("this"), name);
    +            PropertyExpression pexp = new PropertyExpression(new VariableExpression("this"), expression.getName());
    --- End diff --
    
    The patch provided in the JIRA creates a new `VariableExpression` (see below), I think that needs to be done so the source position is not set on the constant `VariableExpress.THIS_EXPRESSION` via the `getObjectExpression().setSourcePosition(..)` call.
    
    ```java
    PropertyExpression pexp = new PropertyExpression(new VariableExpression("this", ClassHelper.DYNAMIC_TYPE), name);
    ```


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastructure@apache.org or file a JIRA ticket
with INFRA.
---