groovy-notifications mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From danielsun1106 <...@git.apache.org>
Subject [GitHub] groovy pull request #792: GROOVY-8778: Cast short-hand breaks for empty map
Date Sat, 08 Sep 2018 00:28:45 GMT
Github user danielsun1106 commented on a diff in the pull request:

    https://github.com/apache/groovy/pull/792#discussion_r216113948
  
    --- Diff: subprojects/parser-antlr4/src/main/java/org/apache/groovy/parser/antlr4/AstBuilder.java
---
    @@ -2337,14 +2337,11 @@ public Expression visitPathElement(PathElementContext ctx) {
                         this.visitNamedPropertyArgs(ctx.namedPropertyArgs());
     
                 Expression right;
    -            if (mapEntryExpressionList.size() == 1) {
    -                MapEntryExpression mapEntryExpression = mapEntryExpressionList.get(0);
    -
    -                if (mapEntryExpression.getKeyExpression() instanceof SpreadMapExpression)
{
    -                    right = mapEntryExpression.getKeyExpression();
    -                } else {
    -                    right = mapEntryExpression;
    -                }
    +            if (mapEntryExpressionList.size() == 0) {
    +                // expecting list of MapEntryExpressions later so use SpreadMap to smuggle
empty MapExpression to later stages
    +                right = new SpreadMapExpression(configureAST(new MapExpression(), ctx.namedPropertyArgs()));
    --- End diff --
    
    It's better to `configureAST` the instance of `SpreadMapExpression` too, or its node position
will be missing.


---

Mime
View raw message