groovy-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From sun...@apache.org
Subject [groovy] 15/20: GROOVY-8468: add test case
Date Sun, 01 Dec 2019 10:41:53 GMT
This is an automated email from the ASF dual-hosted git repository.

sunlan pushed a commit to branch GROOVY_3_0_X
in repository https://gitbox.apache.org/repos/asf/groovy.git

commit 4259a533a729e53fa287134f80bcd7ad5e950453
Author: Eric Milles <eric.milles@thomsonreuters.com>
AuthorDate: Wed Nov 27 08:06:11 2019 -0600

    GROOVY-8468: add test case
    
    (cherry picked from commit 4edad9994113a54ee3c3d47d658c3e369f866c82)
---
 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);
+  }*/
+}


Mime
View raw message