Quantcast

[1/3] groovy git commit: GROOVY-7879 Groovy calls wrong method if there is a static method on an interface

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
3 messages Options
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

[1/3] groovy git commit: GROOVY-7879 Groovy calls wrong method if there is a static method on an interface

paulk
Repository: groovy
Updated Branches:
  refs/heads/master 17c4ac2fd -> 57fb455f5


GROOVY-7879 Groovy calls wrong method if there is a static method on an interface


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

Branch: refs/heads/master
Commit: 076801660c75a985180413d8a792bd03da386438
Parents: 17c4ac2
Author: Dmitrii Kahmitov <[hidden email]>
Authored: Wed Apr 5 09:49:54 2017 +0300
Committer: paulk <[hidden email]>
Committed: Fri Apr 21 13:14:43 2017 +1000

----------------------------------------------------------------------
 .../runtime/metaclass/MetaMethodIndex.java      | 14 +++++--
 .../runtime/methoddispatching/BarOne.java       | 25 ++++++++++++
 .../runtime/methoddispatching/BarThree.java     | 25 ++++++++++++
 .../runtime/methoddispatching/BarTwo.java       | 25 ++++++++++++
 .../runtime/methoddispatching/FooOne.java       | 25 ++++++++++++
 .../runtime/methoddispatching/FooThree.java     | 33 +++++++++++++++
 .../runtime/methoddispatching/FooTwo.java       | 29 ++++++++++++++
 .../StaticMethodOverloadTest.groovy             | 42 ++++++++++++++++++++
 8 files changed, 214 insertions(+), 4 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/groovy/blob/07680166/src/main/org/codehaus/groovy/runtime/metaclass/MetaMethodIndex.java
----------------------------------------------------------------------
diff --git a/src/main/org/codehaus/groovy/runtime/metaclass/MetaMethodIndex.java b/src/main/org/codehaus/groovy/runtime/metaclass/MetaMethodIndex.java
index 0598f9a..c442e48 100644
--- a/src/main/org/codehaus/groovy/runtime/metaclass/MetaMethodIndex.java
+++ b/src/main/org/codehaus/groovy/runtime/metaclass/MetaMethodIndex.java
@@ -315,7 +315,7 @@ public class MetaMethodIndex {
         Object oldListOrMethod = e.methodsForSuper;
         if (oldListOrMethod == null)
           return;
-        
+
         if (oldListOrMethod instanceof FastArray) {
             FastArray oldList = (FastArray) oldListOrMethod;
             int len1 = oldList.size();
@@ -346,7 +346,7 @@ public class MetaMethodIndex {
         Object oldListOrMethod = from.methods;
         if (oldListOrMethod == null)
           return;
-        
+
         if (oldListOrMethod instanceof FastArray) {
             FastArray oldList = (FastArray) oldListOrMethod;
             Entry e = null;
@@ -381,7 +381,10 @@ public class MetaMethodIndex {
                 return list;
             } else {
                 if (match.isPrivate()
-                        || (!isNonRealMethod(match) && match.getDeclaringClass().isInterface() && !method.getDeclaringClass().isInterface())) {
+                        || (!isNonRealMethod(match)
+                            && match.getDeclaringClass().isInterface()
+                            && !method.getDeclaringClass().isInterface()
+                            && !method.isStatic())) {
                     // do not overwrite interface methods with instance methods
                     // do not overwrite private methods
                     // Note: private methods from parent classes are not shown here,
@@ -413,7 +416,10 @@ public class MetaMethodIndex {
                 MetaMethod match = (MetaMethod) list.get(found);
                 if (match==method) return o;
                 if (match.isPrivate()
-                        || (!isNonRealMethod(match) && match.getDeclaringClass().isInterface() && !method.getDeclaringClass().isInterface())) {
+                        || (!isNonRealMethod(match)
+                            && match.getDeclaringClass().isInterface()
+                            && !method.getDeclaringClass().isInterface()
+                            && !method.isStatic())) {
                     // do not overwrite interface methods with instance methods
                     // do not overwrite private methods
                     // Note: private methods from parent classes are not shown here,

http://git-wip-us.apache.org/repos/asf/groovy/blob/07680166/src/test/org/codehaus/groovy/runtime/methoddispatching/BarOne.java
----------------------------------------------------------------------
diff --git a/src/test/org/codehaus/groovy/runtime/methoddispatching/BarOne.java b/src/test/org/codehaus/groovy/runtime/methoddispatching/BarOne.java
new file mode 100644
index 0000000..56daeeb
--- /dev/null
+++ b/src/test/org/codehaus/groovy/runtime/methoddispatching/BarOne.java
@@ -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.runtime.methoddispatching;
+
+class BarOne implements FooOne {
+    static String foo() {
+        return "I'm Bar";
+    }
+}

http://git-wip-us.apache.org/repos/asf/groovy/blob/07680166/src/test/org/codehaus/groovy/runtime/methoddispatching/BarThree.java
----------------------------------------------------------------------
diff --git a/src/test/org/codehaus/groovy/runtime/methoddispatching/BarThree.java b/src/test/org/codehaus/groovy/runtime/methoddispatching/BarThree.java
new file mode 100644
index 0000000..63686b3
--- /dev/null
+++ b/src/test/org/codehaus/groovy/runtime/methoddispatching/BarThree.java
@@ -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.runtime.methoddispatching;
+
+class BarThree implements FooThree {
+    static String foo() {
+        return "I'm Bar";
+    }
+}

http://git-wip-us.apache.org/repos/asf/groovy/blob/07680166/src/test/org/codehaus/groovy/runtime/methoddispatching/BarTwo.java
----------------------------------------------------------------------
diff --git a/src/test/org/codehaus/groovy/runtime/methoddispatching/BarTwo.java b/src/test/org/codehaus/groovy/runtime/methoddispatching/BarTwo.java
new file mode 100644
index 0000000..84a8f02
--- /dev/null
+++ b/src/test/org/codehaus/groovy/runtime/methoddispatching/BarTwo.java
@@ -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.runtime.methoddispatching;
+
+class BarTwo implements FooTwo {
+    static String foo() {
+        return "I'm Bar";
+    }
+}

http://git-wip-us.apache.org/repos/asf/groovy/blob/07680166/src/test/org/codehaus/groovy/runtime/methoddispatching/FooOne.java
----------------------------------------------------------------------
diff --git a/src/test/org/codehaus/groovy/runtime/methoddispatching/FooOne.java b/src/test/org/codehaus/groovy/runtime/methoddispatching/FooOne.java
new file mode 100644
index 0000000..f1bac0f
--- /dev/null
+++ b/src/test/org/codehaus/groovy/runtime/methoddispatching/FooOne.java
@@ -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.runtime.methoddispatching;
+
+interface FooOne {
+    static String foo() {
+        return "I'm Foo";
+    }
+}
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/groovy/blob/07680166/src/test/org/codehaus/groovy/runtime/methoddispatching/FooThree.java
----------------------------------------------------------------------
diff --git a/src/test/org/codehaus/groovy/runtime/methoddispatching/FooThree.java b/src/test/org/codehaus/groovy/runtime/methoddispatching/FooThree.java
new file mode 100644
index 0000000..9f897ea
--- /dev/null
+++ b/src/test/org/codehaus/groovy/runtime/methoddispatching/FooThree.java
@@ -0,0 +1,33 @@
+/*
+ *  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.runtime.methoddispatching;
+
+interface FooThree {
+    static String foo() {
+        return "I'm Foo";
+    }
+
+    static String foo(int num) {
+        return String.valueOf(num);
+    }
+
+    static String foo(boolean bool) {
+        return String.valueOf(bool);
+    }
+}
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/groovy/blob/07680166/src/test/org/codehaus/groovy/runtime/methoddispatching/FooTwo.java
----------------------------------------------------------------------
diff --git a/src/test/org/codehaus/groovy/runtime/methoddispatching/FooTwo.java b/src/test/org/codehaus/groovy/runtime/methoddispatching/FooTwo.java
new file mode 100644
index 0000000..b7b315b
--- /dev/null
+++ b/src/test/org/codehaus/groovy/runtime/methoddispatching/FooTwo.java
@@ -0,0 +1,29 @@
+/*
+ *  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.runtime.methoddispatching;
+
+interface FooTwo {
+    static String foo() {
+        return "I'm Foo";
+    }
+
+    static String foo(int num) {
+        return String.valueOf(num);
+    }
+}
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/groovy/blob/07680166/src/test/org/codehaus/groovy/runtime/methoddispatching/StaticMethodOverloadTest.groovy
----------------------------------------------------------------------
diff --git a/src/test/org/codehaus/groovy/runtime/methoddispatching/StaticMethodOverloadTest.groovy b/src/test/org/codehaus/groovy/runtime/methoddispatching/StaticMethodOverloadTest.groovy
new file mode 100644
index 0000000..2df115f
--- /dev/null
+++ b/src/test/org/codehaus/groovy/runtime/methoddispatching/StaticMethodOverloadTest.groovy
@@ -0,0 +1,42 @@
+/*
+ *  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.runtime.methoddispatching
+
+class StaticMethodOverloadTest extends GroovyTestCase {
+    void testOneStaticMethod() throws Exception {
+        assert FooOne.foo() == "I'm Foo"
+        assert BarOne.foo() == "I'm Bar"
+    }
+
+    void testTwoStaticMethods() {
+        assert FooTwo.foo(42) == '42'
+        assert FooTwo.foo() == "I'm Foo"
+        assert BarTwo.foo(42) == '42'
+        assert BarTwo.foo() == "I'm Bar"
+    }
+
+    void testMoreThanTwoStaticMethods() {
+        assert FooThree.foo(42) == '42'
+        assert FooThree.foo() == "I'm Foo"
+        assert FooThree.foo(true) == 'true'
+        assert BarThree.foo(42) == '42'
+        assert BarThree.foo() == "I'm Bar"
+        assert BarThree.foo(true) == 'true'
+    }
+}

Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

[2/3] groovy git commit: GROOVY-7879 Groovy calls wrong method if there is a static method on an interface * @CompileStatic test cases added * Test with more than two methods changed so it's valid Java code (JLS8, 8.4.8 Inheritance, Overriding, and Hidin

paulk
GROOVY-7879 Groovy calls wrong method if there is a static method on an interface * @CompileStatic test cases added * Test with more than two methods changed so it's valid Java code (JLS8, 8.4.8 Inheritance, Overriding, and Hiding)


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

Branch: refs/heads/master
Commit: 840f6b65d9bc115ff149bbce79886c02f64c094e
Parents: 0768016
Author: Dmitrii Kahmitov <[hidden email]>
Authored: Sun Apr 9 00:18:47 2017 +0300
Committer: paulk <[hidden email]>
Committed: Fri Apr 21 13:14:46 2017 +1000

----------------------------------------------------------------------
 .../runtime/methoddispatching/BarOne.java       | 25 -----------
 .../runtime/methoddispatching/BarThree.java     | 25 -----------
 .../runtime/methoddispatching/BarTwo.java       | 25 -----------
 .../runtime/methoddispatching/FooOne.java       | 10 ++++-
 .../runtime/methoddispatching/FooThree.java     | 32 +++++++++++---
 .../runtime/methoddispatching/FooTwo.java       | 24 +++++++++--
 ...StaticMethodOverloadCompileStaticTest.groovy | 45 ++++++++++++++++++++
 .../StaticMethodOverloadTest.groovy             | 26 +++++------
 8 files changed, 112 insertions(+), 100 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/groovy/blob/840f6b65/src/test/org/codehaus/groovy/runtime/methoddispatching/BarOne.java
----------------------------------------------------------------------
diff --git a/src/test/org/codehaus/groovy/runtime/methoddispatching/BarOne.java b/src/test/org/codehaus/groovy/runtime/methoddispatching/BarOne.java
deleted file mode 100644
index 56daeeb..0000000
--- a/src/test/org/codehaus/groovy/runtime/methoddispatching/BarOne.java
+++ /dev/null
@@ -1,25 +0,0 @@
-/*
- *  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.runtime.methoddispatching;
-
-class BarOne implements FooOne {
-    static String foo() {
-        return "I'm Bar";
-    }
-}

http://git-wip-us.apache.org/repos/asf/groovy/blob/840f6b65/src/test/org/codehaus/groovy/runtime/methoddispatching/BarThree.java
----------------------------------------------------------------------
diff --git a/src/test/org/codehaus/groovy/runtime/methoddispatching/BarThree.java b/src/test/org/codehaus/groovy/runtime/methoddispatching/BarThree.java
deleted file mode 100644
index 63686b3..0000000
--- a/src/test/org/codehaus/groovy/runtime/methoddispatching/BarThree.java
+++ /dev/null
@@ -1,25 +0,0 @@
-/*
- *  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.runtime.methoddispatching;
-
-class BarThree implements FooThree {
-    static String foo() {
-        return "I'm Bar";
-    }
-}

http://git-wip-us.apache.org/repos/asf/groovy/blob/840f6b65/src/test/org/codehaus/groovy/runtime/methoddispatching/BarTwo.java
----------------------------------------------------------------------
diff --git a/src/test/org/codehaus/groovy/runtime/methoddispatching/BarTwo.java b/src/test/org/codehaus/groovy/runtime/methoddispatching/BarTwo.java
deleted file mode 100644
index 84a8f02..0000000
--- a/src/test/org/codehaus/groovy/runtime/methoddispatching/BarTwo.java
+++ /dev/null
@@ -1,25 +0,0 @@
-/*
- *  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.runtime.methoddispatching;
-
-class BarTwo implements FooTwo {
-    static String foo() {
-        return "I'm Bar";
-    }
-}

http://git-wip-us.apache.org/repos/asf/groovy/blob/840f6b65/src/test/org/codehaus/groovy/runtime/methoddispatching/FooOne.java
----------------------------------------------------------------------
diff --git a/src/test/org/codehaus/groovy/runtime/methoddispatching/FooOne.java b/src/test/org/codehaus/groovy/runtime/methoddispatching/FooOne.java
index f1bac0f..25e11c1 100644
--- a/src/test/org/codehaus/groovy/runtime/methoddispatching/FooOne.java
+++ b/src/test/org/codehaus/groovy/runtime/methoddispatching/FooOne.java
@@ -20,6 +20,12 @@ package org.codehaus.groovy.runtime.methoddispatching;
 
 interface FooOne {
     static String foo() {
-        return "I'm Foo";
+        return "FooOne.foo()";
     }
-}
\ No newline at end of file
+}
+
+class BarOne implements FooOne {
+    static String foo() {
+        return "BarOne.foo()";
+    }
+}

http://git-wip-us.apache.org/repos/asf/groovy/blob/840f6b65/src/test/org/codehaus/groovy/runtime/methoddispatching/FooThree.java
----------------------------------------------------------------------
diff --git a/src/test/org/codehaus/groovy/runtime/methoddispatching/FooThree.java b/src/test/org/codehaus/groovy/runtime/methoddispatching/FooThree.java
index 9f897ea..5c0c7cb 100644
--- a/src/test/org/codehaus/groovy/runtime/methoddispatching/FooThree.java
+++ b/src/test/org/codehaus/groovy/runtime/methoddispatching/FooThree.java
@@ -18,16 +18,36 @@
  */
 package org.codehaus.groovy.runtime.methoddispatching;
 
+import org.codehaus.groovy.runtime.metaclass.MetaMethodIndex;
+
+/**
+ * To test the case when we call a static method on a class and while we load all the methods from its interface,
+ * {@link MetaMethodIndex.Entry} contains more than one method from interface already
+ */
 interface FooThree {
     static String foo() {
-        return "I'm Foo";
+        return "FooThree.foo()";
+    }
+
+    static String foo(int a) {
+        return String.format("FooThree.foo(%1$d)", a);
+    }
+
+    static String foo(int a, int b) {
+        return String.format("FooThree.foo(%1$d, %2$d)", a, b);
+    }
+}
+
+class BarThree implements FooThree {
+    static String foo() {
+        return "BarThree.foo()";
     }
 
-    static String foo(int num) {
-        return String.valueOf(num);
+    static String foo(int a) {
+        return String.format("BarThree.foo(%1$d)", a);
     }
 
-    static String foo(boolean bool) {
-        return String.valueOf(bool);
+    static String foo(int a, int b) {
+        return String.format("BarThree.foo(%1$d, %2$d)", a, b);
     }
-}
\ No newline at end of file
+}

http://git-wip-us.apache.org/repos/asf/groovy/blob/840f6b65/src/test/org/codehaus/groovy/runtime/methoddispatching/FooTwo.java
----------------------------------------------------------------------
diff --git a/src/test/org/codehaus/groovy/runtime/methoddispatching/FooTwo.java b/src/test/org/codehaus/groovy/runtime/methoddispatching/FooTwo.java
index b7b315b..ec54c49 100644
--- a/src/test/org/codehaus/groovy/runtime/methoddispatching/FooTwo.java
+++ b/src/test/org/codehaus/groovy/runtime/methoddispatching/FooTwo.java
@@ -18,12 +18,28 @@
  */
 package org.codehaus.groovy.runtime.methoddispatching;
 
+import org.codehaus.groovy.runtime.metaclass.MetaMethodIndex;
+
+/**
+ * To test the case when we call a static method on a class and {@link MetaMethodIndex.Entry}
+ * contains more than one method from interface already
+ */
 interface FooTwo {
     static String foo() {
-        return "I'm Foo";
+        return "FooTwo.foo()";
+    }
+
+    static String foo(int a) {
+        return String.format("FooTwo.foo(%1$d)", a);
+    }
+}
+
+class BarTwo implements FooTwo {
+    static String foo() {
+        return "BarTwo.foo()";
     }
 
-    static String foo(int num) {
-        return String.valueOf(num);
+    static String foo(int a) {
+        return String.format("BarTwo.foo(%1$d)", a);
     }
-}
\ No newline at end of file
+}

http://git-wip-us.apache.org/repos/asf/groovy/blob/840f6b65/src/test/org/codehaus/groovy/runtime/methoddispatching/StaticMethodOverloadCompileStaticTest.groovy
----------------------------------------------------------------------
diff --git a/src/test/org/codehaus/groovy/runtime/methoddispatching/StaticMethodOverloadCompileStaticTest.groovy b/src/test/org/codehaus/groovy/runtime/methoddispatching/StaticMethodOverloadCompileStaticTest.groovy
new file mode 100644
index 0000000..ba4e1d1
--- /dev/null
+++ b/src/test/org/codehaus/groovy/runtime/methoddispatching/StaticMethodOverloadCompileStaticTest.groovy
@@ -0,0 +1,45 @@
+/*
+ *  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.runtime.methoddispatching
+
+import groovy.transform.CompileStatic
+
+@CompileStatic
+class StaticMethodOverloadCompileStaticTest extends GroovyTestCase {
+    void testOneStaticMethod() {
+        assert FooOne.foo() == "FooOne.foo()"
+        assert BarOne.foo() == "BarOne.foo()"
+    }
+
+    void testTwoStaticMethods() {
+        assert FooTwo.foo() == "FooTwo.foo()"
+        assert FooTwo.foo(0) == "FooTwo.foo(0)"
+        assert BarTwo.foo() == "BarTwo.foo()"
+        assert BarTwo.foo(0) == "BarTwo.foo(0)"
+    }
+
+    void testMoreThanTwoStaticMethods() {
+        assert FooThree.foo() == "FooThree.foo()"
+        assert FooThree.foo(0) == "FooThree.foo(0)"
+        assert FooThree.foo(0, 1) == "FooThree.foo(0, 1)"
+        assert BarThree.foo() == "BarThree.foo()"
+        assert BarThree.foo(0) == "BarThree.foo(0)"
+        assert BarThree.foo(0, 1) == "BarThree.foo(0, 1)"
+    }
+}

http://git-wip-us.apache.org/repos/asf/groovy/blob/840f6b65/src/test/org/codehaus/groovy/runtime/methoddispatching/StaticMethodOverloadTest.groovy
----------------------------------------------------------------------
diff --git a/src/test/org/codehaus/groovy/runtime/methoddispatching/StaticMethodOverloadTest.groovy b/src/test/org/codehaus/groovy/runtime/methoddispatching/StaticMethodOverloadTest.groovy
index 2df115f..e12af7a 100644
--- a/src/test/org/codehaus/groovy/runtime/methoddispatching/StaticMethodOverloadTest.groovy
+++ b/src/test/org/codehaus/groovy/runtime/methoddispatching/StaticMethodOverloadTest.groovy
@@ -19,24 +19,24 @@
 package org.codehaus.groovy.runtime.methoddispatching
 
 class StaticMethodOverloadTest extends GroovyTestCase {
-    void testOneStaticMethod() throws Exception {
-        assert FooOne.foo() == "I'm Foo"
-        assert BarOne.foo() == "I'm Bar"
+    void testOneStaticMethod() {
+        assert FooOne.foo() == "FooOne.foo()"
+        assert BarOne.foo() == "BarOne.foo()"
     }
 
     void testTwoStaticMethods() {
-        assert FooTwo.foo(42) == '42'
-        assert FooTwo.foo() == "I'm Foo"
-        assert BarTwo.foo(42) == '42'
-        assert BarTwo.foo() == "I'm Bar"
+        assert FooTwo.foo() == "FooTwo.foo()"
+        assert FooTwo.foo(0) == "FooTwo.foo(0)"
+        assert BarTwo.foo() == "BarTwo.foo()"
+        assert BarTwo.foo(0) == "BarTwo.foo(0)"
     }
 
     void testMoreThanTwoStaticMethods() {
-        assert FooThree.foo(42) == '42'
-        assert FooThree.foo() == "I'm Foo"
-        assert FooThree.foo(true) == 'true'
-        assert BarThree.foo(42) == '42'
-        assert BarThree.foo() == "I'm Bar"
-        assert BarThree.foo(true) == 'true'
+        assert FooThree.foo() == "FooThree.foo()"
+        assert FooThree.foo(0) == "FooThree.foo(0)"
+        assert FooThree.foo(0, 1) == "FooThree.foo(0, 1)"
+        assert BarThree.foo() == "BarThree.foo()"
+        assert BarThree.foo(0) == "BarThree.foo(0)"
+        assert BarThree.foo(0, 1) == "BarThree.foo(0, 1)"
     }
 }

Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

[3/3] groovy git commit: GROOVY-7879: Groovy calls wrong method if there is a static method on an interface (minor refactor - closes #521)

paulk
In reply to this post by paulk
GROOVY-7879: Groovy calls wrong method if there is a static method on an interface (minor refactor - closes #521)


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

Branch: refs/heads/master
Commit: 57fb455f5e65a92bfff4c0c80a18ca1d597fe19f
Parents: 840f6b6
Author: paulk <[hidden email]>
Authored: Fri Apr 21 13:49:29 2017 +1000
Committer: paulk <[hidden email]>
Committed: Fri Apr 21 13:49:29 2017 +1000

----------------------------------------------------------------------
 .../runtime/methoddispatching/FooOne.java       | 31 ------------
 .../runtime/methoddispatching/FooThree.java     | 53 --------------------
 .../runtime/methoddispatching/FooTwo.java       | 45 -----------------
 ...StaticMethodOverloadCompileStaticTest.groovy | 45 -----------------
 .../StaticMethodOverloadTest.groovy             | 42 ----------------
 .../runtime/methoddispatching/vm8/FooOne.java   | 31 ++++++++++++
 .../runtime/methoddispatching/vm8/FooThree.java | 53 ++++++++++++++++++++
 .../runtime/methoddispatching/vm8/FooTwo.java   | 45 +++++++++++++++++
 ...StaticMethodOverloadCompileStaticTest.groovy | 45 +++++++++++++++++
 .../vm8/StaticMethodOverloadTest.groovy         | 42 ++++++++++++++++
 10 files changed, 216 insertions(+), 216 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/groovy/blob/57fb455f/src/test/org/codehaus/groovy/runtime/methoddispatching/FooOne.java
----------------------------------------------------------------------
diff --git a/src/test/org/codehaus/groovy/runtime/methoddispatching/FooOne.java b/src/test/org/codehaus/groovy/runtime/methoddispatching/FooOne.java
deleted file mode 100644
index 25e11c1..0000000
--- a/src/test/org/codehaus/groovy/runtime/methoddispatching/FooOne.java
+++ /dev/null
@@ -1,31 +0,0 @@
-/*
- *  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.runtime.methoddispatching;
-
-interface FooOne {
-    static String foo() {
-        return "FooOne.foo()";
-    }
-}
-
-class BarOne implements FooOne {
-    static String foo() {
-        return "BarOne.foo()";
-    }
-}

http://git-wip-us.apache.org/repos/asf/groovy/blob/57fb455f/src/test/org/codehaus/groovy/runtime/methoddispatching/FooThree.java
----------------------------------------------------------------------
diff --git a/src/test/org/codehaus/groovy/runtime/methoddispatching/FooThree.java b/src/test/org/codehaus/groovy/runtime/methoddispatching/FooThree.java
deleted file mode 100644
index 5c0c7cb..0000000
--- a/src/test/org/codehaus/groovy/runtime/methoddispatching/FooThree.java
+++ /dev/null
@@ -1,53 +0,0 @@
-/*
- *  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.runtime.methoddispatching;
-
-import org.codehaus.groovy.runtime.metaclass.MetaMethodIndex;
-
-/**
- * To test the case when we call a static method on a class and while we load all the methods from its interface,
- * {@link MetaMethodIndex.Entry} contains more than one method from interface already
- */
-interface FooThree {
-    static String foo() {
-        return "FooThree.foo()";
-    }
-
-    static String foo(int a) {
-        return String.format("FooThree.foo(%1$d)", a);
-    }
-
-    static String foo(int a, int b) {
-        return String.format("FooThree.foo(%1$d, %2$d)", a, b);
-    }
-}
-
-class BarThree implements FooThree {
-    static String foo() {
-        return "BarThree.foo()";
-    }
-
-    static String foo(int a) {
-        return String.format("BarThree.foo(%1$d)", a);
-    }
-
-    static String foo(int a, int b) {
-        return String.format("BarThree.foo(%1$d, %2$d)", a, b);
-    }
-}

http://git-wip-us.apache.org/repos/asf/groovy/blob/57fb455f/src/test/org/codehaus/groovy/runtime/methoddispatching/FooTwo.java
----------------------------------------------------------------------
diff --git a/src/test/org/codehaus/groovy/runtime/methoddispatching/FooTwo.java b/src/test/org/codehaus/groovy/runtime/methoddispatching/FooTwo.java
deleted file mode 100644
index ec54c49..0000000
--- a/src/test/org/codehaus/groovy/runtime/methoddispatching/FooTwo.java
+++ /dev/null
@@ -1,45 +0,0 @@
-/*
- *  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.runtime.methoddispatching;
-
-import org.codehaus.groovy.runtime.metaclass.MetaMethodIndex;
-
-/**
- * To test the case when we call a static method on a class and {@link MetaMethodIndex.Entry}
- * contains more than one method from interface already
- */
-interface FooTwo {
-    static String foo() {
-        return "FooTwo.foo()";
-    }
-
-    static String foo(int a) {
-        return String.format("FooTwo.foo(%1$d)", a);
-    }
-}
-
-class BarTwo implements FooTwo {
-    static String foo() {
-        return "BarTwo.foo()";
-    }
-
-    static String foo(int a) {
-        return String.format("BarTwo.foo(%1$d)", a);
-    }
-}

http://git-wip-us.apache.org/repos/asf/groovy/blob/57fb455f/src/test/org/codehaus/groovy/runtime/methoddispatching/StaticMethodOverloadCompileStaticTest.groovy
----------------------------------------------------------------------
diff --git a/src/test/org/codehaus/groovy/runtime/methoddispatching/StaticMethodOverloadCompileStaticTest.groovy b/src/test/org/codehaus/groovy/runtime/methoddispatching/StaticMethodOverloadCompileStaticTest.groovy
deleted file mode 100644
index ba4e1d1..0000000
--- a/src/test/org/codehaus/groovy/runtime/methoddispatching/StaticMethodOverloadCompileStaticTest.groovy
+++ /dev/null
@@ -1,45 +0,0 @@
-/*
- *  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.runtime.methoddispatching
-
-import groovy.transform.CompileStatic
-
-@CompileStatic
-class StaticMethodOverloadCompileStaticTest extends GroovyTestCase {
-    void testOneStaticMethod() {
-        assert FooOne.foo() == "FooOne.foo()"
-        assert BarOne.foo() == "BarOne.foo()"
-    }
-
-    void testTwoStaticMethods() {
-        assert FooTwo.foo() == "FooTwo.foo()"
-        assert FooTwo.foo(0) == "FooTwo.foo(0)"
-        assert BarTwo.foo() == "BarTwo.foo()"
-        assert BarTwo.foo(0) == "BarTwo.foo(0)"
-    }
-
-    void testMoreThanTwoStaticMethods() {
-        assert FooThree.foo() == "FooThree.foo()"
-        assert FooThree.foo(0) == "FooThree.foo(0)"
-        assert FooThree.foo(0, 1) == "FooThree.foo(0, 1)"
-        assert BarThree.foo() == "BarThree.foo()"
-        assert BarThree.foo(0) == "BarThree.foo(0)"
-        assert BarThree.foo(0, 1) == "BarThree.foo(0, 1)"
-    }
-}

http://git-wip-us.apache.org/repos/asf/groovy/blob/57fb455f/src/test/org/codehaus/groovy/runtime/methoddispatching/StaticMethodOverloadTest.groovy
----------------------------------------------------------------------
diff --git a/src/test/org/codehaus/groovy/runtime/methoddispatching/StaticMethodOverloadTest.groovy b/src/test/org/codehaus/groovy/runtime/methoddispatching/StaticMethodOverloadTest.groovy
deleted file mode 100644
index e12af7a..0000000
--- a/src/test/org/codehaus/groovy/runtime/methoddispatching/StaticMethodOverloadTest.groovy
+++ /dev/null
@@ -1,42 +0,0 @@
-/*
- *  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.runtime.methoddispatching
-
-class StaticMethodOverloadTest extends GroovyTestCase {
-    void testOneStaticMethod() {
-        assert FooOne.foo() == "FooOne.foo()"
-        assert BarOne.foo() == "BarOne.foo()"
-    }
-
-    void testTwoStaticMethods() {
-        assert FooTwo.foo() == "FooTwo.foo()"
-        assert FooTwo.foo(0) == "FooTwo.foo(0)"
-        assert BarTwo.foo() == "BarTwo.foo()"
-        assert BarTwo.foo(0) == "BarTwo.foo(0)"
-    }
-
-    void testMoreThanTwoStaticMethods() {
-        assert FooThree.foo() == "FooThree.foo()"
-        assert FooThree.foo(0) == "FooThree.foo(0)"
-        assert FooThree.foo(0, 1) == "FooThree.foo(0, 1)"
-        assert BarThree.foo() == "BarThree.foo()"
-        assert BarThree.foo(0) == "BarThree.foo(0)"
-        assert BarThree.foo(0, 1) == "BarThree.foo(0, 1)"
-    }
-}

http://git-wip-us.apache.org/repos/asf/groovy/blob/57fb455f/src/test/org/codehaus/groovy/runtime/methoddispatching/vm8/FooOne.java
----------------------------------------------------------------------
diff --git a/src/test/org/codehaus/groovy/runtime/methoddispatching/vm8/FooOne.java b/src/test/org/codehaus/groovy/runtime/methoddispatching/vm8/FooOne.java
new file mode 100644
index 0000000..7e50432
--- /dev/null
+++ b/src/test/org/codehaus/groovy/runtime/methoddispatching/vm8/FooOne.java
@@ -0,0 +1,31 @@
+/*
+ *  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.runtime.methoddispatching.vm8;
+
+interface FooOne {
+    static String foo() {
+        return "FooOne.foo()";
+    }
+}
+
+class BarOne implements FooOne {
+    static String foo() {
+        return "BarOne.foo()";
+    }
+}

http://git-wip-us.apache.org/repos/asf/groovy/blob/57fb455f/src/test/org/codehaus/groovy/runtime/methoddispatching/vm8/FooThree.java
----------------------------------------------------------------------
diff --git a/src/test/org/codehaus/groovy/runtime/methoddispatching/vm8/FooThree.java b/src/test/org/codehaus/groovy/runtime/methoddispatching/vm8/FooThree.java
new file mode 100644
index 0000000..d74871b
--- /dev/null
+++ b/src/test/org/codehaus/groovy/runtime/methoddispatching/vm8/FooThree.java
@@ -0,0 +1,53 @@
+/*
+ *  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.runtime.methoddispatching.vm8;
+
+import org.codehaus.groovy.runtime.metaclass.MetaMethodIndex;
+
+/**
+ * To test the case when we call a static method on a class and while we load all the methods from its interface,
+ * {@link MetaMethodIndex.Entry} contains more than one method from interface already
+ */
+interface FooThree {
+    static String foo() {
+        return "FooThree.foo()";
+    }
+
+    static String foo(int a) {
+        return String.format("FooThree.foo(%1$d)", a);
+    }
+
+    static String foo(int a, int b) {
+        return String.format("FooThree.foo(%1$d, %2$d)", a, b);
+    }
+}
+
+class BarThree implements FooThree {
+    static String foo() {
+        return "BarThree.foo()";
+    }
+
+    static String foo(int a) {
+        return String.format("BarThree.foo(%1$d)", a);
+    }
+
+    static String foo(int a, int b) {
+        return String.format("BarThree.foo(%1$d, %2$d)", a, b);
+    }
+}

http://git-wip-us.apache.org/repos/asf/groovy/blob/57fb455f/src/test/org/codehaus/groovy/runtime/methoddispatching/vm8/FooTwo.java
----------------------------------------------------------------------
diff --git a/src/test/org/codehaus/groovy/runtime/methoddispatching/vm8/FooTwo.java b/src/test/org/codehaus/groovy/runtime/methoddispatching/vm8/FooTwo.java
new file mode 100644
index 0000000..f91e9d8
--- /dev/null
+++ b/src/test/org/codehaus/groovy/runtime/methoddispatching/vm8/FooTwo.java
@@ -0,0 +1,45 @@
+/*
+ *  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.runtime.methoddispatching.vm8;
+
+import org.codehaus.groovy.runtime.metaclass.MetaMethodIndex;
+
+/**
+ * To test the case when we call a static method on a class and {@link MetaMethodIndex.Entry}
+ * contains more than one method from interface already
+ */
+interface FooTwo {
+    static String foo() {
+        return "FooTwo.foo()";
+    }
+
+    static String foo(int a) {
+        return String.format("FooTwo.foo(%1$d)", a);
+    }
+}
+
+class BarTwo implements FooTwo {
+    static String foo() {
+        return "BarTwo.foo()";
+    }
+
+    static String foo(int a) {
+        return String.format("BarTwo.foo(%1$d)", a);
+    }
+}

http://git-wip-us.apache.org/repos/asf/groovy/blob/57fb455f/src/test/org/codehaus/groovy/runtime/methoddispatching/vm8/StaticMethodOverloadCompileStaticTest.groovy
----------------------------------------------------------------------
diff --git a/src/test/org/codehaus/groovy/runtime/methoddispatching/vm8/StaticMethodOverloadCompileStaticTest.groovy b/src/test/org/codehaus/groovy/runtime/methoddispatching/vm8/StaticMethodOverloadCompileStaticTest.groovy
new file mode 100644
index 0000000..b62b978
--- /dev/null
+++ b/src/test/org/codehaus/groovy/runtime/methoddispatching/vm8/StaticMethodOverloadCompileStaticTest.groovy
@@ -0,0 +1,45 @@
+/*
+ *  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.runtime.methoddispatching.vm8
+
+import groovy.transform.CompileStatic
+
+@CompileStatic
+class StaticMethodOverloadCompileStaticTest extends GroovyTestCase {
+    void testOneStaticMethod() {
+        assert FooOne.foo() == "FooOne.foo()"
+        assert BarOne.foo() == "BarOne.foo()"
+    }
+
+    void testTwoStaticMethods() {
+        assert FooTwo.foo() == "FooTwo.foo()"
+        assert FooTwo.foo(0) == "FooTwo.foo(0)"
+        assert BarTwo.foo() == "BarTwo.foo()"
+        assert BarTwo.foo(0) == "BarTwo.foo(0)"
+    }
+
+    void testMoreThanTwoStaticMethods() {
+        assert FooThree.foo() == "FooThree.foo()"
+        assert FooThree.foo(0) == "FooThree.foo(0)"
+        assert FooThree.foo(0, 1) == "FooThree.foo(0, 1)"
+        assert BarThree.foo() == "BarThree.foo()"
+        assert BarThree.foo(0) == "BarThree.foo(0)"
+        assert BarThree.foo(0, 1) == "BarThree.foo(0, 1)"
+    }
+}

http://git-wip-us.apache.org/repos/asf/groovy/blob/57fb455f/src/test/org/codehaus/groovy/runtime/methoddispatching/vm8/StaticMethodOverloadTest.groovy
----------------------------------------------------------------------
diff --git a/src/test/org/codehaus/groovy/runtime/methoddispatching/vm8/StaticMethodOverloadTest.groovy b/src/test/org/codehaus/groovy/runtime/methoddispatching/vm8/StaticMethodOverloadTest.groovy
new file mode 100644
index 0000000..1442421
--- /dev/null
+++ b/src/test/org/codehaus/groovy/runtime/methoddispatching/vm8/StaticMethodOverloadTest.groovy
@@ -0,0 +1,42 @@
+/*
+ *  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.runtime.methoddispatching.vm8
+
+class StaticMethodOverloadTest extends GroovyTestCase {
+    void testOneStaticMethod() {
+        assert FooOne.foo() == "FooOne.foo()"
+        assert BarOne.foo() == "BarOne.foo()"
+    }
+
+    void testTwoStaticMethods() {
+        assert FooTwo.foo() == "FooTwo.foo()"
+        assert FooTwo.foo(0) == "FooTwo.foo(0)"
+        assert BarTwo.foo() == "BarTwo.foo()"
+        assert BarTwo.foo(0) == "BarTwo.foo(0)"
+    }
+
+    void testMoreThanTwoStaticMethods() {
+        assert FooThree.foo() == "FooThree.foo()"
+        assert FooThree.foo(0) == "FooThree.foo(0)"
+        assert FooThree.foo(0, 1) == "FooThree.foo(0, 1)"
+        assert BarThree.foo() == "BarThree.foo()"
+        assert BarThree.foo(0) == "BarThree.foo(0)"
+        assert BarThree.foo(0, 1) == "BarThree.foo(0, 1)"
+    }
+}

Loading...