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:06:53 UTC
[groovy] branch GROOVY_3_0_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_3_0_X
in repository https://gitbox.apache.org/repos/asf/groovy.git
The following commit(s) were added to refs/heads/GROOVY_3_0_X by this push:
new c34bedc GROOVY-8960: add test case
c34bedc is described below
commit c34bedcb1e149801aab5c04e938fec507a91c076
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 9667da0..ef55b9d 100644
--- a/src/test/groovy/transform/stc/GenericsSTCTest.groovy
+++ b/src/test/groovy/transform/stc/GenericsSTCTest.groovy
@@ -1246,7 +1246,7 @@ class GenericsSTCTest extends StaticTypeCheckingTestCase {
'''
}
- void testCorrectlyBoundedByExtendsGenericParameterType() {
+ void testCorrectlyBoundedByExtendsGenericParameterType1() {
assertScript '''
class Foo {
static <T extends List<? extends CharSequence>> void bar(T a) {}
@@ -1255,6 +1255,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 {