Repository: groovy
Updated Branches:
  refs/heads/master a3070da9a -> 3b5958538


Refine the node position of path expression


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

Branch: refs/heads/master
Commit: 3b595853853bb4935461a3deeccf5cf2ed67a0c7
Parents: a3070da
Author: sunlan <sun...@apache.org>
Authored: Sat Aug 5 20:54:56 2017 +0800
Committer: sunlan <sun...@apache.org>
Committed: Sat Aug 5 20:55:21 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/3b595853/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 c0f00c6..bafdfb6 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/3b595853/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/3b595853/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 e8f0a9b..b65505a 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
@@ -1914,9 +1914,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