You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@groovy.apache.org by pa...@apache.org on 2022/07/26 14:17:32 UTC
[groovy] branch master updated: GROOVY-10705: ToString order bug for super properties
This is an automated email from the ASF dual-hosted git repository.
paulk pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/groovy.git
The following commit(s) were added to refs/heads/master by this push:
new 5738c34892 GROOVY-10705: ToString order bug for super properties
5738c34892 is described below
commit 5738c34892ddf665a0c29150dae167d692480ad9
Author: Paul King <pa...@asert.com.au>
AuthorDate: Tue Jul 26 22:29:12 2022 +1000
GROOVY-10705: ToString order bug for super properties
---
.../java/org/codehaus/groovy/transform/ToStringASTTransformation.java | 4 ++--
src/test/org/codehaus/groovy/transform/ToStringTransformTest.groovy | 4 ++--
2 files changed, 4 insertions(+), 4 deletions(-)
diff --git a/src/main/java/org/codehaus/groovy/transform/ToStringASTTransformation.java b/src/main/java/org/codehaus/groovy/transform/ToStringASTTransformation.java
index 759201e10d..d2c966573d 100644
--- a/src/main/java/org/codehaus/groovy/transform/ToStringASTTransformation.java
+++ b/src/main/java/org/codehaus/groovy/transform/ToStringASTTransformation.java
@@ -225,13 +225,13 @@ public class ToStringASTTransformation extends AbstractASTTransformation {
body.addStatement(appendS(result, constX(className + delims[0])));
Set<String> names = new HashSet<>();
+ List<PropertyNode> list = getAllProperties(names, cNode, cNode, true, includeFields, allProperties, false, false, true, false, allNames, false);
List<PropertyNode> superList;
if (includeSuperProperties || includeSuperFields) {
superList = getAllProperties(names, cNode, cNode.getSuperClass(), includeSuperProperties, includeSuperFields, allProperties, false, true, true, true, allNames, false);
} else {
- superList = new ArrayList<PropertyNode>();
+ superList = new ArrayList<>();
}
- List<PropertyNode> list = getAllProperties(names, cNode, cNode,true, includeFields, allProperties, false, false, true, false, allNames, false);
list.addAll(superList);
for (PropertyNode pNode : list) {
diff --git a/src/test/org/codehaus/groovy/transform/ToStringTransformTest.groovy b/src/test/org/codehaus/groovy/transform/ToStringTransformTest.groovy
index 9625ab5cdf..f34b7c4357 100644
--- a/src/test/org/codehaus/groovy/transform/ToStringTransformTest.groovy
+++ b/src/test/org/codehaus/groovy/transform/ToStringTransformTest.groovy
@@ -269,7 +269,7 @@ class ToStringTransformTest extends GroovyShellTestCase {
}
new SportsPerson(first: 'John', last: 'Smith', title: 'Mr').toString()
''')
- assert toString == "SportsPerson(title:Mr, cyclist:true, full:John Smith, golfer:false, senior:false, born:1975, adult:true)"
+ assert toString == "SportsPerson(title:Mr, golfer:false, adult:true, cyclist:true, full:John Smith, senior:false, born:1975)"
// same again but with allProperties=false and with @CompileStatic for test coverage purposes
toString = evaluate('''
import groovy.transform.*
@@ -296,7 +296,7 @@ class ToStringTransformTest extends GroovyShellTestCase {
}
new SportsPerson(first: 'John', last: 'Smith', title: 'Mr').toString()
''')
- assert toString == "SportsPerson(title:Mr, adult:true, cyclist:true, golfer:false)"
+ assert toString == "SportsPerson(title:Mr, golfer:false, adult:true, cyclist:true)"
}
void testSelfReference() {