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/05/02 04:21:36 UTC
groovy git commit: GROOVY-7820: CachedMethod.compareToCachedMethod
throws "Should never happen" (closes #315)
Repository: groovy
Updated Branches:
refs/heads/master cf8d2338e -> 78507b121
GROOVY-7820: CachedMethod.compareToCachedMethod throws "Should never happen" (closes #315)
Project: http://git-wip-us.apache.org/repos/asf/groovy/repo
Commit: http://git-wip-us.apache.org/repos/asf/groovy/commit/78507b12
Tree: http://git-wip-us.apache.org/repos/asf/groovy/tree/78507b12
Diff: http://git-wip-us.apache.org/repos/asf/groovy/diff/78507b12
Branch: refs/heads/master
Commit: 78507b121923f55d1cbb4a1f43d1a4c5c7e73b21
Parents: cf8d233
Author: paulk <pa...@asert.com.au>
Authored: Thu Apr 21 14:50:50 2016 +1000
Committer: paulk <pa...@asert.com.au>
Committed: Mon May 2 12:20:28 2016 +1000
----------------------------------------------------------------------
.../groovy/reflection/CachedMethod.java | 4 ++++
.../groovy/reflection/CachedMethodTest.groovy | 25 ++++++++++++++++++++
2 files changed, 29 insertions(+)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/groovy/blob/78507b12/src/main/org/codehaus/groovy/reflection/CachedMethod.java
----------------------------------------------------------------------
diff --git a/src/main/org/codehaus/groovy/reflection/CachedMethod.java b/src/main/org/codehaus/groovy/reflection/CachedMethod.java
index ff3176a..2e2fc29 100644
--- a/src/main/org/codehaus/groovy/reflection/CachedMethod.java
+++ b/src/main/org/codehaus/groovy/reflection/CachedMethod.java
@@ -167,6 +167,10 @@ public class CachedMethod extends MetaMethod implements Comparable {
return nameComp;
}
+ final int classComp = cachedClass.toString().compareTo(other.getDeclaringClass().toString());
+ if (classComp != 0)
+ return classComp;
+
throw new RuntimeException("Should never happen");
}
http://git-wip-us.apache.org/repos/asf/groovy/blob/78507b12/src/test/org/codehaus/groovy/reflection/CachedMethodTest.groovy
----------------------------------------------------------------------
diff --git a/src/test/org/codehaus/groovy/reflection/CachedMethodTest.groovy b/src/test/org/codehaus/groovy/reflection/CachedMethodTest.groovy
new file mode 100644
index 0000000..8af0915
--- /dev/null
+++ b/src/test/org/codehaus/groovy/reflection/CachedMethodTest.groovy
@@ -0,0 +1,25 @@
+/*
+ * 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 org.codehaus.groovy.reflection
+
+class CachedMethodTest extends GroovyTestCase {
+ void testCachedMethodCompareTo() {
+ assert String.metaClass.methods.size() == String.metaClass.methods.unique().size()
+ }
+}