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 2022/09/10 16:35:28 UTC
[groovy] branch GROOVY_4_0_X updated: GROOVY-10756: STC: retain bounds within super class generics
This is an automated email from the ASF dual-hosted git repository.
emilles pushed a commit to branch GROOVY_4_0_X
in repository https://gitbox.apache.org/repos/asf/groovy.git
The following commit(s) were added to refs/heads/GROOVY_4_0_X by this push:
new a3b07841df GROOVY-10756: STC: retain bounds within super class generics
a3b07841df is described below
commit a3b07841df5717275f7e70d6d6ecd2b96813de9c
Author: Eric Milles <er...@thomsonreuters.com>
AuthorDate: Sat Sep 10 11:16:16 2022 -0500
GROOVY-10756: STC: retain bounds within super class generics
---
.../groovy/transform/stc/StaticTypeCheckingSupport.java | 10 +++++-----
.../transform/stc/ClosureParamTypeInferenceSTCTest.groovy | 12 ++++++++++++
2 files changed, 17 insertions(+), 5 deletions(-)
diff --git a/src/main/java/org/codehaus/groovy/transform/stc/StaticTypeCheckingSupport.java b/src/main/java/org/codehaus/groovy/transform/stc/StaticTypeCheckingSupport.java
index d450822884..8faa4b5c45 100644
--- a/src/main/java/org/codehaus/groovy/transform/stc/StaticTypeCheckingSupport.java
+++ b/src/main/java/org/codehaus/groovy/transform/stc/StaticTypeCheckingSupport.java
@@ -1757,14 +1757,14 @@ public abstract class StaticTypeCheckingSupport {
ClassNode superClass = getNextSuperClass(type, target);
if (superClass != null) {
if (GenericsUtils.hasUnresolvedGenerics(superClass)) {
- Map<String, ClassNode> spec = GenericsUtils.createGenericsSpec(type);
- if (!spec.isEmpty()) {
- superClass = GenericsUtils.correctToGenericsSpecRecurse(spec, superClass);
- }
+ // propagate type arguments to the super class or interface
+ Map<GenericsTypeName, GenericsType> spec = new HashMap<>();
+ extractGenericsConnections(spec, type.getGenericsTypes(),
+ type.redirect().getGenericsTypes());
+ superClass = applyGenericsContext(spec, superClass);
}
extractGenericsConnections(connections, superClass, target);
} else {
- // if we reach here, we have an unhandled case
throw new GroovyBugError("The type " + type + " seems not to normally extend " + target + ". Sorry, I cannot handle this.");
}
}
diff --git a/src/test/groovy/transform/stc/ClosureParamTypeInferenceSTCTest.groovy b/src/test/groovy/transform/stc/ClosureParamTypeInferenceSTCTest.groovy
index a131a594fb..f7e033f8fa 100644
--- a/src/test/groovy/transform/stc/ClosureParamTypeInferenceSTCTest.groovy
+++ b/src/test/groovy/transform/stc/ClosureParamTypeInferenceSTCTest.groovy
@@ -1579,4 +1579,16 @@ class ClosureParamTypeInferenceSTCTest extends StaticTypeCheckingTestCase {
assert i == 1
'''
}
+
+ static class Java10756 {
+ static <T extends File> Collection<T> getFiles() {
+ }
+ }
+
+ void testGroovy10756() {
+ assertScript """import ${Java10756.name.replace('$','.')}
+ Java10756.files?.collect { it.name }
+ // ^^ File
+ """
+ }
}