You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@groovy.apache.org by em...@apache.org on 2021/12/19 19:13:07 UTC

[groovy] branch GROOVY-10300 updated: GROOVY-7799: add test case

This is an automated email from the ASF dual-hosted git repository.

emilles pushed a commit to branch GROOVY-10300
in repository https://gitbox.apache.org/repos/asf/groovy.git


The following commit(s) were added to refs/heads/GROOVY-10300 by this push:
     new ed41e27  GROOVY-7799: add test case
ed41e27 is described below

commit ed41e27ba5df0e60e8b2a157220c2e0178d5aa98
Author: Eric Milles <er...@thomsonreuters.com>
AuthorDate: Sun Dec 19 13:13:00 2021 -0600

    GROOVY-7799: add test case
---
 .../groovy/bugs/groovy7799/AB.groovy               | 46 ++++++++++++++++++++++
 .../groovy/bugs/groovy7799/EE.groovy               | 22 +++++++++++
 .../groovy/bugs/groovy7799/Main.groovy             | 30 ++++++++++++++
 src/test/groovy/script/RuntimeResolveTests.groovy  |  5 +++
 4 files changed, 103 insertions(+)

diff --git a/src/test-resources/groovy/bugs/groovy7799/AB.groovy b/src/test-resources/groovy/bugs/groovy7799/AB.groovy
new file mode 100644
index 0000000..fc9ccd2
--- /dev/null
+++ b/src/test-resources/groovy/bugs/groovy7799/AB.groovy
@@ -0,0 +1,46 @@
+/*
+ *  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 groovy.bugs.groovy7799
+
+interface A<T extends EE> {
+
+    A<T> method(T args)
+
+    A<T> method(T[] args)
+
+    A<T> method(Collection<T> args)
+}
+
+class AB<T extends EE> implements A<T> {
+
+    @Override
+    AB<T> method(T args) {
+        return this
+    }
+
+    @Override
+    AB<T> method(T[] args) {
+        return this
+    }
+
+    @Override
+    AB<T> method(Collection<T> args) {
+        return this
+    }
+}
diff --git a/src/test-resources/groovy/bugs/groovy7799/EE.groovy b/src/test-resources/groovy/bugs/groovy7799/EE.groovy
new file mode 100644
index 0000000..9e2c6ca
--- /dev/null
+++ b/src/test-resources/groovy/bugs/groovy7799/EE.groovy
@@ -0,0 +1,22 @@
+/*
+ *  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 groovy.bugs.groovy7799
+
+interface EE {
+}
diff --git a/src/test-resources/groovy/bugs/groovy7799/Main.groovy b/src/test-resources/groovy/bugs/groovy7799/Main.groovy
new file mode 100644
index 0000000..7e1e3a4
--- /dev/null
+++ b/src/test-resources/groovy/bugs/groovy7799/Main.groovy
@@ -0,0 +1,30 @@
+/*
+ *  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 groovy.bugs.groovy7799
+
+class ABC<T extends EE> extends AB<T> {
+}
+
+class X implements EE {
+}
+
+def abc = new ABC<X>()
+def xyz = abc.method(new X(), new X())
+
+assert abc === xyz
diff --git a/src/test/groovy/script/RuntimeResolveTests.groovy b/src/test/groovy/script/RuntimeResolveTests.groovy
index d5893f0..c6edaaf 100644
--- a/src/test/groovy/script/RuntimeResolveTests.groovy
+++ b/src/test/groovy/script/RuntimeResolveTests.groovy
@@ -68,4 +68,9 @@ final class RuntimeResolveTests {
     void testResolvePackagePeersAndCompileTrait() {
         runScript('/groovy/bugs/groovyA144/Main.groovy')
     }
+
+    @Test
+    void testResolvePackagePeersAndTypeArgument() {
+        runScript('/groovy/bugs/groovy7799/Main.groovy')
+    }
 }