You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@groovy.apache.org by jo...@apache.org on 2025/07/22 14:07:55 UTC
(groovy) 02/02: Add test for generics handling
This is an automated email from the ASF dual-hosted git repository.
jonnybot pushed a commit to branch GROOVY-11719-regression-semantic-analysis-exception
in repository https://gitbox.apache.org/repos/asf/groovy.git
commit d5acd7d1a809e6c991fc3f50c00a6ea87ae84a1b
Author: Jonny Carter <jc...@adaptavist.com>
AuthorDate: Tue Jul 22 09:04:27 2025 -0500
Add test for generics handling
GROOVY-11719
---
.../util/GroovyScriptEngineReloadingTest.groovy | 33 ++++++++++++++++++++++
1 file changed, 33 insertions(+)
diff --git a/src/test/groovy/groovy/util/GroovyScriptEngineReloadingTest.groovy b/src/test/groovy/groovy/util/GroovyScriptEngineReloadingTest.groovy
index 660f4ddcf0..935d99abc8 100644
--- a/src/test/groovy/groovy/util/GroovyScriptEngineReloadingTest.groovy
+++ b/src/test/groovy/groovy/util/GroovyScriptEngineReloadingTest.groovy
@@ -182,6 +182,39 @@ final class GroovyScriptEngineReloadingTest {
}
+ @Test
+ void testRecompilingWithGenericsAndConstants() {
+ MapFileSystem.instance.modFile('BaseClass.groovy', 'class BaseClass<T> {}', gse.@time)
+
+ def tertiaryClassText = '''
+ class NotGeneric {
+ /**
+ * Not typed on purpose - if typed as String then NotGeneric is no longer a dependency of
+ * ParameterisedClass for some reason...
+ */
+ public static final Object CONSTANT = "not generic"
+ }
+ '''
+ MapFileSystem.instance.modFile('NotGeneric.groovy', tertiaryClassText, gse.@time)
+
+ def subClassText = '''
+ class SubClass extends BaseClass<String> {
+ public static final String CONSTANT = NotGeneric.CONSTANT
+ }
+ '''
+ MapFileSystem.instance.modFile('SubClass.groovy', subClassText, gse.@time)
+
+ MapFileSystem.instance.modFile('scriptUsingGeneric.groovy', 'SubClass.CONSTANT', gse.@time)
+
+
+ gse.loadScriptByName('scriptUsingGeneric.groovy')
+ sleep 1000
+
+ // make a change to the sub-class so that it gets recompiled
+ MapFileSystem.instance.modFile('SubClass.groovy', subClassText + '\n', gse.@time)
+ gse.loadScriptByName('scriptUsingGeneric.groovy')
+ }
+
@Test
void testDeleteDependent() {
sleep 10000