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:14 GMT
Repository: groovy
Updated Branches:
  refs/heads/master e80f794c8 -> 40269f772


Validate expression list stricter

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


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

Branch: refs/heads/master
Commit: 40269f772e781b577ba5c60cd8180df5aa3bd506
Parents: e80f794
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:09 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/40269f77/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 c1bee5c..47863f0 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
@@ -3496,7 +3496,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