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/03/19 21:15:17 UTC
[groovy] branch GROOVY_2_5_X updated: GROOVY-8960: add test case
This is an automated email from the ASF dual-hosted git repository.
emilles pushed a commit to branch GROOVY_2_5_X
in repository https://gitbox.apache.org/repos/asf/groovy.git
The following commit(s) were added to refs/heads/GROOVY_2_5_X by this push:
new 6666e81 GROOVY-8960: add test case
6666e81 is described below
commit 6666e81f5bd1cea08d51b7e584c9691c245078a8
Author: Eric Milles <er...@thomsonreuters.com>
AuthorDate: Fri Mar 19 15:52:26 2021 -0500
GROOVY-8960: add test case
---
.../groovy/transform/stc/GenericsSTCTest.groovy | 48 +++++++++++++++++++++-
1 file changed, 47 insertions(+), 1 deletion(-)
diff --git a/src/test/groovy/transform/stc/GenericsSTCTest.groovy b/src/test/groovy/transform/stc/GenericsSTCTest.groovy
index 53f83d6..1e5c37b 100644
--- a/src/test/groovy/transform/stc/GenericsSTCTest.groovy
+++ b/src/test/groovy/transform/stc/GenericsSTCTest.groovy
@@ -1005,7 +1005,7 @@ class GenericsSTCTest extends StaticTypeCheckingTestCase {
'''
}
- void testCorrectlyBoundedByExtendsGenericParameterType() {
+ void testCorrectlyBoundedByExtendsGenericParameterType1() {
assertScript '''
class Foo {
static <T extends List<? extends CharSequence>> void bar(T a) {}
@@ -1014,6 +1014,52 @@ class GenericsSTCTest extends StaticTypeCheckingTestCase {
'''
}
+ // GROOVY-8960
+ void testCorrectlyBoundedByExtendsGenericParameterType2() {
+ File parentDir = File.createTempDir()
+ config.with {
+ targetDirectory = File.createTempDir()
+ jointCompilationOptions = [stubDir: File.createTempDir()]
+ }
+ try {
+ def a = new File(parentDir, 'aJavaClass.java')
+ a.write '''
+ import java.io.Serializable;
+ public class aJavaClass<A extends Serializable> {
+ public static <A extends Serializable> aJavaClass<A> create(A a) {
+ return new aJavaClass<>(a);
+ }
+ private aJavaClass(A a) {
+ }
+ public enum anEnum {
+ entry1;
+ }
+ }
+ '''
+ def b = new File(parentDir, 'aGroovyClass.groovy')
+ b.write '''
+ import aJavaClass
+ class aGroovyClass {
+ static main(args) {
+ def out = aJavaClass.create(aJavaClass.anEnum.entry1)
+ assert out != null
+ }
+ }
+ '''
+
+ def loader = new GroovyClassLoader(this.class.classLoader)
+ def cu = new JavaAwareCompilationUnit(config, loader)
+ cu.addSources(a, b)
+ cu.compile()
+
+ loader.loadClass('aGroovyClass').main()
+ } finally {
+ parentDir.deleteDir()
+ config.targetDirectory.deleteDir()
+ config.jointCompilationOptions.stubDir.deleteDir()
+ }
+ }
+
void testCorrectlyBoundedBySuperGenericParameterType() {
assertScript '''
class Foo {