You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@groovy.apache.org by su...@apache.org on 2017/02/08 04:12:25 UTC

[01/11] groovy git commit: GROOVY-8026: Matcher indexed via IntRange with startIdx..-1 does not return "intermediate" range matches (closes #483)

Repository: groovy
Updated Branches:
  refs/heads/parrot a9c704665 -> d21ddc7ab


GROOVY-8026: Matcher indexed via IntRange with startIdx..-1 does not return "intermediate" range matches (closes #483)


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

Branch: refs/heads/parrot
Commit: 598b93e04767c0511860758531bff56975e49e53
Parents: 84462bb
Author: paulk <pa...@asert.com.au>
Authored: Fri Jan 27 16:58:50 2017 +1000
Committer: paulk <pa...@asert.com.au>
Committed: Mon Jan 30 22:56:39 2017 +1000

----------------------------------------------------------------------
 .../groovy/runtime/StringGroovyMethods.java     |  5 +++
 src/test/groovy/bugs/Groovy8026Bug.groovy       | 35 ++++++++++++++++++++
 2 files changed, 40 insertions(+)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/groovy/blob/598b93e0/src/main/org/codehaus/groovy/runtime/StringGroovyMethods.java
----------------------------------------------------------------------
diff --git a/src/main/org/codehaus/groovy/runtime/StringGroovyMethods.java b/src/main/org/codehaus/groovy/runtime/StringGroovyMethods.java
index 2d41ac3..2fded6f 100644
--- a/src/main/org/codehaus/groovy/runtime/StringGroovyMethods.java
+++ b/src/main/org/codehaus/groovy/runtime/StringGroovyMethods.java
@@ -1348,6 +1348,11 @@ public class StringGroovyMethods extends DefaultGroovyMethodsSupport {
      */
     public static List getAt(Matcher self, Collection indices) {
         List result = new ArrayList();
+        if (indices instanceof IntRange) {
+            int size = (int) size(self);
+            RangeInfo info = subListBorders(size, (Range) indices);
+            indices = new IntRange(((IntRange)indices).getInclusive(), info.from, info.to - 1);
+        }
         for (Object value : indices) {
             if (value instanceof Range) {
                 result.addAll(getAt(self, (Range) value));

http://git-wip-us.apache.org/repos/asf/groovy/blob/598b93e0/src/test/groovy/bugs/Groovy8026Bug.groovy
----------------------------------------------------------------------
diff --git a/src/test/groovy/bugs/Groovy8026Bug.groovy b/src/test/groovy/bugs/Groovy8026Bug.groovy
new file mode 100644
index 0000000..8483ee0
--- /dev/null
+++ b/src/test/groovy/bugs/Groovy8026Bug.groovy
@@ -0,0 +1,35 @@
+/*
+ *  Licensed to the Apache Software Foundation (ASF) under one
+ *  or more contributor license agreements.  See the NOTICE file
+ *  distributed with this work for additional information
+ *  regarding copyright ownership.  The ASF licenses this file
+ *  to you under the Apache License, Version 2.0 (the
+ *  "License"); you may not use this file except in compliance
+ *  with the License.  You may obtain a copy of the License at
+ *
+ *    http://www.apache.org/licenses/LICENSE-2.0
+ *
+ *  Unless required by applicable law or agreed to in writing,
+ *  software distributed under the License is distributed on an
+ *  "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ *  KIND, either express or implied.  See the License for the
+ *  specific language governing permissions and limitations
+ *  under the License.
+ */
+package groovy.bugs
+
+class Groovy8026Bug extends GroovyTestCase {
+    void testJavaBeanPropertiesAvailableInInnerClasses() {
+        assertScript '''
+            def mm = '1 2 3 4 5 6 7 8 9' =~ /\\d/
+            assert mm.collect { it }.toString() == '[1, 2, 3, 4, 5, 6, 7, 8, 9]'
+            assert mm[ 0..8 ].toString() == '[1, 2, 3, 4, 5, 6, 7, 8, 9]'
+            assert mm[ 0..mm.size()-1 ].toString() == '[1, 2, 3, 4, 5, 6, 7, 8, 9]'
+            assert mm[ 0..<mm.size() ].toString() == '[1, 2, 3, 4, 5, 6, 7, 8, 9]'
+            assert mm[-1] == '9'
+            assert mm[ 0..-1 ].toString() == '[1, 2, 3, 4, 5, 6, 7, 8, 9]'
+            assert mm[ (0..-1).toList() ].toString() == '[1, 9]'
+            assert mm[ (0..-1).iterator().toList() ].toString() == '[1, 9]'
+        '''
+    }
+}


[02/11] groovy git commit: trivial refactor

Posted by su...@apache.org.
trivial refactor


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

Branch: refs/heads/parrot
Commit: 6ba1cdc41f5b9911567a335d46553a94d1c14ab9
Parents: 598b93e
Author: paulk <pa...@asert.com.au>
Authored: Mon Jan 30 23:52:22 2017 +1000
Committer: paulk <pa...@asert.com.au>
Committed: Mon Jan 30 23:52:22 2017 +1000

----------------------------------------------------------------------
 gradle/pomconfigurer.gradle                     |  3 ++
 .../groovy/classgen/AnnotationVisitor.java      | 31 ++++++++++++++------
 2 files changed, 25 insertions(+), 9 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/groovy/blob/6ba1cdc4/gradle/pomconfigurer.gradle
----------------------------------------------------------------------
diff --git a/gradle/pomconfigurer.gradle b/gradle/pomconfigurer.gradle
index 2877e8a..3f3f291 100644
--- a/gradle/pomconfigurer.gradle
+++ b/gradle/pomconfigurer.gradle
@@ -579,6 +579,9 @@ project.ext.pomConfigureClosureWithoutTweaks = {
             contributor {
                 name 'Alan Green'
             }
+            contributor {
+                name 'Alex Popescu'
+            }
         }
         mailingLists {
             mailingList {

http://git-wip-us.apache.org/repos/asf/groovy/blob/6ba1cdc4/src/main/org/codehaus/groovy/classgen/AnnotationVisitor.java
----------------------------------------------------------------------
diff --git a/src/main/org/codehaus/groovy/classgen/AnnotationVisitor.java b/src/main/org/codehaus/groovy/classgen/AnnotationVisitor.java
index d0a7baf..63296cb 100644
--- a/src/main/org/codehaus/groovy/classgen/AnnotationVisitor.java
+++ b/src/main/org/codehaus/groovy/classgen/AnnotationVisitor.java
@@ -18,13 +18,26 @@
  */
 package org.codehaus.groovy.classgen;
 
-import java.util.*;
 import java.lang.reflect.Field;
 import java.lang.reflect.Modifier;
+import java.util.List;
+import java.util.Map;
 
-import org.codehaus.groovy.ast.*;
+import org.codehaus.groovy.ast.ASTNode;
+import org.codehaus.groovy.ast.AnnotationNode;
+import org.codehaus.groovy.ast.ClassHelper;
+import org.codehaus.groovy.ast.ClassNode;
+import org.codehaus.groovy.ast.FieldNode;
+import org.codehaus.groovy.ast.MethodNode;
+import org.codehaus.groovy.ast.expr.AnnotationConstantExpression;
+import org.codehaus.groovy.ast.expr.ClassExpression;
+import org.codehaus.groovy.ast.expr.ClosureExpression;
+import org.codehaus.groovy.ast.expr.ConstantExpression;
+import org.codehaus.groovy.ast.expr.Expression;
+import org.codehaus.groovy.ast.expr.ListExpression;
+import org.codehaus.groovy.ast.expr.PropertyExpression;
+import org.codehaus.groovy.ast.expr.VariableExpression;
 import org.codehaus.groovy.ast.stmt.ReturnStatement;
-import org.codehaus.groovy.ast.expr.*;
 import org.codehaus.groovy.control.ErrorCollector;
 import org.codehaus.groovy.control.SourceUnit;
 import org.codehaus.groovy.control.messages.SyntaxErrorMessage;
@@ -32,12 +45,12 @@ import org.codehaus.groovy.syntax.SyntaxException;
 import org.codehaus.groovy.vmplugin.VMPluginFactory;
 
 /**
- * An Annotation visitor responsible with:
- * - reading annotation metadata (@Retention, @Target, attribute types)
- * - verify that an <code>AnnotationNode</code> conforms to annotation meta
- * - enhancing an <code>AnnotationNode</code> AST to reflect real annotation meta
- *
- * @author <a href='mailto:the[dot]mindstorm[at]gmail[dot]com'>Alex Popescu</a>
+ * An Annotation visitor responsible for:
+ * <ul>
+ * <li>reading annotation metadata (@Retention, @Target, attribute types)</li>
+ * <li>verify that an <code>AnnotationNode</code> conforms to annotation meta</li>
+ * <li>enhancing an <code>AnnotationNode</code> AST to reflect real annotation meta</li>
+ * </ul>
  */
 public class AnnotationVisitor {
     private final SourceUnit source;


[06/11] groovy git commit: trivial refactor

Posted by su...@apache.org.
trivial refactor


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

Branch: refs/heads/parrot
Commit: 15a8c67aa133ab85a5c11cf0ed0e1f267f1c9d6e
Parents: c219797
Author: paulk <pa...@asert.com.au>
Authored: Wed Feb 1 17:48:50 2017 +1000
Committer: paulk <pa...@asert.com.au>
Committed: Wed Feb 1 17:48:50 2017 +1000

----------------------------------------------------------------------
 .../groovy/classgen/asm/sc/StaticTypesCallSiteWriter.java    | 8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/groovy/blob/15a8c67a/src/main/org/codehaus/groovy/classgen/asm/sc/StaticTypesCallSiteWriter.java
----------------------------------------------------------------------
diff --git a/src/main/org/codehaus/groovy/classgen/asm/sc/StaticTypesCallSiteWriter.java b/src/main/org/codehaus/groovy/classgen/asm/sc/StaticTypesCallSiteWriter.java
index c34be18..fe69531 100644
--- a/src/main/org/codehaus/groovy/classgen/asm/sc/StaticTypesCallSiteWriter.java
+++ b/src/main/org/codehaus/groovy/classgen/asm/sc/StaticTypesCallSiteWriter.java
@@ -636,10 +636,10 @@ public class StaticTypesCallSiteWriter extends CallSiteWriter implements Opcodes
         }
         // todo: more cases
         throw new GroovyBugError(
-                "At line "+receiver.getLineNumber() + " column " + receiver.getColumnNumber() + "\n" +
-                "On receiver: "+receiver.getText() + " with message: "+message+" and arguments: "+arguments.getText()+"\n"+
-                "This method should not have been called. Please try to create a simple example reproducing this error and file" +
-                "a bug report at https://issues.apache.org/jira/browse/GROOVY");
+                "At line " + receiver.getLineNumber() + " column " + receiver.getColumnNumber() + "\n" +
+                "On receiver: " + receiver.getText() + " with message: " + message + " and arguments: " + arguments.getText() + "\n" +
+                "This method should not have been called. Please try to create a simple example reproducing\n" +
+                "this error and file a bug report at https://issues.apache.org/jira/browse/GROOVY");
     }
 
     private boolean trySubscript(final Expression receiver, final String message, final Expression arguments, ClassNode rType, final ClassNode aType) {


[05/11] groovy git commit: minor refactor

Posted by su...@apache.org.
minor refactor


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

Branch: refs/heads/parrot
Commit: c219797c8f4e2021e05ed70adb8a562140ab1dd2
Parents: d4edf9c
Author: paulk <pa...@asert.com.au>
Authored: Wed Feb 1 14:17:53 2017 +1000
Committer: paulk <pa...@asert.com.au>
Committed: Wed Feb 1 14:18:20 2017 +1000

----------------------------------------------------------------------
 .../codehaus/groovy/ast/tools/GeneralUtils.java |   4 +
 .../stc/StaticTypeCheckingVisitor.java          | 128 ++++++++-----------
 2 files changed, 58 insertions(+), 74 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/groovy/blob/c219797c/src/main/org/codehaus/groovy/ast/tools/GeneralUtils.java
----------------------------------------------------------------------
diff --git a/src/main/org/codehaus/groovy/ast/tools/GeneralUtils.java b/src/main/org/codehaus/groovy/ast/tools/GeneralUtils.java
index 6afa4e0..bcdf627 100644
--- a/src/main/org/codehaus/groovy/ast/tools/GeneralUtils.java
+++ b/src/main/org/codehaus/groovy/ast/tools/GeneralUtils.java
@@ -125,6 +125,10 @@ public class GeneralUtils {
         return new AttributeExpression(oe, prop);
     }
 
+    public static BinaryExpression binX(Expression left, Token token, Expression right) {
+        return new BinaryExpression(left, token, right);
+    }
+
     public static BlockStatement block(VariableScope varScope, Statement... stmts) {
         BlockStatement block = new BlockStatement();
         block.setVariableScope(varScope);

http://git-wip-us.apache.org/repos/asf/groovy/blob/c219797c/src/main/org/codehaus/groovy/transform/stc/StaticTypeCheckingVisitor.java
----------------------------------------------------------------------
diff --git a/src/main/org/codehaus/groovy/transform/stc/StaticTypeCheckingVisitor.java b/src/main/org/codehaus/groovy/transform/stc/StaticTypeCheckingVisitor.java
index bac9d7c..0f49976 100644
--- a/src/main/org/codehaus/groovy/transform/stc/StaticTypeCheckingVisitor.java
+++ b/src/main/org/codehaus/groovy/transform/stc/StaticTypeCheckingVisitor.java
@@ -91,6 +91,11 @@ import java.util.concurrent.atomic.AtomicLong;
 import java.util.concurrent.atomic.AtomicReference;
 
 import static org.codehaus.groovy.ast.ClassHelper.*;
+import static org.codehaus.groovy.ast.tools.GeneralUtils.args;
+import static org.codehaus.groovy.ast.tools.GeneralUtils.binX;
+import static org.codehaus.groovy.ast.tools.GeneralUtils.callX;
+import static org.codehaus.groovy.ast.tools.GeneralUtils.castX;
+import static org.codehaus.groovy.ast.tools.GeneralUtils.varX;
 import static org.codehaus.groovy.ast.tools.WideningCategories.LowestUpperBoundClassNode;
 import static org.codehaus.groovy.ast.tools.WideningCategories.isBigDecCategory;
 import static org.codehaus.groovy.ast.tools.WideningCategories.isBigIntCategory;
@@ -490,7 +495,7 @@ public class StaticTypeCheckingVisitor extends ClassCodeVisitorSupport {
     }
 
     private boolean tryVariableExpressionAsProperty(final VariableExpression vexp, final String dynName) {
-        VariableExpression implicitThis = new VariableExpression("this");
+        VariableExpression implicitThis = varX("this");
         PropertyExpression pe = new PropertyExpression(implicitThis, dynName);
         pe.setImplicitThis(true);
         if (visitPropertyExpressionSilent(pe, vexp)) {
@@ -575,7 +580,7 @@ public class StaticTypeCheckingVisitor extends ClassCodeVisitorSupport {
                 if (!isPrimitiveType(lType))
                     rType = UNKNOWN_PARAMETER_TYPE; // primitive types should be ignored as they will result in another failure
             }
-            BinaryExpression reversedBinaryExpression = new BinaryExpression(rightExpression, expression.getOperation(), leftExpression);
+            BinaryExpression reversedBinaryExpression = binX(rightExpression, expression.getOperation(), leftExpression);
             ClassNode resultType = op==KEYWORD_IN
                     ?getResultType(rType,op,lType,reversedBinaryExpression)
                     :getResultType(lType, op, rType, expression);
@@ -717,12 +722,12 @@ public class StaticTypeCheckingVisitor extends ClassCodeVisitorSupport {
         // we know that the RHS type is a closure
         // but we must check if the binary expression is an assignment
         // because we need to check if a setter uses @DelegatesTo
-        VariableExpression ve = new VariableExpression("%", setterInfo.receiverType);
+        VariableExpression ve = varX("%", setterInfo.receiverType);
         // for compound assignment "x op= y" find type as if it was "x = (x op y)"
         final Expression newRightExpression = isCompoundAssignment(expression)
-                ? new BinaryExpression(leftExpression, getOpWithoutEqual(expression), rightExpression)
+                ? binX(leftExpression, getOpWithoutEqual(expression), rightExpression)
                 : rightExpression;
-        MethodCallExpression call = new MethodCallExpression(ve, setterInfo.name, newRightExpression);
+        MethodCallExpression call = callX(ve, setterInfo.name, newRightExpression);
         call.setImplicitThis(false);
         visitMethodCallExpression(call);
         MethodNode directSetterCandidate = call.getNodeMetaData(StaticTypesMarker.DIRECT_METHOD_CALL_TARGET);
@@ -732,7 +737,7 @@ public class StaticTypeCheckingVisitor extends ClassCodeVisitorSupport {
             for (MethodNode setter : setterInfo.setters) {
                 ClassNode type = getWrapper(setter.getParameters()[0].getOriginType());
                 if (Boolean_TYPE.equals(type) || STRING_TYPE.equals(type) || CLASS_Type.equals(type)) {
-                    call = new MethodCallExpression(ve, setterInfo.name, new CastExpression(type, newRightExpression));
+                    call = callX(ve, setterInfo.name, castX(type, newRightExpression));
                     call.setImplicitThis(false);
                     visitMethodCallExpression(call);
                     directSetterCandidate = call.getNodeMetaData(StaticTypesMarker.DIRECT_METHOD_CALL_TARGET);
@@ -793,38 +798,11 @@ public class StaticTypeCheckingVisitor extends ClassCodeVisitorSupport {
         if (node.isUsingGenerics() && node.getGenericsTypes() != null && node.getGenericsTypes().length == 0) {
             ArgumentListExpression argumentListExpression = InvocationWriter.makeArgumentList(cce.getArguments());
             if (argumentListExpression.getExpressions().isEmpty()) {
-                GenericsType[] genericsTypes = lType.getGenericsTypes();
-                if (genericsTypes == null) {
-                    // case of def foo = new HashMap<>()
-                    genericsTypes = node.redirect().getGenericsTypes();
-                }
-                GenericsType[] copy = new GenericsType[genericsTypes.length];
-                for (int i = 0; i < genericsTypes.length; i++) {
-                    GenericsType genericsType = genericsTypes[i];
-                    copy[i] = new GenericsType(
-                            wrapTypeIfNecessary(genericsType.getType()),
-                            genericsType.getUpperBounds(),
-                            genericsType.getLowerBound()
-                    );
-                }
-                node.setGenericsTypes(copy);
+                adjustGenerics(lType, node);
             } else {
                 ClassNode type = getType(argumentListExpression.getExpression(0));
                 if (type.isUsingGenerics()) {
-                    GenericsType[] genericsTypes = type.getGenericsTypes();
-                    if (genericsTypes == null) {
-                        genericsTypes = node.redirect().getGenericsTypes();
-                    }
-                    GenericsType[] copy = new GenericsType[genericsTypes.length];
-                    for (int i = 0; i < genericsTypes.length; i++) {
-                        GenericsType genericsType = genericsTypes[i];
-                        copy[i] = new GenericsType(
-                                wrapTypeIfNecessary(genericsType.getType()),
-                                genericsType.getUpperBounds(),
-                                genericsType.getLowerBound()
-                        );
-                    }
-                    node.setGenericsTypes(copy);
+                    adjustGenerics(type, node);
                 }
             }
             // store inferred type on CCE
@@ -832,6 +810,24 @@ public class StaticTypeCheckingVisitor extends ClassCodeVisitorSupport {
         }
     }
 
+    private void adjustGenerics(ClassNode from, ClassNode to) {
+        GenericsType[] genericsTypes = from.getGenericsTypes();
+        if (genericsTypes == null) {
+            // case of: def foo = new HashMap<>()
+            genericsTypes = to.redirect().getGenericsTypes();
+        }
+        GenericsType[] copy = new GenericsType[genericsTypes.length];
+        for (int i = 0; i < genericsTypes.length; i++) {
+            GenericsType genericsType = genericsTypes[i];
+            copy[i] = new GenericsType(
+                    wrapTypeIfNecessary(genericsType.getType()),
+                    genericsType.getUpperBounds(),
+                    genericsType.getLowerBound()
+            );
+        }
+        to.setGenericsTypes(copy);
+    }
+
     /**
      * Stores information about types when [objectOfInstanceof instanceof typeExpression] is visited
      *
@@ -942,7 +938,7 @@ public class StaticTypeCheckingVisitor extends ClassCodeVisitorSupport {
         // constructor type : Dimension d = [100,200]
         // In that case, more checks can be performed
         if (rightExpression instanceof ListExpression && !implementsInterfaceOrIsSubclassOf(LIST_TYPE, leftRedirect)) {
-            ArgumentListExpression argList = new ArgumentListExpression(((ListExpression) rightExpression).getExpressions());
+            ArgumentListExpression argList = args(((ListExpression) rightExpression).getExpressions());
             ClassNode[] args = getArgumentTypes(argList);
             MethodNode methodNode = checkGroovyStyleConstructor(leftRedirect, args, assignmentExpression);
             if (methodNode!=null) {
@@ -963,9 +959,9 @@ public class StaticTypeCheckingVisitor extends ClassCodeVisitorSupport {
         // In this case, more checks can be performed
         if (!implementsInterfaceOrIsSubclassOf(leftRedirect, MAP_TYPE) && rightExpression instanceof MapExpression) {
             if (!(leftExpression instanceof VariableExpression) || !((VariableExpression) leftExpression).isDynamicTyped()) {
-                ArgumentListExpression argList = new ArgumentListExpression(rightExpression);
-                ClassNode[] args = getArgumentTypes(argList);
-                checkGroovyStyleConstructor(leftRedirect, args, rightExpression);
+                ArgumentListExpression argList = args(rightExpression);
+                ClassNode[] argTypes = getArgumentTypes(argList);
+                checkGroovyStyleConstructor(leftRedirect, argTypes, rightExpression);
                 // perform additional type checking on arguments
                 MapExpression mapExpression = (MapExpression) rightExpression;
                 checkGroovyConstructorMap(leftExpression, leftRedirect, mapExpression);
@@ -1046,7 +1042,7 @@ public class StaticTypeCheckingVisitor extends ClassCodeVisitorSupport {
                 addStaticTypeError("Dynamic keys in map-style constructors are unsupported in static type checking", keyExpr);
             } else {
                 AtomicReference<ClassNode> lookup = new AtomicReference<ClassNode>();
-                PropertyExpression pexp = new PropertyExpression(new VariableExpression("_", receiverType), keyExpr.getText());
+                PropertyExpression pexp = new PropertyExpression(varX("_", receiverType), keyExpr.getText());
                 boolean hasProperty = existsProperty(pexp, false, new PropertyLookupVisitor(lookup));
                 if (!hasProperty) {
                     addStaticTypeError("No such property: " + keyExpr.getText() +
@@ -1372,7 +1368,7 @@ public class StaticTypeCheckingVisitor extends ClassCodeVisitorSupport {
 
     private ClassNode getTypeForSpreadExpression(ClassNode testClass, ClassNode objectExpressionType, PropertyExpression pexp) {
         if (!pexp.isSpreadSafe()) return null;
-        MethodCallExpression mce = new MethodCallExpression(new VariableExpression("_", testClass), "iterator", ArgumentListExpression.EMPTY_ARGUMENTS);
+        MethodCallExpression mce = callX(varX("_", testClass), "iterator", ArgumentListExpression.EMPTY_ARGUMENTS);
         mce.setImplicitThis(false);
         mce.visit(this);
         ClassNode callType = getType(mce);
@@ -1380,9 +1376,7 @@ public class StaticTypeCheckingVisitor extends ClassCodeVisitorSupport {
         GenericsType[] types = callType.getGenericsTypes();
         ClassNode contentType = OBJECT_TYPE;
         if (types!=null && types.length==1) contentType = types[0].getType();
-        PropertyExpression subExp = new PropertyExpression(
-                new VariableExpression("{}", contentType),
-                pexp.getPropertyAsString());
+        PropertyExpression subExp = new PropertyExpression(varX("{}", contentType), pexp.getPropertyAsString());
         AtomicReference<ClassNode> result = new AtomicReference<ClassNode>();
         if (existsProperty(subExp, true, new PropertyLookupVisitor(result))) {
             ClassNode intf = LIST_TYPE.getPlainNodeReference();
@@ -1398,9 +1392,7 @@ public class StaticTypeCheckingVisitor extends ClassCodeVisitorSupport {
         GenericsType[] types = intf.getGenericsTypes();
         if (types==null || types.length!=1) return OBJECT_TYPE;
 
-        PropertyExpression subExp = new PropertyExpression(
-                new VariableExpression("{}", types[0].getType()),
-                pexp.getPropertyAsString());
+        PropertyExpression subExp = new PropertyExpression(varX("{}", types[0].getType()), pexp.getPropertyAsString());
         AtomicReference<ClassNode> result = new AtomicReference<ClassNode>();
         if (existsProperty(subExp, true, new PropertyLookupVisitor(result))) {
             intf = LIST_TYPE.getPlainNodeReference();
@@ -1575,7 +1567,7 @@ public class StaticTypeCheckingVisitor extends ClassCodeVisitorSupport {
             Expression init = node.getInitialExpression();
             if (init != null) {
                 FieldExpression left = new FieldExpression(node);
-                BinaryExpression bexp = new BinaryExpression(
+                BinaryExpression bexp = binX(
                         left,
                         Token.newSymbol("=", node.getLineNumber(), node.getColumnNumber()),
                         init
@@ -1759,7 +1751,7 @@ public class StaticTypeCheckingVisitor extends ClassCodeVisitorSupport {
         if (isPrimitiveType(exprType) || isPrimitiveType(getUnwrapper(exprType))) {
             if (operationType == PLUS_PLUS || operationType == MINUS_MINUS) {
                 if (!isPrimitiveType(exprType)) {
-                    MethodNode node = findMethodOrFail(new VariableExpression("_dummy_", exprType), exprType, name);
+                    MethodNode node = findMethodOrFail(varX("_dummy_", exprType), exprType, name);
                     if (node != null) {
                         storeTargetMethod(origin, node);
                         storeType(origin,
@@ -1852,9 +1844,9 @@ public class StaticTypeCheckingVisitor extends ClassCodeVisitorSupport {
                 if (implementsInterfaceOrIsSubclassOf(inferred, enclosingMethod.getReturnType())) {
                     if (missesGenericsTypes(inferred)) {
                         DeclarationExpression virtualDecl = new DeclarationExpression(
-                                new VariableExpression("{target}", enclosingMethod.getReturnType()),
+                                varX("{target}", enclosingMethod.getReturnType()),
                                 Token.newSymbol(EQUAL, -1, -1),
-                                new VariableExpression("{source}", type)
+                                varX("{source}", type)
                         );
                         virtualDecl.setSourcePosition(statement);
                         virtualDecl.visit(this);
@@ -2310,9 +2302,9 @@ public class StaticTypeCheckingVisitor extends ClassCodeVisitorSupport {
         List<Expression> expressions = new LinkedList<Expression>(arguments.getExpressions());
         if (selectedMethod instanceof ExtensionMethodNode) {
             params = ((ExtensionMethodNode) selectedMethod).getExtensionMethodNode().getParameters();
-            expressions.add(0, new VariableExpression("$self", receiver));
+            expressions.add(0, varX("$self", receiver));
         }
-        ArgumentListExpression newArgs = new ArgumentListExpression(expressions);
+        ArgumentListExpression newArgs = args(expressions);
 
         for (int i = 0, expressionsSize = expressions.size(); i < expressionsSize; i++) {
             final Expression expression = expressions.get(i);
@@ -2674,7 +2666,7 @@ public class StaticTypeCheckingVisitor extends ClassCodeVisitorSupport {
                 Expression type = annotation.getMember("type");
                 Integer stInt = Closure.OWNER_FIRST;
                 if (strategy!=null) {
-                    stInt = (Integer) evaluateExpression(new CastExpression(ClassHelper.Integer_TYPE,strategy), typeCheckingContext.source.getConfiguration());
+                    stInt = (Integer) evaluateExpression(castX(ClassHelper.Integer_TYPE,strategy), typeCheckingContext.source.getConfiguration());
                 }
                 if (value instanceof ClassExpression && !value.getType().equals(DELEGATES_TO_TARGET)) {
                     if (genericTypeIndex!=null) {
@@ -2829,11 +2821,7 @@ public class StaticTypeCheckingVisitor extends ClassCodeVisitorSupport {
             } else {
                 // type check call as if it was made on component type
                 ClassNode componentType = inferComponentType(expressionType, int_TYPE);
-                MethodCallExpression subcall = new MethodCallExpression(
-                        new CastExpression(componentType, EmptyExpression.INSTANCE),
-                        name,
-                        call.getArguments()
-                );
+                MethodCallExpression subcall = callX(castX(componentType, EmptyExpression.INSTANCE), name, call.getArguments());
                 subcall.setLineNumber(call.getLineNumber());
                 subcall.setColumnNumber(call.getColumnNumber());
                 subcall.setImplicitThis(call.isImplicitThis());
@@ -3355,7 +3343,7 @@ public class StaticTypeCheckingVisitor extends ClassCodeVisitorSupport {
         boolean sourceIsNull = isNullConstant(source);
         ClassNode expressionType = getType(source);
         if (targetType.isArray() && expressionType.isArray()) {
-            return checkCast(targetType.getComponentType(), new VariableExpression("foo", expressionType.getComponentType()));
+            return checkCast(targetType.getComponentType(), varX("foo", expressionType.getComponentType()));
         } else if (targetType.equals(char_TYPE) && expressionType == STRING_TYPE
                 && source instanceof ConstantExpression && source.getText().length() == 1) {
             // ex: (char) 'c'
@@ -3535,11 +3523,7 @@ public class StaticTypeCheckingVisitor extends ClassCodeVisitorSupport {
         } else if (isArrayOp(op)) {
             // using getPNR() to ignore generics at this point
             // and a different binary expression not to pollute the AST
-            BinaryExpression newExpr = new BinaryExpression(
-                    expr.getLeftExpression(),
-                    expr.getOperation(),
-                    rightExpression
-            );
+            BinaryExpression newExpr = binX(expr.getLeftExpression(), expr.getOperation(), rightExpression);
             newExpr.setSourcePosition(expr);
             MethodNode method = findMethodOrFail(newExpr, left.getPlainNodeReference(), "getAt", right.getPlainNodeReference());
             if (method!=null && implementsInterfaceOrIsSubclassOf(right, RANGE_TYPE)) {
@@ -3614,7 +3598,7 @@ public class StaticTypeCheckingVisitor extends ClassCodeVisitorSupport {
             if (isAssignment(op)) return left;
             if (isCompareToBoolean(op)) return boolean_TYPE;
             if (op == COMPARE_TO) return int_TYPE;
-            return inferReturnTypeGenerics(left, method, new ArgumentListExpression(rightExpression));
+            return inferReturnTypeGenerics(left, method, args(rightExpression));
         }
         //TODO: other cases
         return null;
@@ -3676,7 +3660,7 @@ public class StaticTypeCheckingVisitor extends ClassCodeVisitorSupport {
             // GROOVY-5521
             // try to identify a getAt method
             typeCheckingContext.pushErrorCollector();
-            MethodCallExpression vcall = new MethodCallExpression(new VariableExpression("_hash_", containerType), "getAt", new VariableExpression("_index_", indexType));
+            MethodCallExpression vcall = callX(varX("_hash_", containerType), "getAt", varX("_index_", indexType));
             try {
                 visitMethodCallExpression(vcall);
             } finally {
@@ -3694,12 +3678,8 @@ public class StaticTypeCheckingVisitor extends ClassCodeVisitorSupport {
         List<MethodNode> methods = findMethod(receiver, name, args);
         if (methods.isEmpty() && (expr instanceof BinaryExpression)) {
             BinaryExpression be = (BinaryExpression) expr;
-            MethodCallExpression call = new MethodCallExpression(
-                    be.getLeftExpression(),
-                    name,
-                    be.getRightExpression()
-            );
-            methods = extension.handleMissingMethod(receiver, name, new ArgumentListExpression(be.getLeftExpression()), args, call);
+            MethodCallExpression call = callX(be.getLeftExpression(), name, be.getRightExpression());
+            methods = extension.handleMissingMethod(receiver, name, args(be.getLeftExpression()), args, call);
         }
         if (methods.isEmpty()) {
             addNoMatchingMethodError(receiver, name, args, expr);
@@ -4288,7 +4268,7 @@ public class StaticTypeCheckingVisitor extends ClassCodeVisitorSupport {
             MethodNode dgmMethod = emn.getExtensionMethodNode();
             ClassNode dc = emn.getDeclaringClass();
             ArgumentListExpression argList = new ArgumentListExpression();
-            VariableExpression vexp = new VariableExpression("$foo", receiver);
+            VariableExpression vexp = varX("$foo", receiver);
             vexp.setNodeMetaData(ExtensionMethodDeclaringClass.class, dc);
             argList.addExpression(vexp);
             if (arguments instanceof ArgumentListExpression) {


[08/11] groovy git commit: GROOVY-8030: An unexpected error has occurred when using 'kkk = kkk + 12' (closes #488)

Posted by su...@apache.org.
GROOVY-8030: An unexpected error has occurred when using 'kkk = kkk + 12' (closes #488)


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

Branch: refs/heads/parrot
Commit: 4971552b85e5c12d4ebf49ddac181523c5160baa
Parents: ea28001
Author: paulk <pa...@asert.com.au>
Authored: Fri Feb 3 19:59:47 2017 +1000
Committer: paulk <pa...@asert.com.au>
Committed: Sun Feb 5 11:33:11 2017 +1000

----------------------------------------------------------------------
 .../asm/sc/StaticTypesCallSiteWriter.java       |  5 +++
 src/test/groovy/bugs/Groovy8030Bug.groovy       | 34 ++++++++++++++++++++
 2 files changed, 39 insertions(+)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/groovy/blob/4971552b/src/main/org/codehaus/groovy/classgen/asm/sc/StaticTypesCallSiteWriter.java
----------------------------------------------------------------------
diff --git a/src/main/org/codehaus/groovy/classgen/asm/sc/StaticTypesCallSiteWriter.java b/src/main/org/codehaus/groovy/classgen/asm/sc/StaticTypesCallSiteWriter.java
index fe69531..727739d 100644
--- a/src/main/org/codehaus/groovy/classgen/asm/sc/StaticTypesCallSiteWriter.java
+++ b/src/main/org/codehaus/groovy/classgen/asm/sc/StaticTypesCallSiteWriter.java
@@ -631,6 +631,11 @@ public class StaticTypesCallSiteWriter extends CallSiteWriter implements Opcodes
         }
         // now try with flow type instead of declaration type
         rType = receiver.getNodeMetaData(StaticTypesMarker.INFERRED_TYPE);
+        if (receiver instanceof VariableExpression && receiver.getNodeMetaData().isEmpty()) {
+            // TODO: can STCV be made smarter to avoid this check?
+            VariableExpression ve = (VariableExpression) ((VariableExpression)receiver).getAccessedVariable();
+            rType = ve.getNodeMetaData(StaticTypesMarker.INFERRED_TYPE);
+        }
         if (rType!=null && trySubscript(receiver, message, arguments, rType, aType)) {
             return;
         }

http://git-wip-us.apache.org/repos/asf/groovy/blob/4971552b/src/test/groovy/bugs/Groovy8030Bug.groovy
----------------------------------------------------------------------
diff --git a/src/test/groovy/bugs/Groovy8030Bug.groovy b/src/test/groovy/bugs/Groovy8030Bug.groovy
new file mode 100644
index 0000000..5438989
--- /dev/null
+++ b/src/test/groovy/bugs/Groovy8030Bug.groovy
@@ -0,0 +1,34 @@
+/*
+ *  Licensed to the Apache Software Foundation (ASF) under one
+ *  or more contributor license agreements.  See the NOTICE file
+ *  distributed with this work for additional information
+ *  regarding copyright ownership.  The ASF licenses this file
+ *  to you under the Apache License, Version 2.0 (the
+ *  "License"); you may not use this file except in compliance
+ *  with the License.  You may obtain a copy of the License at
+ *
+ *    http://www.apache.org/licenses/LICENSE-2.0
+ *
+ *  Unless required by applicable law or agreed to in writing,
+ *  software distributed under the License is distributed on an
+ *  "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ *  KIND, either express or implied.  See the License for the
+ *  specific language governing permissions and limitations
+ *  under the License.
+ */
+package groovy.bugs
+
+class Groovy8030Bug extends GroovyTestCase {
+    void testCompileStaticWithBinaryExpressionAndFlowTyping() {
+        assertScript """
+@groovy.transform.CompileStatic
+def main() {
+    def kkk = "abc"
+    kkk = 30
+    kkk + 12 // Previously: BUG! exception in phase 'class generation'
+}
+
+assert main() == 42
+        """
+    }
+}


[09/11] groovy git commit: GROOVY-8075: Bump Ant version to 1.9.9

Posted by su...@apache.org.
GROOVY-8075: Bump Ant version to 1.9.9


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

Branch: refs/heads/parrot
Commit: 59a36cfd20a8ca039bea274e339af6f4c61ef13f
Parents: 4971552b
Author: paulk <pa...@asert.com.au>
Authored: Tue Feb 7 18:24:21 2017 +1000
Committer: paulk <pa...@asert.com.au>
Committed: Tue Feb 7 18:24:21 2017 +1000

----------------------------------------------------------------------
 build.gradle | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/groovy/blob/59a36cfd/build.gradle
----------------------------------------------------------------------
diff --git a/build.gradle b/build.gradle
index 9343891..22300d4 100644
--- a/build.gradle
+++ b/build.gradle
@@ -144,7 +144,7 @@ configurations {
 }
 
 ext {
-    antVersion = '1.9.7'
+    antVersion = '1.9.9'
     asmVersion = '6.0_ALPHA'
     antlrVersion = '2.7.7'
     bridgerVersion = '1.1.Final'


[11/11] groovy git commit: Merge branch 'master' of https://git-wip-us.apache.org/repos/asf/groovy into parrot

Posted by su...@apache.org.
Merge branch 'master' of https://git-wip-us.apache.org/repos/asf/groovy into parrot


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

Branch: refs/heads/parrot
Commit: d21ddc7abe062ee643b5d6db8e209a9da50446fe
Parents: a9c7046 01fdb70
Author: sunlan <su...@apache.org>
Authored: Wed Feb 8 12:11:16 2017 +0800
Committer: sunlan <su...@apache.org>
Committed: Wed Feb 8 12:11:58 2017 +0800

----------------------------------------------------------------------
 build.gradle                                    |   2 +-
 gradle/pomconfigurer.gradle                     |   3 +
 src/main/groovy/util/logging/Commons.java       |   1 +
 src/main/groovy/util/logging/Log.java           |   1 +
 src/main/groovy/util/logging/Log4j.java         |   1 +
 src/main/groovy/util/logging/Log4j2.java        |   1 +
 src/main/groovy/util/logging/Slf4j.java         |   1 +
 .../codehaus/groovy/ast/tools/GeneralUtils.java |   4 +
 .../groovy/classgen/AnnotationVisitor.java      |  31 ++-
 .../asm/sc/StaticTypesCallSiteWriter.java       |  14 +-
 .../groovy/runtime/StringGroovyMethods.java     |   5 +
 .../stc/StaticTypeCheckingVisitor.java          | 275 +++++--------------
 src/spec/doc/core-syntax.adoc                   |   2 +-
 src/test/gls/annotations/AnnotationTest.groovy  |   4 -
 src/test/groovy/bugs/Groovy8026Bug.groovy       |  35 +++
 src/test/groovy/bugs/Groovy8030Bug.groovy       |  34 +++
 .../classgen/asm/sc/bugs/Groovy8069Bug.groovy   |  55 ++++
 .../src/main/java/groovy/sql/Sql.java           |  15 +-
 18 files changed, 256 insertions(+), 228 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/groovy/blob/d21ddc7a/build.gradle
----------------------------------------------------------------------

http://git-wip-us.apache.org/repos/asf/groovy/blob/d21ddc7a/src/main/org/codehaus/groovy/classgen/asm/sc/StaticTypesCallSiteWriter.java
----------------------------------------------------------------------
diff --cc src/main/org/codehaus/groovy/classgen/asm/sc/StaticTypesCallSiteWriter.java
index 37bfe88,727739d..d77316a
--- a/src/main/org/codehaus/groovy/classgen/asm/sc/StaticTypesCallSiteWriter.java
+++ b/src/main/org/codehaus/groovy/classgen/asm/sc/StaticTypesCallSiteWriter.java
@@@ -632,18 -631,23 +631,23 @@@ public class StaticTypesCallSiteWriter 
          }
          // now try with flow type instead of declaration type
          rType = receiver.getNodeMetaData(StaticTypesMarker.INFERRED_TYPE);
+         if (receiver instanceof VariableExpression && receiver.getNodeMetaData().isEmpty()) {
+             // TODO: can STCV be made smarter to avoid this check?
+             VariableExpression ve = (VariableExpression) ((VariableExpression)receiver).getAccessedVariable();
+             rType = ve.getNodeMetaData(StaticTypesMarker.INFERRED_TYPE);
+         }
 -        if (rType!=null && trySubscript(receiver, message, arguments, rType, aType)) {
 +        if (rType!=null && trySubscript(receiver, message, arguments, rType, aType, safe)) {
              return;
          }
          // todo: more cases
          throw new GroovyBugError(
-                 "At line "+receiver.getLineNumber() + " column " + receiver.getColumnNumber() + "\n" +
-                 "On receiver: "+receiver.getText() + " with message: "+message+" and arguments: "+arguments.getText()+"\n"+
-                 "This method should not have been called. Please try to create a simple example reproducing this error and file" +
-                 "a bug report at https://issues.apache.org/jira/browse/GROOVY");
+                 "At line " + receiver.getLineNumber() + " column " + receiver.getColumnNumber() + "\n" +
+                 "On receiver: " + receiver.getText() + " with message: " + message + " and arguments: " + arguments.getText() + "\n" +
+                 "This method should not have been called. Please try to create a simple example reproducing\n" +
+                 "this error and file a bug report at https://issues.apache.org/jira/browse/GROOVY");
      }
  
 -    private boolean trySubscript(final Expression receiver, final String message, final Expression arguments, ClassNode rType, final ClassNode aType) {
 +    private boolean trySubscript(final Expression receiver, final String message, final Expression arguments, ClassNode rType, final ClassNode aType, boolean safe) {
          if (getWrapper(rType).isDerivedFrom(Number_TYPE)
                  && getWrapper(aType).isDerivedFrom(Number_TYPE)) {
              if ("plus".equals(message) || "minus".equals(message) || "multiply".equals(message) || "div".equals(message)) {

http://git-wip-us.apache.org/repos/asf/groovy/blob/d21ddc7a/src/main/org/codehaus/groovy/transform/stc/StaticTypeCheckingVisitor.java
----------------------------------------------------------------------
diff --cc src/main/org/codehaus/groovy/transform/stc/StaticTypeCheckingVisitor.java
index 006e082,0f49976..a2f93f0
--- a/src/main/org/codehaus/groovy/transform/stc/StaticTypeCheckingVisitor.java
+++ b/src/main/org/codehaus/groovy/transform/stc/StaticTypeCheckingVisitor.java
@@@ -693,11 -580,11 +583,11 @@@ public class StaticTypeCheckingVisitor 
                  if (!isPrimitiveType(lType))
                      rType = UNKNOWN_PARAMETER_TYPE; // primitive types should be ignored as they will result in another failure
              }
-             BinaryExpression reversedBinaryExpression = new BinaryExpression(rightExpression, expression.getOperation(), leftExpression);
+             BinaryExpression reversedBinaryExpression = binX(rightExpression, expression.getOperation(), leftExpression);
 -            ClassNode resultType = op==KEYWORD_IN
 +            ClassNode resultType = (op==KEYWORD_IN || op==COMPARE_NOT_IN)
                      ?getResultType(rType,op,lType,reversedBinaryExpression)
                      :getResultType(lType, op, rType, expression);
 -            if (op==KEYWORD_IN) {
 +            if (op==KEYWORD_IN || op==COMPARE_NOT_IN) {
                  // in case of the "in" operator, the receiver and the arguments are reversed
                  // so we use the reversedExpression and get the target method from it
                  storeTargetMethod(expression, (MethodNode) reversedBinaryExpression.getNodeMetaData(StaticTypesMarker.DIRECT_METHOD_CALL_TARGET));
@@@ -1202,7 -1080,7 +1083,7 @@@
       *
       * @param node      the class node for which we will try to find a matching constructor
       * @param arguments the constructor arguments
--     * @deprecated use {@link #checkGroovyStyleConstructor(org.codehaus.groovy.ast.ClassNode, org.codehaus.groovy.ast.ClassNode[], org.codehaus.groovy.ast.ASTNode)} )}
++     * @deprecated use {@link #checkGroovyStyleConstructor(ClassNode, ClassNode[], ASTNode)} )}
       */
      @Deprecated
      protected void checkGroovyStyleConstructor(final ClassNode node, final ClassNode[] arguments) {
@@@ -2224,13 -2098,13 +2101,13 @@@
              return;
          }
          if (!extension.beforeVisitMethod(node)) {
--        ErrorCollector collector = (ErrorCollector) node.getNodeMetaData(ERROR_COLLECTOR);
--        if (collector != null) {
--            typeCheckingContext.getErrorCollector().addCollectorContents(collector);
--        } else {
--            startMethodInference(node, typeCheckingContext.getErrorCollector());
--        }
--        node.removeNodeMetaData(ERROR_COLLECTOR);
++            ErrorCollector collector = (ErrorCollector) node.getNodeMetaData(ERROR_COLLECTOR);
++            if (collector != null) {
++                typeCheckingContext.getErrorCollector().addCollectorContents(collector);
++            } else {
++                startMethodInference(node, typeCheckingContext.getErrorCollector());
++            }
++            node.removeNodeMetaData(ERROR_COLLECTOR);
          }
          extension.afterVisitMethod(node);
      }
@@@ -2459,13 -2333,13 +2336,13 @@@
       * This method is responsible for performing type inference on closure argument types whenever code like this is
       * found: <code>foo.collect { it.toUpperCase() }</code>.
       * In this case, the type checker tries to find if the <code>collect</code> method has its {@link Closure} argument
--     * annotated with {@link groovy.transform.stc.ClosureParams}. If yes, then additional type inference can be performed
++     * annotated with {@link ClosureParams}. If yes, then additional type inference can be performed
       * and the type of <code>it</code> may be inferred.
       *
       * @param receiver
       * @param arguments
       * @param expression a closure expression for which the argument types should be inferred
--     * @param param the parameter where to look for a {@link groovy.transform.stc.ClosureParams} annotation.
++     * @param param the parameter where to look for a {@link ClosureParams} annotation.
       * @param selectedMethod the method accepting a closure
       */
      protected void inferClosureParameterTypes(final ClassNode receiver, final Expression arguments, final ClosureExpression expression, final Parameter param, final MethodNode selectedMethod) {
@@@ -2738,7 -2612,7 +2615,7 @@@
  
      /**
       * Given a GenericsType instance, returns a ClassNode which can be used as an inferred type.
--     * @param genericsType a {@link org.codehaus.groovy.ast.GenericsType} representing either a type, a placeholder or a wildcard
++     * @param genericsType a {@link GenericsType} representing either a type, a placeholder or a wildcard
       * @return a class node usable as an inferred type
       */
      private static ClassNode createUsableClassNodeFromGenericsType(final GenericsType genericsType) {
@@@ -3205,7 -3075,7 +3078,7 @@@
       * @param directMethodCallCandidate a method selected by the type checker
       * @param receiver the receiver of the method call
       *@param args the arguments of the method call
--     * @param returnType the original return type, as inferred by the type checker   @return fixed return type if the selected method is {@link org.codehaus.groovy.runtime.DefaultGroovyMethods#withTraits(Object, Class[]) withTraits}
++     * @param returnType the original return type, as inferred by the type checker   @return fixed return type if the selected method is {@link DefaultGroovyMethods#withTraits(Object, Class[]) withTraits}
       */
      private static ClassNode adjustWithTraits(final MethodNode directMethodCallCandidate, final ClassNode receiver, final ClassNode[] args, final ClassNode returnType) {
          if (directMethodCallCandidate instanceof ExtensionMethodNode) {
@@@ -4896,7 -4758,7 +4761,7 @@@
  
      /**
       * Returns a wrapped type if, and only if, the provided class node is a primitive type.
--     * This method differs from {@link ClassHelper#getWrapper(org.codehaus.groovy.ast.ClassNode)} as it will
++     * This method differs from {@link ClassHelper#getWrapper(ClassNode)} as it will
       * return the same instance if the provided type is not a generic type.
       *
       * @param type


[04/11] groovy git commit: Fixed typo. (closes #486)

Posted by su...@apache.org.
Fixed typo. (closes #486)

~ Petty typo fixes are the backbone of OSS ~


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

Branch: refs/heads/parrot
Commit: d4edf9c531f2678d7a83c07fda16a566cd2d6c61
Parents: 70330d5
Author: amanda.e.sullivan@ndsu.edu <am...@ndsu.edu>
Authored: Tue Jan 31 08:47:51 2017 -0600
Committer: paulk <pa...@asert.com.au>
Committed: Wed Feb 1 11:34:22 2017 +1000

----------------------------------------------------------------------
 src/spec/doc/core-syntax.adoc | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/groovy/blob/d4edf9c5/src/spec/doc/core-syntax.adoc
----------------------------------------------------------------------
diff --git a/src/spec/doc/core-syntax.adoc b/src/spec/doc/core-syntax.adoc
index d88499c..a0815d0 100644
--- a/src/spec/doc/core-syntax.adoc
+++ b/src/spec/doc/core-syntax.adoc
@@ -719,7 +719,7 @@ include::{projectdir}/src/spec/test/SyntaxTest.groovy[tags=underscore_in_number_
 
 === Number type suffixes
 
-We can force a number (including binary, octals and hexadecimals) to have a specific type by giving a suffix (see table bellow), either uppercase or lowercase.
+We can force a number (including binary, octals and hexadecimals) to have a specific type by giving a suffix (see table below), either uppercase or lowercase.
 
 [cols="1,2" options="header"]
 |====


[10/11] groovy git commit: GROOVY-8068: improper logging in groovy.sql.Sql (closes #491)

Posted by su...@apache.org.
GROOVY-8068: improper logging in groovy.sql.Sql (closes #491)


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

Branch: refs/heads/parrot
Commit: 01fdb705c4ca0737949c4fd323b62736c27716a8
Parents: 59a36cf
Author: paulk <pa...@asert.com.au>
Authored: Tue Feb 7 18:31:02 2017 +1000
Committer: paulk <pa...@asert.com.au>
Committed: Tue Feb 7 18:35:39 2017 +1000

----------------------------------------------------------------------
 .../groovy-sql/src/main/java/groovy/sql/Sql.java     | 15 ++++++++++++---
 1 file changed, 12 insertions(+), 3 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/groovy/blob/01fdb705/subprojects/groovy-sql/src/main/java/groovy/sql/Sql.java
----------------------------------------------------------------------
diff --git a/subprojects/groovy-sql/src/main/java/groovy/sql/Sql.java b/subprojects/groovy-sql/src/main/java/groovy/sql/Sql.java
index 7816dec..b115ed8 100644
--- a/subprojects/groovy-sql/src/main/java/groovy/sql/Sql.java
+++ b/subprojects/groovy-sql/src/main/java/groovy/sql/Sql.java
@@ -578,17 +578,26 @@ public class Sql {
 
         Object url = sqlArgs.remove("url");
         Connection connection;
+        LOG.fine("url = " + url);
         if (props != null) {
-            System.err.println("url = " + url);
-            System.err.println("props = " + props);
-            connection = DriverManager.getConnection(url.toString(), new Properties(props));
+            Properties propsCopy = new Properties(props);
+            connection = DriverManager.getConnection(url.toString(), propsCopy);
+            if (propsCopy.containsKey("password")) {
+                // don't log the password
+                propsCopy = new Properties(propsCopy);
+                propsCopy.setProperty("password", "***");
+            }
+            LOG.fine("props = " + propsCopy);
         } else if (sqlArgs.containsKey("user")) {
             Object user = sqlArgs.remove("user");
+            LOG.fine("user = " + user);
             Object password = sqlArgs.remove("password");
+            LOG.fine("password = " + (password == null ? "null" : "***"));
             connection = DriverManager.getConnection(url.toString(),
                     (user == null ? null : user.toString()),
                     (password == null ? null : password.toString()));
         } else {
+            LOG.fine("No user/password specified");
             connection = DriverManager.getConnection(url.toString());
         }
 


[07/11] groovy git commit: GROOVY-8069: Annotation based logging of complex expression in closure throws GroovyCastException with SC (closes #487)

Posted by su...@apache.org.
GROOVY-8069: Annotation based logging of complex expression in closure throws GroovyCastException with SC (closes #487)


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

Branch: refs/heads/parrot
Commit: ea28001ac0c12e4ee44af96e6caf5fe2eb9931b7
Parents: 15a8c67
Author: Shil Sinha <sh...@apache.org>
Authored: Thu Feb 2 01:48:01 2017 -0500
Committer: Shil Sinha <sh...@apache.org>
Committed: Thu Feb 2 09:03:02 2017 -0500

----------------------------------------------------------------------
 src/main/groovy/util/logging/Commons.java       |  1 +
 src/main/groovy/util/logging/Log.java           |  1 +
 src/main/groovy/util/logging/Log4j.java         |  1 +
 src/main/groovy/util/logging/Log4j2.java        |  1 +
 src/main/groovy/util/logging/Slf4j.java         |  1 +
 .../classgen/asm/sc/bugs/Groovy8069Bug.groovy   | 55 ++++++++++++++++++++
 6 files changed, 60 insertions(+)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/groovy/blob/ea28001a/src/main/groovy/util/logging/Commons.java
----------------------------------------------------------------------
diff --git a/src/main/groovy/util/logging/Commons.java b/src/main/groovy/util/logging/Commons.java
index cfb912f..7b1da7d 100644
--- a/src/main/groovy/util/logging/Commons.java
+++ b/src/main/groovy/util/logging/Commons.java
@@ -91,6 +91,7 @@ public @interface Commons {
                     logVariable,
                     "is" + methodName.substring(0, 1).toUpperCase(Locale.ENGLISH) + methodName.substring(1, methodName.length()) + "Enabled",
                     ArgumentListExpression.EMPTY_ARGUMENTS);
+            condition.setImplicitThis(false);
 
             return new TernaryExpression(
                     new BooleanExpression(condition),

http://git-wip-us.apache.org/repos/asf/groovy/blob/ea28001a/src/main/groovy/util/logging/Log.java
----------------------------------------------------------------------
diff --git a/src/main/groovy/util/logging/Log.java b/src/main/groovy/util/logging/Log.java
index 66d3c32..39edc39 100644
--- a/src/main/groovy/util/logging/Log.java
+++ b/src/main/groovy/util/logging/Log.java
@@ -105,6 +105,7 @@ public @interface Log {
             ArgumentListExpression args = new ArgumentListExpression();
             args.addExpression(logLevelExpression);
             MethodCallExpression condition = new MethodCallExpression(logVariable, "isLoggable", args);
+            condition.setImplicitThis(false);
 
             return new TernaryExpression(
                     new BooleanExpression(condition),

http://git-wip-us.apache.org/repos/asf/groovy/blob/ea28001a/src/main/groovy/util/logging/Log4j.java
----------------------------------------------------------------------
diff --git a/src/main/groovy/util/logging/Log4j.java b/src/main/groovy/util/logging/Log4j.java
index d60acd2..5a78e79 100644
--- a/src/main/groovy/util/logging/Log4j.java
+++ b/src/main/groovy/util/logging/Log4j.java
@@ -101,6 +101,7 @@ public @interface Log4j {
                         "is" + methodName.substring(0, 1).toUpperCase(Locale.ENGLISH) + methodName.substring(1, methodName.length()) + "Enabled",
                         ArgumentListExpression.EMPTY_ARGUMENTS);
             }
+            condition.setImplicitThis(false);
 
             return new TernaryExpression(
                     new BooleanExpression(condition),

http://git-wip-us.apache.org/repos/asf/groovy/blob/ea28001a/src/main/groovy/util/logging/Log4j2.java
----------------------------------------------------------------------
diff --git a/src/main/groovy/util/logging/Log4j2.java b/src/main/groovy/util/logging/Log4j2.java
index f2685df..6aab6c5 100644
--- a/src/main/groovy/util/logging/Log4j2.java
+++ b/src/main/groovy/util/logging/Log4j2.java
@@ -95,6 +95,7 @@ public @interface Log4j2 {
                     logVariable,
                     "is" + methodName.substring(0, 1).toUpperCase(Locale.ENGLISH) + methodName.substring(1, methodName.length()) + "Enabled",
                     ArgumentListExpression.EMPTY_ARGUMENTS);
+            condition.setImplicitThis(false);
 
             return new TernaryExpression(
                     new BooleanExpression(condition),

http://git-wip-us.apache.org/repos/asf/groovy/blob/ea28001a/src/main/groovy/util/logging/Slf4j.java
----------------------------------------------------------------------
diff --git a/src/main/groovy/util/logging/Slf4j.java b/src/main/groovy/util/logging/Slf4j.java
index fad38d1..7084938 100644
--- a/src/main/groovy/util/logging/Slf4j.java
+++ b/src/main/groovy/util/logging/Slf4j.java
@@ -90,6 +90,7 @@ public @interface Slf4j {
                     logVariable,
                     "is" + methodName.substring(0, 1).toUpperCase(Locale.ENGLISH) + methodName.substring(1, methodName.length()) + "Enabled",
                     ArgumentListExpression.EMPTY_ARGUMENTS);
+            condition.setImplicitThis(false);
 
             return new TernaryExpression(
                     new BooleanExpression(condition),

http://git-wip-us.apache.org/repos/asf/groovy/blob/ea28001a/src/test/org/codehaus/groovy/classgen/asm/sc/bugs/Groovy8069Bug.groovy
----------------------------------------------------------------------
diff --git a/src/test/org/codehaus/groovy/classgen/asm/sc/bugs/Groovy8069Bug.groovy b/src/test/org/codehaus/groovy/classgen/asm/sc/bugs/Groovy8069Bug.groovy
new file mode 100644
index 0000000..38eead6
--- /dev/null
+++ b/src/test/org/codehaus/groovy/classgen/asm/sc/bugs/Groovy8069Bug.groovy
@@ -0,0 +1,55 @@
+/*
+ *  Licensed to the Apache Software Foundation (ASF) under one
+ *  or more contributor license agreements.  See the NOTICE file
+ *  distributed with this work for additional information
+ *  regarding copyright ownership.  The ASF licenses this file
+ *  to you under the Apache License, Version 2.0 (the
+ *  "License"); you may not use this file except in compliance
+ *  with the License.  You may obtain a copy of the License at
+ *
+ *    http://www.apache.org/licenses/LICENSE-2.0
+ *
+ *  Unless required by applicable law or agreed to in writing,
+ *  software distributed under the License is distributed on an
+ *  "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ *  KIND, either express or implied.  See the License for the
+ *  specific language governing permissions and limitations
+ *  under the License.
+ */
+package org.codehaus.groovy.classgen.asm.sc.bugs
+
+import groovy.transform.stc.StaticTypeCheckingTestCase
+import org.codehaus.groovy.classgen.asm.sc.StaticCompilationTestSupport
+
+class Groovy8069Bug extends StaticTypeCheckingTestCase implements StaticCompilationTestSupport {
+    void testComplexLogInClosure() {
+        assertScript '''
+            @groovy.util.logging.Log
+            @groovy.transform.CompileStatic
+            class Foo {
+                void bar() {
+                    def callable = {
+                        log.info('a' + 1)
+                    }
+                    callable.call()
+                }
+            }
+            new Foo().bar()
+        '''
+    }
+    void testComplexLogInClosureInStaticMethod() {
+        assertScript '''
+            @groovy.util.logging.Log
+            @groovy.transform.CompileStatic
+            class Foo {
+                static void barStatic() {
+                    def callable = {
+                        log.info('a' + 1)
+                    }
+                    callable.call()
+                }
+            }
+            Foo.barStatic()
+        '''
+    }
+}


[03/11] groovy git commit: trivial refactor

Posted by su...@apache.org.
trivial refactor


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

Branch: refs/heads/parrot
Commit: 70330d576320e2343f86f032139bc0fa1aad89bc
Parents: 6ba1cdc
Author: paulk <pa...@asert.com.au>
Authored: Tue Jan 31 00:03:32 2017 +1000
Committer: paulk <pa...@asert.com.au>
Committed: Tue Jan 31 00:03:32 2017 +1000

----------------------------------------------------------------------
 src/test/gls/annotations/AnnotationTest.groovy | 4 ----
 1 file changed, 4 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/groovy/blob/70330d57/src/test/gls/annotations/AnnotationTest.groovy
----------------------------------------------------------------------
diff --git a/src/test/gls/annotations/AnnotationTest.groovy b/src/test/gls/annotations/AnnotationTest.groovy
index 7c80faf..a63e0bd 100644
--- a/src/test/gls/annotations/AnnotationTest.groovy
+++ b/src/test/gls/annotations/AnnotationTest.groovy
@@ -22,10 +22,6 @@ import gls.CompilableTestSupport
 
 /**
  * Tests various properties of annotation definitions.
- *
- * @author Jochen Theodorou
- * @author Guillaume Laforge
- * @author Paul King
  */
 class AnnotationTest extends CompilableTestSupport {