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/10/10 15:39:34 UTC
[groovy] branch master updated: GROOVY-10280: STC: do not mix type
param contexts when resolving
This is an automated email from the ASF dual-hosted git repository.
emilles pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/groovy.git
The following commit(s) were added to refs/heads/master by this push:
new a3ab384 GROOVY-10280: STC: do not mix type param contexts when resolving
a3ab384 is described below
commit a3ab384dbb1d323fcbcdd5675dc74f43650e0356
Author: Eric Milles <er...@thomsonreuters.com>
AuthorDate: Sun Oct 10 10:39:05 2021 -0500
GROOVY-10280: STC: do not mix type param contexts when resolving
---
.../groovy/transform/stc/StaticTypeCheckingSupport.java | 12 ++++--------
src/test/groovy/transform/stc/GenericsSTCTest.groovy | 17 ++++++++++-------
2 files changed, 14 insertions(+), 15 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 ececcfb..168f496 100644
--- a/src/main/java/org/codehaus/groovy/transform/stc/StaticTypeCheckingSupport.java
+++ b/src/main/java/org/codehaus/groovy/transform/stc/StaticTypeCheckingSupport.java
@@ -1576,14 +1576,10 @@ public abstract class StaticTypeCheckingSupport {
}
public static ClassNode resolveClassNodeGenerics(Map<GenericsTypeName, GenericsType> resolvedPlaceholders, final Map<GenericsTypeName, GenericsType> placeholdersFromContext, final ClassNode currentType) {
- ClassNode target = currentType.redirect();
- resolvedPlaceholders = new HashMap<>(resolvedPlaceholders);
- applyContextGenerics(resolvedPlaceholders, placeholdersFromContext);
-
- Map<GenericsTypeName, GenericsType> connections = new HashMap<>();
- extractGenericsConnections(connections, currentType, target);
- applyGenericsConnections(connections, resolvedPlaceholders);
- return applyGenericsContext(resolvedPlaceholders, currentType);
+ ClassNode type = currentType; // GROOVY-10280, et al.
+ type = applyGenericsContext(resolvedPlaceholders, type);
+ type = applyGenericsContext(placeholdersFromContext, type);
+ return type;
}
static void applyGenericsConnections(final Map<GenericsTypeName, GenericsType> connections, final Map<GenericsTypeName, GenericsType> resolvedPlaceholders) {
diff --git a/src/test/groovy/transform/stc/GenericsSTCTest.groovy b/src/test/groovy/transform/stc/GenericsSTCTest.groovy
index 682b4f0..03de7e4 100644
--- a/src/test/groovy/transform/stc/GenericsSTCTest.groovy
+++ b/src/test/groovy/transform/stc/GenericsSTCTest.groovy
@@ -932,21 +932,24 @@ class GenericsSTCTest extends StaticTypeCheckingTestCase {
assertScript '''
class Test<T> {
T test() {
- new Foo<T>().one.two.three
+ @ASTTest(phase=INSTRUCTION_SELECTION, value={
+ def type = node.getNodeMetaData(INFERRED_TYPE)
+ assert type.toString(false) == 'T'
+ })
+ def t = new Foo<T>().x.y.z
}
}
class Foo<X> {
- Bar<X> one = new Bar<>()
+ Bar<X> x = new Bar<>()
}
- class Bar<Y> {
- Baz<Y> two = new Baz<>()
+ class Bar<T> {
+ Baz<T> y = new Baz<>()
}
class Baz<Z> {
- Z three
+ Z z
}
- def result = new Test().test()
- assert result == null
+ new Test<String>().test()
'''
}