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 2016/07/24 11:27:38 UTC

groovy git commit: GROOVY-7876: ClassCastException when calling DefaultTypeTransformation#compareEqual (minor refactor)

Repository: groovy
Updated Branches:
  refs/heads/master 2c226838e -> 0d86565c5


GROOVY-7876: ClassCastException when calling DefaultTypeTransformation#compareEqual (minor refactor)


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

Branch: refs/heads/master
Commit: 0d86565c503595965ce2ed697e87ddafe7c40491
Parents: 2c22683
Author: paulk <pa...@asert.com.au>
Authored: Sun Jul 24 21:27:16 2016 +1000
Committer: paulk <pa...@asert.com.au>
Committed: Sun Jul 24 21:27:16 2016 +1000

----------------------------------------------------------------------
 .../groovy/runtime/typehandling/DefaultTypeTransformation.java  | 5 ++++-
 1 file changed, 4 insertions(+), 1 deletion(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/groovy/blob/0d86565c/src/main/org/codehaus/groovy/runtime/typehandling/DefaultTypeTransformation.java
----------------------------------------------------------------------
diff --git a/src/main/org/codehaus/groovy/runtime/typehandling/DefaultTypeTransformation.java b/src/main/org/codehaus/groovy/runtime/typehandling/DefaultTypeTransformation.java
index 41484d8..94e0084 100644
--- a/src/main/org/codehaus/groovy/runtime/typehandling/DefaultTypeTransformation.java
+++ b/src/main/org/codehaus/groovy/runtime/typehandling/DefaultTypeTransformation.java
@@ -578,9 +578,12 @@ public class DefaultTypeTransformation {
             else if (left instanceof String && right instanceof GString) {
                 return ((String) left).compareTo(right.toString());
             }
+            else if (left instanceof GString && right instanceof String) {
+                return ((GString) left).compareTo(right);
+            }
             if (!equalityCheckOnly || left.getClass().isAssignableFrom(right.getClass())
                     || (right.getClass() != Object.class && right.getClass().isAssignableFrom(left.getClass())) //GROOVY-4046
-                    || (left instanceof GString && right instanceof String)) {
+            ) {
                 Comparable comparable = (Comparable) left;
                 // GROOVY-7876: when comparing for equality we try to only call compareTo when an assignable
                 // relationship holds but with a container/holder class and because of erasure, we might still end