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 2019/11/27 14:11:15 UTC
[groovy] branch master updated: GROOVY-8468: add test case
This is an automated email from the ASF dual-hosted git repository.
emilles 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 4edad99 GROOVY-8468: add test case
4edad99 is described below
commit 4edad9994113a54ee3c3d47d658c3e369f866c82
Author: Eric Milles <er...@thomsonreuters.com>
AuthorDate: Wed Nov 27 08:06:11 2019 -0600
GROOVY-8468: add test case
---
src/test/groovy/bugs/Groovy8468.groovy | 46 ++++++++++++++++++++++++
src/test/groovy/bugs/groovy8468/Face.java | 22 ++++++++++++
src/test/groovy/bugs/groovy8468/FaceImpl.java | 22 ++++++++++++
src/test/groovy/bugs/groovy8468/Factory.java | 23 ++++++++++++
src/test/groovy/bugs/groovy8468/FactoryImpl.java | 32 +++++++++++++++++
5 files changed, 145 insertions(+)
diff --git a/src/test/groovy/bugs/Groovy8468.groovy b/src/test/groovy/bugs/Groovy8468.groovy
new file mode 100644
index 0000000..b15a561
--- /dev/null
+++ b/src/test/groovy/bugs/Groovy8468.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
+
+import groovy.transform.CompileStatic
+import org.junit.Test
+
+import static groovy.test.GroovyAssert.assertScript
+
+@CompileStatic
+final class Groovy8468 {
+
+ @Test
+ void testGenericArrayType() {
+ assertScript '''
+ import groovy.bugs.groovy8468.*
+
+ @groovy.transform.CompileStatic
+ def test() {
+ Factory factory = new FactoryImpl()
+ Face[] array = factory.makeArray(FaceImpl) // NoSuchMethodError: Factory.makeArray(Ljava/lang/Class;)[Ljava/lang/Object;
+ return array
+ }
+
+ def result = test()
+ assert result != null
+ assert result.length == 0
+ '''
+ }
+}
diff --git a/src/test/groovy/bugs/groovy8468/Face.java b/src/test/groovy/bugs/groovy8468/Face.java
new file mode 100644
index 0000000..1ccc9c3
--- /dev/null
+++ b/src/test/groovy/bugs/groovy8468/Face.java
@@ -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.groovy8468;
+
+public interface Face {
+}
diff --git a/src/test/groovy/bugs/groovy8468/FaceImpl.java b/src/test/groovy/bugs/groovy8468/FaceImpl.java
new file mode 100644
index 0000000..25e51d9
--- /dev/null
+++ b/src/test/groovy/bugs/groovy8468/FaceImpl.java
@@ -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.groovy8468;
+
+public class FaceImpl implements Face {
+}
diff --git a/src/test/groovy/bugs/groovy8468/Factory.java b/src/test/groovy/bugs/groovy8468/Factory.java
new file mode 100644
index 0000000..2281466
--- /dev/null
+++ b/src/test/groovy/bugs/groovy8468/Factory.java
@@ -0,0 +1,23 @@
+/*
+ * 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.groovy8468;
+
+public interface Factory {
+ public <T extends Face> T[] makeArray(Class<T> clazz);
+}
diff --git a/src/test/groovy/bugs/groovy8468/FactoryImpl.java b/src/test/groovy/bugs/groovy8468/FactoryImpl.java
new file mode 100644
index 0000000..1d25532
--- /dev/null
+++ b/src/test/groovy/bugs/groovy8468/FactoryImpl.java
@@ -0,0 +1,32 @@
+/*
+ * 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.groovy8468;
+
+public class FactoryImpl implements Factory {
+ @Override @SuppressWarnings("unchecked")
+ public <T extends Face> T[] makeArray(Class<T> clazz) {
+ return (T[]) java.lang.reflect.Array.newInstance(clazz, 0);
+ }
+
+ /*public static void main(String[] args) {
+ Factory factory = new FactoryImpl();
+ Face[] array = factory.makeArray(FaceImpl.class);
+ System.out.println(array);
+ }*/
+}