Repository: groovy
Updated Branches:
  refs/heads/GROOVY_2_6_X edd461375 -> a6e5328f8


Refine the node position of path expression

(cherry picked from commit 3b59585)


Project: http://git-wip-us.apache.org/repos/asf/groovy/repo
Commit: http://git-wip-us.apache.org/repos/asf/groovy/commit/a6e5328f
Tree: http://git-wip-us.apache.org/repos/asf/groovy/tree/a6e5328f
Diff: http://git-wip-us.apache.org/repos/asf/groovy/diff/a6e5328f

Branch: refs/heads/GROOVY_2_6_X
Commit: a6e5328f81c1580f943f7799f3f61635ffa34faf
Parents: edd4613
Author: sunlan <sun...@apache.org>
Authored: Sat Aug 5 20:54:56 2017 +0800
Committer: sunlan <sun...@apache.org>
Committed: Sat Aug 5 20:58:03 2017 +0800

----------------------------------------------------------------------
 .../groovy/control/CompilerConfiguration.java   |  4 ++++
 .../transform/stc/DelegatesToSTCTest.groovy     | 23 ++++++++++++++++++--
 .../apache/groovy/parser/antlr4/AstBuilder.java |  6 ++---
 3 files changed, 28 insertions(+), 5 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/groovy/blob/a6e5328f/src/main/org/codehaus/groovy/control/CompilerConfiguration.java
----------------------------------------------------------------------
diff --git a/src/main/org/codehaus/groovy/control/CompilerConfiguration.java 
b/src/main/org/codehaus/groovy/control/CompilerConfiguration.java
index 17ac7cf..8a0d26f 100644
--- a/src/main/org/codehaus/groovy/control/CompilerConfiguration.java
+++ b/src/main/org/codehaus/groovy/control/CompilerConfiguration.java
@@ -905,4 +905,8 @@ public class CompilerConfiguration {
     public void setBytecodePostprocessor(final BytecodeProcessor 
bytecodePostprocessor) {
         this.bytecodePostprocessor = bytecodePostprocessor;
     }
+
+    public boolean isAntlr2Parser() {
+        return antlr2Parser;
+    }
 }

http://git-wip-us.apache.org/repos/asf/groovy/blob/a6e5328f/src/test/groovy/transform/stc/DelegatesToSTCTest.groovy
----------------------------------------------------------------------
diff --git a/src/test/groovy/transform/stc/DelegatesToSTCTest.groovy 
b/src/test/groovy/transform/stc/DelegatesToSTCTest.groovy
index d58ae9b..9f8dd3f 100644
--- a/src/test/groovy/transform/stc/DelegatesToSTCTest.groovy
+++ b/src/test/groovy/transform/stc/DelegatesToSTCTest.groovy
@@ -609,7 +609,9 @@ class DelegatesToSTCTest extends StaticTypeCheckingTestCase 
{
 
     // GROOVY-6165
     void testDelegatesToGenericArgumentTypeAndTypo() {
-        shouldFailWithMessages '''import groovy.transform.*
+        boolean isAntlr2Parser = config.isAntlr2Parser()
+
+        String code = '''import groovy.transform.*
 
         @TupleConstructor
         class Person { String name }
@@ -631,7 +633,24 @@ class DelegatesToSTCTest extends 
StaticTypeCheckingTestCase {
         }
 
         test([new Person('Guillaume'), new Person('Cedric')])
-        ''', 'Cannot find matching method'
+        '''
+
+        String msg = 'Cannot find matching method'
+
+        if (isAntlr2Parser) {
+            shouldFailWithMessages code, msg
+        } else {
+            /*
+             * Because the Parrot parser provides more accurate node position 
information,
+             * 
org.codehaus.groovy.transform.stc.StaticTypeCheckingVisitor.addError will not 
be interfered by wrong node position.
+             *
+             * 1) TestScripttestDelegatesToGenericArgumentTypeAndTypo0.groovy: 
17: [Static type checking] - Cannot find matching method 
TestScripttestDelegatesToGenericArgumentTypeAndTypo0#getname(). Please check if 
the declared type is right and if the method exists.
+             * 2) TestScripttestDelegatesToGenericArgumentTypeAndTypo0.groovy: 
17: [Static type checking] - Cannot find matching method 
java.lang.Object#toUpperCase(). Please check if the declared type is right and 
if the method exists.
+             *
+             */
+            shouldFailWithMessages code, msg, msg
+        }
+
     }
 
     // GROOVY-6323, GROOVY-6325, GROOVY-6332

http://git-wip-us.apache.org/repos/asf/groovy/blob/a6e5328f/subprojects/parser-antlr4/src/main/java/org/apache/groovy/parser/antlr4/AstBuilder.java
----------------------------------------------------------------------
diff --git 
a/subprojects/parser-antlr4/src/main/java/org/apache/groovy/parser/antlr4/AstBuilder.java
 
b/subprojects/parser-antlr4/src/main/java/org/apache/groovy/parser/antlr4/AstBuilder.java
index 4d82c18..5dd8118 100644
--- 
a/subprojects/parser-antlr4/src/main/java/org/apache/groovy/parser/antlr4/AstBuilder.java
+++ 
b/subprojects/parser-antlr4/src/main/java/org/apache/groovy/parser/antlr4/AstBuilder.java
@@ -1937,9 +1937,9 @@ public class AstBuilder extends 
GroovyParserBaseVisitor<Object> implements Groov
 
     @Override
     public Expression visitPathExpression(PathExpressionContext ctx) {
-        return this.configureAST(
-                this.createPathExpression((Expression) 
this.visit(ctx.primary()), ctx.pathElement()),
-                ctx);
+        return //this.configureAST(
+                this.createPathExpression((Expression) 
this.visit(ctx.primary()), ctx.pathElement());
+                //ctx);
     }
 
     @Override

Reply via email to