eric-milles commented on code in PR #3054:
URL: https://github.com/apache/groovy/pull/3054#discussion_r4425456242


##########
src/main/java/org/apache/groovy/parser/antlr4/AstBuilder.java:
##########
@@ -2485,10 +2495,30 @@ public DeclarationExpression 
visitVariableDeclarator(final VariableDeclaratorCon
                                 ),
                                 ctx.variableDeclaratorId()),
                         token,
-                        
this.visitVariableInitializer(ctx.variableInitializer())),
+                        init),
                 ctx);
     }
 
+    private void checkArrayInitEdgeCase(final Expression expr) {
+        if (expr instanceof ArrayExpression array && array.hasInitializer()) {
+            ClassNode elementType = array.getElementType();
+
+            ClassNode baseType = elementType;
+            while (baseType.isArray()) baseType = baseType.getComponentType();
+            if (isPrimitiveType(baseType)) {
+                return; // closure coerced to boolean or integer is not likely
+            }
+
+            if (!elementType.isArray()) {
+                if (array.getExpressions().size() == 1 && 
!(array.getExpression(0) instanceof ClosureExpression)) {

Review Comment:
   The type is not resolved here.  Only primitive types get resolved by name.  
Restriction to closure or SAM types is not possible.



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to