groovy-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From sun...@apache.org
Subject [groovy] branch master updated: GROOVY-9136: set source position of object expression for error messages
Date Tue, 30 Jul 2019 09:02:30 GMT
This is an automated email from the ASF dual-hosted git repository.

sunlan pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/groovy.git


The following commit(s) were added to refs/heads/master by this push:
     new 7e496ed  GROOVY-9136: set source position of object expression for error messages
7e496ed is described below

commit 7e496edb4413c0fd6520e95eb6b8449fa0ecedd7
Author: Eric Milles <eric.milles@thomsonreuters.com>
AuthorDate: Sat Jul 20 11:44:16 2019 -0500

    GROOVY-9136: set source position of object expression for error messages
    
    Set only line and column to prevent overlap with property expression.
---
 .../sc/transformers/VariableExpressionTransformer.java         | 10 ++++++++--
 1 file changed, 8 insertions(+), 2 deletions(-)

diff --git a/src/main/java/org/codehaus/groovy/transform/sc/transformers/VariableExpressionTransformer.java
b/src/main/java/org/codehaus/groovy/transform/sc/transformers/VariableExpressionTransformer.java
index 6e490c1..84aeb72 100644
--- a/src/main/java/org/codehaus/groovy/transform/sc/transformers/VariableExpressionTransformer.java
+++ b/src/main/java/org/codehaus/groovy/transform/sc/transformers/VariableExpressionTransformer.java
@@ -50,18 +50,24 @@ public class VariableExpressionTransformer {
         // processClassVariable before it reaches any makeCall, that could handle it
         Object val = expr.getNodeMetaData(StaticTypesMarker.IMPLICIT_RECEIVER);
         if (val == null) return null;
+
         // TODO handle the owner and delegate cases better for nested scenarios and potentially
remove the need for the implicit this case
         VariableExpression receiver = new VariableExpression("owner".equals(val) ? (String)
val : "delegate".equals(val) ? (String) val : "this");
-        receiver.setSourcePosition(expr);
+        // GROOVY-9136 -- object expression should not overlap source range of property;
property stands in for original varibale expression
+        receiver.setLineNumber(expr.getLineNumber());
+        receiver.setColumnNumber(expr.getColumnNumber());
+
         PropertyExpression pexp = new PropertyExpression(receiver, expr.getName());
+        pexp.getProperty().setSourcePosition(expr);
         pexp.copyNodeMetaData(expr);
         pexp.setImplicitThis(true);
-        pexp.getProperty().setSourcePosition(expr);
+
         ClassNode owner = expr.getNodeMetaData(StaticCompilationMetadataKeys.PROPERTY_OWNER);
         if (owner != null) {
             receiver.putNodeMetaData(StaticTypesMarker.INFERRED_TYPE, owner);
             receiver.putNodeMetaData(StaticTypesMarker.IMPLICIT_RECEIVER, val);
         }
+
         return pexp;
     }
 


Mime
View raw message