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

[1/3] groovy git commit: refactor: remove invalid comment

Repository: groovy
Updated Branches:
  refs/heads/master 9ad1b2937 -> 891c35f28


refactor: remove invalid comment

Comment refers to code that has since been changed and is no longer valid.


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

Branch: refs/heads/master
Commit: faf1eced1e624b2035d7edeba13ec5c2959384c6
Parents: 9ad1b29
Author: John Wagenleitner <jw...@apache.org>
Authored: Sat Aug 5 10:24:45 2017 -0700
Committer: John Wagenleitner <jw...@apache.org>
Committed: Sat Aug 5 14:15:13 2017 -0700

----------------------------------------------------------------------
 src/main/org/codehaus/groovy/ast/GenericsType.java | 2 --
 1 file changed, 2 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/groovy/blob/faf1eced/src/main/org/codehaus/groovy/ast/GenericsType.java
----------------------------------------------------------------------
diff --git a/src/main/org/codehaus/groovy/ast/GenericsType.java b/src/main/org/codehaus/groovy/ast/GenericsType.java
index 3494b33..3b8427a 100644
--- a/src/main/org/codehaus/groovy/ast/GenericsType.java
+++ b/src/main/org/codehaus/groovy/ast/GenericsType.java
@@ -377,8 +377,6 @@ public class GenericsType extends ASTNode {
             for (int i = 0; redirectBoundGenericTypes!=null && i < redirectBoundGenericTypes.length && match; i++) {
                 GenericsType redirectBoundType = redirectBoundGenericTypes[i];
                 GenericsType classNodeType = cnTypes[i];
-                // The following code has been commented out because it causes GROOVY-5415
-                // However, commenting doesn't make any test fail, which is curious...
                 if (classNodeType.isPlaceholder()) {
                     String name = classNodeType.getName();
                     if (redirectBoundType.isPlaceholder()) {


[2/3] groovy git commit: GROOVY-8242: @Newify default attribute value (closes #579)

Posted by jw...@apache.org.
GROOVY-8242: @Newify default attribute value (closes #579)

Class values are only required for Python-style conversions so the
attribute should default to an empty array to indicate it is not
strictly required.


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

Branch: refs/heads/master
Commit: 51f929403509229eac6c9bc92400e4573cc1768a
Parents: faf1ece
Author: John Wagenleitner <jw...@apache.org>
Authored: Sat Aug 5 11:05:17 2017 -0700
Committer: John Wagenleitner <jw...@apache.org>
Committed: Sat Aug 5 14:15:40 2017 -0700

----------------------------------------------------------------------
 src/main/groovy/lang/Newify.java | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/groovy/blob/51f92940/src/main/groovy/lang/Newify.java
----------------------------------------------------------------------
diff --git a/src/main/groovy/lang/Newify.java b/src/main/groovy/lang/Newify.java
index 66edcde..5bf7fdf 100644
--- a/src/main/groovy/lang/Newify.java
+++ b/src/main/groovy/lang/Newify.java
@@ -28,7 +28,7 @@ import java.lang.annotation.Target;
 /**
  * Annotation that supports writing constructor call expressions without the 'new'
  * keyword. Instead they can be written "Ruby-style" as a method call to a 'new'
- * method or "Python-style" by just omitting the keyword missing.
+ * method or "Python-style" by just omitting the 'new' keyword.
  * <p>
  * It allows you to write code snippets like this ("Python-style"):
  * <pre>
@@ -100,7 +100,7 @@ import java.lang.annotation.Target;
 @Target({ElementType.CONSTRUCTOR, ElementType.METHOD, ElementType.TYPE, ElementType.FIELD, ElementType.LOCAL_VARIABLE})
 @GroovyASTTransformationClass("org.codehaus.groovy.transform.NewifyASTTransformation")
 public @interface Newify {
-    Class[] value();
+    Class<?>[] value() default {};
 
     /**
      * @return if automatic conversion of "Ruby-style" new method calls should occur


[3/3] groovy git commit: GROOVY-8245: @Newify(auto=false) not transforming declarations (closes #571)

Posted by jw...@apache.org.
GROOVY-8245: @Newify(auto=false) not transforming declarations (closes #571)


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

Branch: refs/heads/master
Commit: 891c35f28b0419e4080f222d1d8722351817b7f7
Parents: 51f9294
Author: John Wagenleitner <jw...@apache.org>
Authored: Sat Aug 5 11:15:04 2017 -0700
Committer: John Wagenleitner <jw...@apache.org>
Committed: Sat Aug 5 14:16:20 2017 -0700

----------------------------------------------------------------------
 .../transform/NewifyASTTransformation.java      | 10 ++++++++-
 .../groovy/transform/NewifyTransformTest.groovy | 22 ++++++++++++++++++++
 2 files changed, 31 insertions(+), 1 deletion(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/groovy/blob/891c35f2/src/main/org/codehaus/groovy/transform/NewifyASTTransformation.java
----------------------------------------------------------------------
diff --git a/src/main/org/codehaus/groovy/transform/NewifyASTTransformation.java b/src/main/org/codehaus/groovy/transform/NewifyASTTransformation.java
index 55ae7de..8c31449 100644
--- a/src/main/org/codehaus/groovy/transform/NewifyASTTransformation.java
+++ b/src/main/org/codehaus/groovy/transform/NewifyASTTransformation.java
@@ -178,7 +178,7 @@ public class NewifyASTTransformation extends ClassCodeExpressionTransformer impl
             }
         } else if (expr instanceof DeclarationExpression) {
             DeclarationExpression de = (DeclarationExpression) expr;
-            if (de == candidate || auto) {
+            if (shouldTransform(de)) {
                 candidate = null;
                 Expression left = de.getLeftExpression();
                 Expression right = transform(de.getRightExpression());
@@ -191,6 +191,14 @@ public class NewifyASTTransformation extends ClassCodeExpressionTransformer impl
         return expr.transformExpression(this);
     }
 
+    private boolean shouldTransform(DeclarationExpression exp) {
+        return exp == candidate || auto || hasClassesToNewify();
+    }
+
+    private boolean hasClassesToNewify() {
+        return classesToNewify != null && !classesToNewify.getExpressions().isEmpty();
+    }
+
     private void newifyClass(ClassNode cNode, boolean autoFlag, ListExpression list) {
         String cName = cNode.getName();
         if (cNode.isInterface()) {

http://git-wip-us.apache.org/repos/asf/groovy/blob/891c35f2/src/test/org/codehaus/groovy/transform/NewifyTransformTest.groovy
----------------------------------------------------------------------
diff --git a/src/test/org/codehaus/groovy/transform/NewifyTransformTest.groovy b/src/test/org/codehaus/groovy/transform/NewifyTransformTest.groovy
index e3e9890..d585c8a 100644
--- a/src/test/org/codehaus/groovy/transform/NewifyTransformTest.groovy
+++ b/src/test/org/codehaus/groovy/transform/NewifyTransformTest.groovy
@@ -189,4 +189,26 @@ class NewifyTransformTest extends GroovyShellTestCase {
             assert !new Z().foo()
         '''
     }
+
+    // GROOVY-8245
+    void testDeclarationWhenAutoIsFalse() {
+        assertScript '''
+            class Foo {
+                static int answer = 7
+                Foo() {
+                    answer = 42
+                }
+            }
+            @Newify(auto=false, value=Foo)
+            class Bar {
+                static {
+                    Foo foo = Foo()
+                }
+                static void method() {}
+            }
+            assert Foo.answer == 7
+            Bar.method()
+            assert Foo.answer == 42
+        '''
+    }
 }
\ No newline at end of file