groovy-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From sun...@apache.org
Subject groovy git commit: Validate expression list stricter
Date Thu, 05 Jul 2018 02:43:43 GMT
Repository: groovy
Updated Branches:
  refs/heads/GROOVY_2_6_X 0fc6bb0d6 -> 209fe3f98


Validate expression list stricter

code like `foo(String a)` can be parsed as command expression in the parentheses, we should
resolve the ambiguity strictly.

(cherry picked from commit 40269f7)


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

Branch: refs/heads/GROOVY_2_6_X
Commit: 209fe3f985f30b5e54ab55e880a8db0c932b471e
Parents: 0fc6bb0
Author: sunlan <sunlan@apache.org>
Authored: Thu Jul 5 10:42:52 2018 +0800
Committer: sunlan <sunlan@apache.org>
Committed: Thu Jul 5 10:43:38 2018 +0800

----------------------------------------------------------------------
 .../src/main/java/org/apache/groovy/parser/antlr4/AstBuilder.java  | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/groovy/blob/209fe3f9/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 d7aa09d..9ffa660 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
@@ -3539,7 +3539,7 @@ public class AstBuilder extends GroovyParserBaseVisitor<Object>
implements Groov
         // statements like `foo(String a)` is invalid
         MethodCallExpression methodCallExpression = (MethodCallExpression) expression;
         String methodName = methodCallExpression.getMethodAsString();
-        if (Character.isUpperCase(methodName.codePointAt(0)) || PRIMITIVE_TYPE_SET.contains(methodName))
{
+        if (methodCallExpression.isImplicitThis() && Character.isUpperCase(methodName.codePointAt(0))
|| PRIMITIVE_TYPE_SET.contains(methodName)) {
             throw createParsingFailedException("Invalid method declaration", ctx);
         }
     }


Mime
View raw message