groovy-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From emil...@apache.org
Subject [groovy] branch master updated: minor edits
Date Mon, 23 Dec 2019 19:35:13 GMT
This is an automated email from the ASF dual-hosted git repository.

emilles pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/groovy.git


The following commit(s) were added to refs/heads/master by this push:
     new 4eb3529  minor edits
4eb3529 is described below

commit 4eb3529256ab510f5d741fd50eba9412a3b73cc7
Author: Eric Milles <eric.milles@thomsonreuters.com>
AuthorDate: Mon Dec 23 13:32:22 2019 -0600

    minor edits
---
 .../transform/sc/StaticCompilationVisitor.java     | 26 +++++++++-------------
 .../transform/stc/StaticTypeCheckingVisitor.java   | 13 +++++------
 2 files changed, 16 insertions(+), 23 deletions(-)

diff --git a/src/main/java/org/codehaus/groovy/transform/sc/StaticCompilationVisitor.java
b/src/main/java/org/codehaus/groovy/transform/sc/StaticCompilationVisitor.java
index 3dec6b8..7a08905 100644
--- a/src/main/java/org/codehaus/groovy/transform/sc/StaticCompilationVisitor.java
+++ b/src/main/java/org/codehaus/groovy/transform/sc/StaticCompilationVisitor.java
@@ -175,15 +175,14 @@ public class StaticCompilationVisitor extends StaticTypeCheckingVisitor
{
 
         ClassNode previousClassNode = classNode; classNode = node;
 
-        for (Iterator<InnerClassNode> innerClasses = classNode.getInnerClasses(); innerClasses.hasNext();
) {
-            InnerClassNode innerClassNode = innerClasses.next();
+        classNode.getInnerClasses().forEachRemaining(innerClassNode -> {
             boolean innerStaticCompile = !(skip || isSkippedInnerClass(innerClassNode));
             innerClassNode.putNodeMetaData(STATIC_COMPILE_NODE, Boolean.valueOf(innerStaticCompile));
             innerClassNode.putNodeMetaData(WriterControllerFactory.class, node.getNodeMetaData(WriterControllerFactory.class));
             if (innerStaticCompile && !anyMethodSkip(innerClassNode)) {
                 innerClassNode.putNodeMetaData(MopWriter.Factory.class, StaticCompilationMopWriter.FACTORY);
             }
-        }
+        });
         super.visitClass(node);
         addPrivateFieldAndMethodAccessors(node);
         if (isStaticallyCompiled(node)) {
@@ -414,19 +413,16 @@ public class StaticCompilationVisitor extends StaticTypeCheckingVisitor
{
         MethodNode target = call.getNodeMetaData(DIRECT_METHOD_CALL_TARGET);
         if (target == null && call.getLineNumber() > 0) {
             addError("Target constructor for constructor call expression hasn't been set",
call);
-        } else {
-            if (target==null) {
-                // try to find a target
-                ArgumentListExpression argumentListExpression = InvocationWriter.makeArgumentList(call.getArguments());
-                List<Expression> expressions = argumentListExpression.getExpressions();
-                ClassNode[] args = new ClassNode[expressions.size()];
-                for (int i = 0, n = args.length; i < n; i += 1) {
-                    args[i] = typeChooser.resolveType(expressions.get(i), classNode);
-                }
-                MethodNode constructor = findMethodOrFail(call, call.isSuperCall() ? classNode.getSuperClass()
: classNode, "<init>", args);
-                call.putNodeMetaData(DIRECT_METHOD_CALL_TARGET, constructor);
-                target = constructor;
+        } else if (target == null) {
+            // try to find a target
+            ArgumentListExpression argumentListExpression = InvocationWriter.makeArgumentList(call.getArguments());
+            List<Expression> expressions = argumentListExpression.getExpressions();
+            ClassNode[] args = new ClassNode[expressions.size()];
+            for (int i = 0, n = args.length; i < n; i += 1) {
+                args[i] = typeChooser.resolveType(expressions.get(i), classNode);
             }
+            target = findMethodOrFail(call, call.isSuperCall() ? classNode.getSuperClass()
: classNode, "<init>", args);
+            call.putNodeMetaData(DIRECT_METHOD_CALL_TARGET, target);
         }
         if (target != null) {
             memorizeInitialExpressions(target);
diff --git a/src/main/java/org/codehaus/groovy/transform/stc/StaticTypeCheckingVisitor.java
b/src/main/java/org/codehaus/groovy/transform/stc/StaticTypeCheckingVisitor.java
index 30c389b..2bacc9d 100644
--- a/src/main/java/org/codehaus/groovy/transform/stc/StaticTypeCheckingVisitor.java
+++ b/src/main/java/org/codehaus/groovy/transform/stc/StaticTypeCheckingVisitor.java
@@ -2215,14 +2215,11 @@ public class StaticTypeCheckingVisitor extends ClassCodeVisitorSupport
{
         extension.afterMethodCall(call);
     }
 
-    private boolean looksLikeNamedArgConstructor(final ClassNode receiver, final ClassNode[]
args) {
-        return (args.length == 1 || args.length == 2 && isInnerConstructor(receiver,
args[0]))
-                && implementsInterfaceOrIsSubclassOf(args[args.length - 1], MAP_TYPE);
-    }
-
-    private boolean isInnerConstructor(final ClassNode receiver, final ClassNode parent)
{
-        return receiver.isRedirectNode() && receiver.redirect() instanceof InnerClassNode
&&
-                receiver.redirect().getOuterClass().equals(parent);
+    private boolean looksLikeNamedArgConstructor(final ClassNode receiver, final ClassNode[]
argumentTypes) {
+        if (argumentTypes.length == 1 || argumentTypes.length == 2 && argumentTypes[0].equals(receiver.getOuterClass()))
{
+            return argumentTypes[argumentTypes.length - 1].implementsInterface(MAP_TYPE);
+        }
+        return false;
     }
 
     protected MethodNode typeCheckMapConstructor(final ConstructorCallExpression call, final
ClassNode receiver, final Expression arguments) {


Mime
View raw message