groovy-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From pa...@apache.org
Subject [1/3] groovy git commit: GROOVY-6245: @EqualsAndHashCode assumes get style getters for boolean properties (closes #379)
Date Sat, 06 Aug 2016 00:08:09 GMT
Repository: groovy
Updated Branches:
  refs/heads/master d96e370f4 -> 457c82fa0


GROOVY-6245: @EqualsAndHashCode assumes get style getters for boolean properties (closes #379)


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

Branch: refs/heads/master
Commit: 1fa296acbf581fdb70dcabfe337db359219169c7
Parents: d96e370
Author: paulk <paulk@asert.com.au>
Authored: Fri Aug 5 19:22:31 2016 +1000
Committer: paulk <paulk@asert.com.au>
Committed: Fri Aug 5 19:33:56 2016 +1000

----------------------------------------------------------------------
 .../org/codehaus/groovy/ast/tools/GeneralUtils.java |  9 ++-------
 .../transform/EqualsAndHashCodeTransformTest.groovy | 16 ++++++++++++++++
 2 files changed, 18 insertions(+), 7 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/groovy/blob/1fa296ac/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 2d59447..ba9bb0e 100644
--- a/src/main/org/codehaus/groovy/ast/tools/GeneralUtils.java
+++ b/src/main/org/codehaus/groovy/ast/tools/GeneralUtils.java
@@ -72,11 +72,6 @@ import java.util.Set;
 
 /**
  * Handy methods when working with the Groovy AST
- *
- * @author Guillaume Laforge
- * @author Paul King
- * @author Andre Steingress
- * @author Graeme Rocher
  */
 public class GeneralUtils {
     public static final Token ASSIGN = Token.newSymbol(Types.ASSIGN, -1, -1);
@@ -506,8 +501,8 @@ public class GeneralUtils {
     }
 
     public static BooleanExpression hasSamePropertyX(PropertyNode pNode, Expression other)
{
-        String getterName = getGetterName(pNode);
-        return sameX(callThisX(getterName), callX(other, getterName));
+        ClassNode cNode = pNode.getDeclaringClass();
+        return sameX(getterThisX(cNode, pNode), getterX(cNode, other, pNode));
     }
 
     public static Statement ifElseS(Expression cond, Statement thenStmt, Statement elseStmt)
{

http://git-wip-us.apache.org/repos/asf/groovy/blob/1fa296ac/src/test/org/codehaus/groovy/transform/EqualsAndHashCodeTransformTest.groovy
----------------------------------------------------------------------
diff --git a/src/test/org/codehaus/groovy/transform/EqualsAndHashCodeTransformTest.groovy
b/src/test/org/codehaus/groovy/transform/EqualsAndHashCodeTransformTest.groovy
index 4f189b0..1e9e3c9 100644
--- a/src/test/org/codehaus/groovy/transform/EqualsAndHashCodeTransformTest.groovy
+++ b/src/test/org/codehaus/groovy/transform/EqualsAndHashCodeTransformTest.groovy
@@ -103,4 +103,20 @@ class EqualsAndHashCodeTransformTest extends GroovyShellTestCase {
         '''
     }
 
+    void testPrimitiveBooleanPropertiesWithIsGetter_GROOVY6245() {
+        assertScript '''
+            @groovy.transform.EqualsAndHashCode
+            class A {
+                boolean a
+                boolean isA() { a }
+            }
+
+            def a1 = new A(a: true)
+            def a2 = new A(a: true)
+            def a3 = new A(a: false)
+            assert a1 == a2
+            assert a1 != a3
+        '''
+    }
+
 }
\ No newline at end of file


Mime
View raw message