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/01/28 16:08:09 UTC

[01/10] groovy git commit: GROOVY-8060: @Log annotation does not check logging enablement inside closures which are arguments to methods

Repository: groovy
Updated Branches:
  refs/heads/parrot a033231e2 -> 5392eb4fa


GROOVY-8060: @Log annotation does not check logging enablement inside closures which are arguments to methods


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

Branch: refs/heads/parrot
Commit: e96a9619ca3e51d867290056194fe5259c55c084
Parents: 90fe6d2
Author: paulk <pa...@asert.com.au>
Authored: Mon Jan 23 21:42:52 2017 +1000
Committer: paulk <pa...@asert.com.au>
Committed: Mon Jan 23 21:42:52 2017 +1000

----------------------------------------------------------------------
 .../groovy/transform/LogASTTransformation.java  | 24 +++++++-----
 src/test/groovy/bugs/Groovy8060Bug.groovy       | 39 ++++++++++++++++++++
 2 files changed, 54 insertions(+), 9 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/groovy/blob/e96a9619/src/main/org/codehaus/groovy/transform/LogASTTransformation.java
----------------------------------------------------------------------
diff --git a/src/main/org/codehaus/groovy/transform/LogASTTransformation.java b/src/main/org/codehaus/groovy/transform/LogASTTransformation.java
index 42fb9a3..ecf92bc 100644
--- a/src/main/org/codehaus/groovy/transform/LogASTTransformation.java
+++ b/src/main/org/codehaus/groovy/transform/LogASTTransformation.java
@@ -129,24 +129,30 @@ public class LogASTTransformation extends AbstractASTTransformation implements C
             }
 
             private Expression transformMethodCallExpression(Expression exp) {
-                MethodCallExpression mce = (MethodCallExpression) exp;
+                Expression modifiedCall = addGuard((MethodCallExpression) exp);
+                return modifiedCall == null ? super.transform(exp) : modifiedCall;
+            }
+
+            private Expression addGuard(MethodCallExpression mce) {
+                // only add guard to methods of the form: logVar.logMethod(params)
                 if (!(mce.getObjectExpression() instanceof VariableExpression)) {
-                    return exp;
+                    return null;
                 }
                 VariableExpression variableExpression = (VariableExpression) mce.getObjectExpression();
                 if (!variableExpression.getName().equals(logFieldName)
                         || !(variableExpression.getAccessedVariable() instanceof DynamicVariable)) {
-                    return exp;
+                    return null;
                 }
+
                 String methodName = mce.getMethodAsString();
-                if (methodName == null) return exp;
-                if (usesSimpleMethodArgumentsOnly(mce)) return exp;
+                if (methodName == null) return null;
+                if (!loggingStrategy.isLoggingMethod(methodName)) return null;
+                // also don't bother with guard if we have "simple" method args
+                // since there is no saving
+                if (usesSimpleMethodArgumentsOnly(mce)) return null;
 
                 variableExpression.setAccessedVariable(logNode);
-
-                if (!loggingStrategy.isLoggingMethod(methodName)) return exp;
-
-                return loggingStrategy.wrapLoggingMethodCall(variableExpression, methodName, exp);
+                return loggingStrategy.wrapLoggingMethodCall(variableExpression, methodName, mce);
             }
 
             private boolean usesSimpleMethodArgumentsOnly(MethodCallExpression mce) {

http://git-wip-us.apache.org/repos/asf/groovy/blob/e96a9619/src/test/groovy/bugs/Groovy8060Bug.groovy
----------------------------------------------------------------------
diff --git a/src/test/groovy/bugs/Groovy8060Bug.groovy b/src/test/groovy/bugs/Groovy8060Bug.groovy
new file mode 100644
index 0000000..741929b
--- /dev/null
+++ b/src/test/groovy/bugs/Groovy8060Bug.groovy
@@ -0,0 +1,39 @@
+/*
+ *  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 Groovy8060Bug extends GroovyTestCase {
+    void testLoggingWithinClosuresThatAreMethodArgsShouldHaveGuards() {
+        assertScript '''
+            @Grab('org.slf4j:slf4j-simple:1.7.21')
+            import groovy.util.logging.Slf4j
+
+            @Slf4j
+            class LogMain {
+                public static int count = 0
+
+                static void main(args) {
+                    assert !log.isTraceEnabled()
+                    1.times { log.trace("${count++}") }
+                    assert !count
+                }
+            }
+        '''
+    }
+}


[07/10] groovy git commit: Merge branch 'groovy8065'

Posted by su...@apache.org.
Merge branch 'groovy8065'


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

Branch: refs/heads/parrot
Commit: 4308f2aaebd5b6ec51245ff043b572c8b7b9a5a9
Parents: 636ef87 1358ed5
Author: paulk <pa...@asert.com.au>
Authored: Sat Jan 28 13:22:32 2017 +1000
Committer: paulk <pa...@asert.com.au>
Committed: Sat Jan 28 13:22:32 2017 +1000

----------------------------------------------------------------------
 src/main/groovy/lang/MetaClassImpl.java   | 21 ++++++-----
 src/test/groovy/bugs/Groovy8065Bug.groovy | 48 ++++++++++++++++++++++++++
 2 files changed, 61 insertions(+), 8 deletions(-)
----------------------------------------------------------------------



[04/10] groovy git commit: Fix misprint in javadoc for href attribute (closes #481)

Posted by su...@apache.org.
Fix misprint in javadoc for href attribute (closes #481)

See RFC-2368 (https://tools.ietf.org/html/rfc2368).
The right scheme for  mailtoURL  is  "mailto:" [ to ] [ headers ]


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

Branch: refs/heads/parrot
Commit: 11c37114d740efd5223814cf7e6758a98e83e4de
Parents: 186e77e
Author: Alykoff <ga...@yandex.kz>
Authored: Thu Jan 26 22:52:04 2017 +0300
Committer: paulk <pa...@asert.com.au>
Committed: Fri Jan 27 15:21:03 2017 +1000

----------------------------------------------------------------------
 src/main/org/codehaus/groovy/ast/ASTNode.java | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/groovy/blob/11c37114/src/main/org/codehaus/groovy/ast/ASTNode.java
----------------------------------------------------------------------
diff --git a/src/main/org/codehaus/groovy/ast/ASTNode.java b/src/main/org/codehaus/groovy/ast/ASTNode.java
index c6d238d..058af78 100644
--- a/src/main/org/codehaus/groovy/ast/ASTNode.java
+++ b/src/main/org/codehaus/groovy/ast/ASTNode.java
@@ -44,7 +44,7 @@ import java.util.Map;
  * </ul>
  *
  * @author <a href="mailto:james@coredevelopers.net">James Strachan</a>
- * @author <a href="maito:blackdrag@gmx.org">Jochen "blackdrag" Theodorou</a>
+ * @author <a href="mailto:blackdrag@gmx.org">Jochen "blackdrag" Theodorou</a>
  */
 public class ASTNode {
 


[05/10] groovy git commit: GROOVY-8066: protected fields should be disallowed in traits (closes #482)

Posted by su...@apache.org.
GROOVY-8066: protected fields should be disallowed in traits (closes #482)


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

Branch: refs/heads/parrot
Commit: 636ef871bc8f8d201d1571e7beb135ee28f3fa16
Parents: 11c3711
Author: paulk <pa...@asert.com.au>
Authored: Fri Jan 27 12:52:47 2017 +1000
Committer: paulk <pa...@asert.com.au>
Committed: Fri Jan 27 17:21:06 2017 +1000

----------------------------------------------------------------------
 .../transform/trait/TraitASTTransformation.java |  6 ++++
 src/test/groovy/bugs/Groovy8066Bug.groovy       | 33 ++++++++++++++++++++
 2 files changed, 39 insertions(+)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/groovy/blob/636ef871/src/main/org/codehaus/groovy/transform/trait/TraitASTTransformation.java
----------------------------------------------------------------------
diff --git a/src/main/org/codehaus/groovy/transform/trait/TraitASTTransformation.java b/src/main/org/codehaus/groovy/transform/trait/TraitASTTransformation.java
index 6e852ce..f91ab4e 100644
--- a/src/main/org/codehaus/groovy/transform/trait/TraitASTTransformation.java
+++ b/src/main/org/codehaus/groovy/transform/trait/TraitASTTransformation.java
@@ -386,6 +386,12 @@ public class TraitASTTransformation extends AbstractASTTransformation implements
 
 
     private void processField(final FieldNode field, final MethodNode initializer, final MethodNode staticInitializer, final ClassNode fieldHelper, final ClassNode trait, final Set<String> knownFields) {
+        if (field.isProtected()) {
+            unit.addError(new SyntaxException("Cannot have protected field in a trait (" + trait.getName() + "#" + field.getName() + ")",
+                    field.getLineNumber(), field.getColumnNumber()));
+            return;
+        }
+
         Expression initialExpression = field.getInitialExpression();
         MethodNode selectedMethod = field.isStatic()?staticInitializer:initializer;
         if (initialExpression != null && !field.isFinal()) {

http://git-wip-us.apache.org/repos/asf/groovy/blob/636ef871/src/test/groovy/bugs/Groovy8066Bug.groovy
----------------------------------------------------------------------
diff --git a/src/test/groovy/bugs/Groovy8066Bug.groovy b/src/test/groovy/bugs/Groovy8066Bug.groovy
new file mode 100644
index 0000000..3d5520f
--- /dev/null
+++ b/src/test/groovy/bugs/Groovy8066Bug.groovy
@@ -0,0 +1,33 @@
+/*
+ *  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
+
+import gls.CompilableTestSupport
+
+class Groovy8066Bug extends CompilableTestSupport {
+    void testTraitWithProtectedFieldShouldGiveCompileError() {
+        def message = shouldNotCompile """
+            trait Foo {
+                protected String bar
+            }
+            class Baz implements Foo { }
+        """
+        assert message.contains('Cannot have protected field in a trait')
+    }
+}


[08/10] groovy git commit: javadoc typo

Posted by su...@apache.org.
javadoc typo


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

Branch: refs/heads/parrot
Commit: cb2e2c2c36f40c35eedcc951305c95e3986c8d56
Parents: 4308f2a
Author: paulk <pa...@asert.com.au>
Authored: Sat Jan 28 15:39:06 2017 +1000
Committer: paulk <pa...@asert.com.au>
Committed: Sat Jan 28 15:39:06 2017 +1000

----------------------------------------------------------------------
 .../codehaus/groovy/classgen/asm/sc/StaticTypesCallSiteWriter.java | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/groovy/blob/cb2e2c2c/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 a2900b4..c34be18 100644
--- a/src/main/org/codehaus/groovy/classgen/asm/sc/StaticTypesCallSiteWriter.java
+++ b/src/main/org/codehaus/groovy/classgen/asm/sc/StaticTypesCallSiteWriter.java
@@ -629,7 +629,7 @@ public class StaticTypesCallSiteWriter extends CallSiteWriter implements Opcodes
         if (trySubscript(receiver, message, arguments, rType, aType)) {
             return;
         }
-        // new try with flow type instead of declaration type
+        // now try with flow type instead of declaration type
         rType = receiver.getNodeMetaData(StaticTypesMarker.INFERRED_TYPE);
         if (rType!=null && trySubscript(receiver, message, arguments, rType, aType)) {
             return;


[03/10] groovy git commit: GROOVY-8023: removing empty method

Posted by su...@apache.org.
GROOVY-8023: removing empty method


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

Branch: refs/heads/parrot
Commit: 186e77eb1250f0a9c67f98d02cf2c94732b1b506
Parents: d3dd694
Author: Jochen Theodorou <bl...@gmx.org>
Authored: Thu Jan 26 21:03:42 2017 +0100
Committer: Jochen Theodorou <bl...@gmx.org>
Committed: Thu Jan 26 21:03:42 2017 +0100

----------------------------------------------------------------------
 .../transform/trait/SuperCallTraitTransformer.java      | 12 ------------
 1 file changed, 12 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/groovy/blob/186e77eb/src/main/org/codehaus/groovy/transform/trait/SuperCallTraitTransformer.java
----------------------------------------------------------------------
diff --git a/src/main/org/codehaus/groovy/transform/trait/SuperCallTraitTransformer.java b/src/main/org/codehaus/groovy/transform/trait/SuperCallTraitTransformer.java
index 6ebc5f2..f3d35d8 100644
--- a/src/main/org/codehaus/groovy/transform/trait/SuperCallTraitTransformer.java
+++ b/src/main/org/codehaus/groovy/transform/trait/SuperCallTraitTransformer.java
@@ -141,18 +141,6 @@ class SuperCallTraitTransformer extends ClassCodeExpressionTransformer {
         return super.transform(exp);
     }
 
-    private Expression transformPropertyExpression(final PropertyExpression expression) {
-        Expression objectExpression = expression.getObjectExpression();
-        ClassNode type = objectExpression.getType();
-        if (objectExpression instanceof ClassExpression) {
-            if (Traits.isTrait(type) && "super".equals(expression.getPropertyAsString())) {
-                // SomeTrait.super --> annotate to recognize later
-                expression.putNodeMetaData(SuperCallTraitTransformer.class, type);
-            }
-        }
-        return super.transform(expression);
-    }
-
     private boolean isTraitSuperPropertyExpression(Expression exp) {
         if (exp instanceof PropertyExpression) {
             PropertyExpression pexp = (PropertyExpression) exp;


[02/10] groovy git commit: GROOVY-8023: changing O(n^2) time complexity of transformMethodCall in SuperCallTraitTransformer to O(n)

Posted by su...@apache.org.
GROOVY-8023: changing O(n^2) time complexity of transformMethodCall in SuperCallTraitTransformer to O(n)


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

Branch: refs/heads/parrot
Commit: d3dd694969e85050b2b127280ad5ca7dcdfd2180
Parents: e96a961
Author: Jochen Theodorou <bl...@gmx.org>
Authored: Thu Jan 26 21:01:35 2017 +0100
Committer: Jochen Theodorou <bl...@gmx.org>
Committed: Thu Jan 26 21:01:35 2017 +0100

----------------------------------------------------------------------
 .../trait/SuperCallTraitTransformer.java        | 40 ++++++++++++++------
 .../codehaus/groovy/transform/trait/Traits.java |  2 +-
 2 files changed, 29 insertions(+), 13 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/groovy/blob/d3dd6949/src/main/org/codehaus/groovy/transform/trait/SuperCallTraitTransformer.java
----------------------------------------------------------------------
diff --git a/src/main/org/codehaus/groovy/transform/trait/SuperCallTraitTransformer.java b/src/main/org/codehaus/groovy/transform/trait/SuperCallTraitTransformer.java
index e403a2c..6ebc5f2 100644
--- a/src/main/org/codehaus/groovy/transform/trait/SuperCallTraitTransformer.java
+++ b/src/main/org/codehaus/groovy/transform/trait/SuperCallTraitTransformer.java
@@ -19,6 +19,7 @@
 package org.codehaus.groovy.transform.trait;
 
 import groovy.lang.MetaProperty;
+import java.util.List;
 import org.codehaus.groovy.ast.ClassCodeExpressionTransformer;
 import org.codehaus.groovy.ast.ClassNode;
 import org.codehaus.groovy.ast.MethodNode;
@@ -34,8 +35,6 @@ import org.codehaus.groovy.ast.expr.VariableExpression;
 import org.codehaus.groovy.control.SourceUnit;
 import org.codehaus.groovy.syntax.Types;
 
-import java.util.List;
-
 /**
  * This transformer is used to transform calls to <code>SomeTrait.super.foo()</code> into the appropriate trait call.
  *
@@ -56,9 +55,6 @@ class SuperCallTraitTransformer extends ClassCodeExpressionTransformer {
 
     @Override
     public Expression transform(final Expression exp) {
-        if (exp instanceof PropertyExpression) {
-            return transformPropertyExpression((PropertyExpression) exp);
-        }
         if (exp instanceof MethodCallExpression) {
             return transformMethodCallExpression((MethodCallExpression)exp);
         }
@@ -74,12 +70,17 @@ class SuperCallTraitTransformer extends ClassCodeExpressionTransformer {
             BinaryExpression bin = (BinaryExpression) trn;
             Expression leftExpression = bin.getLeftExpression();
             if (bin.getOperation().getType() == Types.EQUAL && leftExpression instanceof PropertyExpression) {
-                ClassNode traitReceiver = ((PropertyExpression) leftExpression).getObjectExpression().getNodeMetaData(SuperCallTraitTransformer.class);
+                ClassNode traitReceiver = null;
+                PropertyExpression leftPropertyExpression = (PropertyExpression) leftExpression;
+                if (isTraitSuperPropertyExpression(leftPropertyExpression.getObjectExpression())) {
+                    PropertyExpression pexp = (PropertyExpression) leftPropertyExpression.getObjectExpression();
+                    traitReceiver = pexp.getObjectExpression().getType();
+                }
                 if (traitReceiver!=null) {
                     // A.super.foo = ...
                     TraitHelpersTuple helpers = Traits.findHelpers(traitReceiver);
                     ClassNode helper = helpers.getHelper();
-                    String setterName = MetaProperty.getSetterName(((PropertyExpression) leftExpression).getPropertyAsString());
+                    String setterName = MetaProperty.getSetterName(leftPropertyExpression.getPropertyAsString());
                     List<MethodNode> methods = helper.getMethods(setterName);
                     for (MethodNode method : methods) {
                         Parameter[] parameters = method.getParameters();
@@ -106,9 +107,10 @@ class SuperCallTraitTransformer extends ClassCodeExpressionTransformer {
     }
 
     private Expression transformMethodCallExpression(final MethodCallExpression exp) {
-        Expression objectExpression = transform(exp.getObjectExpression());
-        ClassNode traitReceiver = objectExpression.getNodeMetaData(SuperCallTraitTransformer.class);
-        if (traitReceiver!=null) {
+        if (isTraitSuperPropertyExpression(exp.getObjectExpression())) {
+            Expression objectExpression = exp.getObjectExpression();
+            ClassNode traitReceiver = ((PropertyExpression) objectExpression).getObjectExpression().getType();
+
             TraitHelpersTuple helpers = Traits.findHelpers(traitReceiver);
             // (SomeTrait.super).foo() --> SomeTrait$Helper.foo(this)
             ClassExpression receiver = new ClassExpression(
@@ -123,11 +125,11 @@ class SuperCallTraitTransformer extends ClassCodeExpressionTransformer {
                     newArgs.addExpression(transform(expression));
                 }
             } else {
-                newArgs.addExpression(arguments);
+                newArgs.addExpression(transform(arguments));
             }
             MethodCallExpression result = new MethodCallExpression(
                     receiver,
-                    exp.getMethod(),
+                    transform(exp.getMethod()),
                     newArgs
             );
             result.setImplicitThis(false);
@@ -150,4 +152,18 @@ class SuperCallTraitTransformer extends ClassCodeExpressionTransformer {
         }
         return super.transform(expression);
     }
+
+    private boolean isTraitSuperPropertyExpression(Expression exp) {
+        if (exp instanceof PropertyExpression) {
+            PropertyExpression pexp = (PropertyExpression) exp;
+            Expression objectExpression = pexp.getObjectExpression();
+            if (objectExpression instanceof ClassExpression) {
+                ClassNode type = objectExpression.getType();
+                if (Traits.isTrait(type) && "super".equals(pexp.getPropertyAsString())) {
+                    return true;
+                }
+            }
+        }
+        return false;
+    }
 }

http://git-wip-us.apache.org/repos/asf/groovy/blob/d3dd6949/src/main/org/codehaus/groovy/transform/trait/Traits.java
----------------------------------------------------------------------
diff --git a/src/main/org/codehaus/groovy/transform/trait/Traits.java b/src/main/org/codehaus/groovy/transform/trait/Traits.java
index 4a0ac91..b1c9537 100644
--- a/src/main/org/codehaus/groovy/transform/trait/Traits.java
+++ b/src/main/org/codehaus/groovy/transform/trait/Traits.java
@@ -136,7 +136,7 @@ public abstract class Traits {
             try {
                 final ClassLoader classLoader = trait.getTypeClass().getClassLoader();
                 String helperClassName = Traits.helperClassName(trait);
-                helperClassNode = ClassHelper.make(classLoader.loadClass(helperClassName));
+                helperClassNode = ClassHelper.make(Class.forName(helperClassName, false, classLoader));
                 try {
                     fieldHelperClassNode = ClassHelper.make(classLoader.loadClass(Traits.fieldHelperClassName(trait)));
                 } catch (ClassNotFoundException e) {


[10/10] 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/5392eb4f
Tree: http://git-wip-us.apache.org/repos/asf/groovy/tree/5392eb4f
Diff: http://git-wip-us.apache.org/repos/asf/groovy/diff/5392eb4f

Branch: refs/heads/parrot
Commit: 5392eb4fa0970fb7036fc2730ec5f177af278039
Parents: a033231 84462bb
Author: sunlan <su...@apache.org>
Authored: Sun Jan 29 00:07:35 2017 +0800
Committer: sunlan <su...@apache.org>
Committed: Sun Jan 29 00:07:35 2017 +0800

----------------------------------------------------------------------
 src/main/groovy/lang/MetaClassImpl.java         | 21 +++++----
 .../groovy/antlr/AntlrParserPlugin.java         | 19 +++++++-
 src/main/org/codehaus/groovy/ast/ASTNode.java   |  2 +-
 .../asm/sc/StaticTypesCallSiteWriter.java       |  2 +-
 .../groovy/transform/LogASTTransformation.java  | 24 ++++++----
 .../trait/SuperCallTraitTransformer.java        | 44 ++++++++++--------
 .../transform/trait/TraitASTTransformation.java |  6 +++
 .../codehaus/groovy/transform/trait/Traits.java |  2 +-
 src/test/groovy/bugs/Groovy5318Bug.groovy       | 30 ++++++++++++
 src/test/groovy/bugs/Groovy8060Bug.groovy       | 39 ++++++++++++++++
 src/test/groovy/bugs/Groovy8065Bug.groovy       | 48 ++++++++++++++++++++
 src/test/groovy/bugs/Groovy8066Bug.groovy       | 33 ++++++++++++++
 12 files changed, 229 insertions(+), 41 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/groovy/blob/5392eb4f/src/main/groovy/lang/MetaClassImpl.java
----------------------------------------------------------------------

http://git-wip-us.apache.org/repos/asf/groovy/blob/5392eb4f/src/main/org/codehaus/groovy/classgen/asm/sc/StaticTypesCallSiteWriter.java
----------------------------------------------------------------------
diff --cc src/main/org/codehaus/groovy/classgen/asm/sc/StaticTypesCallSiteWriter.java
index a1d18bf,c34be18..37bfe88
--- a/src/main/org/codehaus/groovy/classgen/asm/sc/StaticTypesCallSiteWriter.java
+++ b/src/main/org/codehaus/groovy/classgen/asm/sc/StaticTypesCallSiteWriter.java
@@@ -627,12 -626,12 +627,12 @@@ public class StaticTypesCallSiteWriter 
          ClassNode classNode = controller.getClassNode();
          ClassNode rType = typeChooser.resolveType(receiver, classNode);
          ClassNode aType = typeChooser.resolveType(arguments, classNode);
 -        if (trySubscript(receiver, message, arguments, rType, aType)) {
 +        if (trySubscript(receiver, message, arguments, rType, aType, safe)) {
              return;
          }
-         // new try with flow type instead of declaration type
+         // now try with flow type instead of declaration type
          rType = receiver.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


[06/10] groovy git commit: GROOVY-8065: Map created as org.springframework.http.HttpHeaders is empty in 2.4.8, works fine in 2.4.7 (closes #480)

Posted by su...@apache.org.
GROOVY-8065: Map created as org.springframework.http.HttpHeaders is empty in 2.4.8, works fine in 2.4.7 (closes #480)


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

Branch: refs/heads/parrot
Commit: 1358ed58af0df10a959924816310f8f1c020aa50
Parents: e96a961
Author: paulk <pa...@asert.com.au>
Authored: Thu Jan 26 23:51:32 2017 +1000
Committer: paulk <pa...@asert.com.au>
Committed: Sat Jan 28 08:46:13 2017 +1000

----------------------------------------------------------------------
 src/main/groovy/lang/MetaClassImpl.java   | 21 ++++++-----
 src/test/groovy/bugs/Groovy8065Bug.groovy | 48 ++++++++++++++++++++++++++
 2 files changed, 61 insertions(+), 8 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/groovy/blob/1358ed58/src/main/groovy/lang/MetaClassImpl.java
----------------------------------------------------------------------
diff --git a/src/main/groovy/lang/MetaClassImpl.java b/src/main/groovy/lang/MetaClassImpl.java
index d7d8d9b..93c013b 100644
--- a/src/main/groovy/lang/MetaClassImpl.java
+++ b/src/main/groovy/lang/MetaClassImpl.java
@@ -2686,18 +2686,15 @@ public class MetaClassImpl implements MetaClass, MutableMetaClass {
         }
 
         //----------------------------------------------------------------------
-        // turn setProperty on a Map to put on the Map itself
-        //----------------------------------------------------------------------
-        if (method == null && !isStatic && this.isMap) {
-            ((Map) object).put(name, newValue);
-            return;
-        }
-
-        //----------------------------------------------------------------------
         // field
         //----------------------------------------------------------------------
         if (method == null && field != null) {
             if (Modifier.isFinal(field.getModifiers())) {
+                // GROOVY-5985
+                if (!isStatic && this.isMap) {
+                    ((Map) object).put(name, newValue);
+                    return;
+                }
                 throw new ReadOnlyPropertyException(name, theClass);
             }
             if(!(this.isMap && isPrivateOrPkgPrivate(field.getModifiers()))) {
@@ -2742,6 +2739,14 @@ public class MetaClassImpl implements MetaClass, MutableMetaClass {
         }
 
         //----------------------------------------------------------------------
+        // turn setProperty on a Map to put on the Map itself
+        //----------------------------------------------------------------------
+        if (method == null && !isStatic && this.isMap) {
+            ((Map) object).put(name, newValue);
+            return;
+        }
+
+        //----------------------------------------------------------------------
         // error due to missing method/field
         //----------------------------------------------------------------------
         if (ambiguousListener) {

http://git-wip-us.apache.org/repos/asf/groovy/blob/1358ed58/src/test/groovy/bugs/Groovy8065Bug.groovy
----------------------------------------------------------------------
diff --git a/src/test/groovy/bugs/Groovy8065Bug.groovy b/src/test/groovy/bugs/Groovy8065Bug.groovy
new file mode 100644
index 0000000..5c3f018
--- /dev/null
+++ b/src/test/groovy/bugs/Groovy8065Bug.groovy
@@ -0,0 +1,48 @@
+/*
+ *  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 Groovy8065Bug extends GroovyTestCase {
+    void testMapWithCustomSetDuringAsTypeCast() {
+        assertScript '''
+            class MapWithSet extends LinkedHashMap {
+                void set(String k, String v) {
+                    put(k.toLowerCase(), v.toUpperCase())
+                }
+            }
+            def m = [Foo: 'Bar'] as MapWithSet
+            assert m == [foo: 'BAR']
+        '''
+    }
+
+    void testMapWithPublicField() {
+        assertScript '''
+            class A extends HashMap {
+                public foo
+            }
+            def a = new A()
+            a.x = 1
+            assert a.x == 1
+            a.foo = 2
+            assert a.@foo == 2
+            assert a.foo == null
+            assert a == [x:1]
+        '''
+    }
+}


[09/10] groovy git commit: GROOVY-5318: generic types in fully-qualified class names parsing error (closes #479)

Posted by su...@apache.org.
GROOVY-5318: generic types in fully-qualified class names parsing error (closes #479)


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

Branch: refs/heads/parrot
Commit: 84462bb563b0c1c0faf1ef0af623561e60c557e7
Parents: cb2e2c2
Author: paulk <pa...@asert.com.au>
Authored: Wed Jan 25 21:15:17 2017 +1000
Committer: paulk <pa...@asert.com.au>
Committed: Sat Jan 28 17:03:06 2017 +1000

----------------------------------------------------------------------
 .../groovy/antlr/AntlrParserPlugin.java         | 19 ++++++++++++-
 src/test/groovy/bugs/Groovy5318Bug.groovy       | 30 ++++++++++++++++++++
 2 files changed, 48 insertions(+), 1 deletion(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/groovy/blob/84462bb5/src/main/org/codehaus/groovy/antlr/AntlrParserPlugin.java
----------------------------------------------------------------------
diff --git a/src/main/org/codehaus/groovy/antlr/AntlrParserPlugin.java b/src/main/org/codehaus/groovy/antlr/AntlrParserPlugin.java
index 28a0395..6cacbfd 100644
--- a/src/main/org/codehaus/groovy/antlr/AntlrParserPlugin.java
+++ b/src/main/org/codehaus/groovy/antlr/AntlrParserPlugin.java
@@ -2907,13 +2907,14 @@ public class AntlrParserPlugin extends ASTHelper implements ParserPlugin, Groovy
             StringBuilder buffer = new StringBuilder();
             boolean first = true;
 
-            for (; node != null && !isType(TYPE_ARGUMENTS, node); node = node.getNextSibling()) {
+            while (node != null && !isType(TYPE_ARGUMENTS, node)) {
                 if (first) {
                     first = false;
                 } else {
                     buffer.append(".");
                 }
                 buffer.append(qualifiedName(node));
+                node = node.getNextSibling();
             }
             return buffer.toString();
         } else {
@@ -3038,6 +3039,7 @@ public class AntlrParserPlugin extends ASTHelper implements ParserPlugin, Groovy
             if (isType(INDEX_OP, node) || isType(ARRAY_DECLARATOR, node)) {
                 answer = makeType(node).makeArray();
             } else {
+                checkTypeArgs(node, false);
                 answer = ClassHelper.make(qualifiedName(node));
                 if (answer.isUsingGenerics()) {
                     ClassNode newAnswer = ClassHelper.makeWithoutCaching(answer.getName());
@@ -3050,6 +3052,21 @@ public class AntlrParserPlugin extends ASTHelper implements ParserPlugin, Groovy
         return answer;
     }
 
+    private boolean checkTypeArgs(AST node, boolean seenTypeArgs) {
+        if (isType(IDENT, node) && seenTypeArgs) {
+            throw new ASTRuntimeException(node, "Unexpected type arguments found prior to: " + qualifiedName(node));
+        }
+        if (isType(DOT, node)) {
+            AST next = node.getFirstChild();
+            while (next != null && !isType(TYPE_ARGUMENTS, next)) {
+                seenTypeArgs |= checkTypeArgs(next, seenTypeArgs);
+                seenTypeArgs |= isType(TYPE_ARGUMENTS, next.getFirstChild()) || isType(TYPE_ARGUMENTS, next.getNextSibling());
+                next = next.getNextSibling();
+            }
+        }
+        return seenTypeArgs;
+    }
+
     /**
      * Performs a name resolution to see if the given name is a type from imports,
      * aliases or newly created classes

http://git-wip-us.apache.org/repos/asf/groovy/blob/84462bb5/src/test/groovy/bugs/Groovy5318Bug.groovy
----------------------------------------------------------------------
diff --git a/src/test/groovy/bugs/Groovy5318Bug.groovy b/src/test/groovy/bugs/Groovy5318Bug.groovy
new file mode 100644
index 0000000..819dd58
--- /dev/null
+++ b/src/test/groovy/bugs/Groovy5318Bug.groovy
@@ -0,0 +1,30 @@
+/*
+ *  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
+
+import gls.CompilableTestSupport
+
+class Groovy5318Bug extends CompilableTestSupport {
+    void testTypeArgumentsOnlyOnTheLastComponent() {
+        def message = shouldNotCompile """
+            def a = new java.util<Integer>.ArrayList<ArrayList<Integer>>()
+        """
+        assert message.contains('Unexpected type arguments found prior to: ArrayList')
+    }
+}