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/11/18 21:36:13 UTC
[groovy] branch GROOVY_2_5_X updated: GROOVY-10055, GROOVY-10846: STC: erasure for generic with no upper bound
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 f0e3658409 GROOVY-10055, GROOVY-10846: STC: erasure for generic with no upper bound
f0e3658409 is described below
commit f0e365840928964a0108d1c7320904e24ec49629
Author: Eric Milles <er...@thomsonreuters.com>
AuthorDate: Fri Nov 18 13:30:49 2022 -0600
GROOVY-10055, GROOVY-10846: STC: erasure for generic with no upper bound
---
.../transform/stc/StaticTypeCheckingVisitor.java | 5 +++--
.../groovy/transform/stc/GenericsSTCTest.groovy | 21 ++++++++++++++++++++-
2 files changed, 23 insertions(+), 3 deletions(-)
diff --git a/src/main/java/org/codehaus/groovy/transform/stc/StaticTypeCheckingVisitor.java b/src/main/java/org/codehaus/groovy/transform/stc/StaticTypeCheckingVisitor.java
index 29a9099387..86e663d400 100644
--- a/src/main/java/org/codehaus/groovy/transform/stc/StaticTypeCheckingVisitor.java
+++ b/src/main/java/org/codehaus/groovy/transform/stc/StaticTypeCheckingVisitor.java
@@ -3833,8 +3833,9 @@ public class StaticTypeCheckingVisitor extends ClassCodeVisitorSupport {
addBoundType(cn, owners);
addSelfTypes(cn, owners);
}
- } else {
- owners.add(Receiver.<String>make(OBJECT_TYPE)); // T or T super Type
+ } else { // GROOVY-10055, GROOVY-10846, et al.
+ ClassNode cn = gt.getType().redirect(); // T or T super Type
+ owners.add(Receiver.<String>make(cn));
}
}
diff --git a/src/test/groovy/transform/stc/GenericsSTCTest.groovy b/src/test/groovy/transform/stc/GenericsSTCTest.groovy
index 699083e2a2..7b003e8754 100644
--- a/src/test/groovy/transform/stc/GenericsSTCTest.groovy
+++ b/src/test/groovy/transform/stc/GenericsSTCTest.groovy
@@ -3443,6 +3443,25 @@ class GenericsSTCTest extends StaticTypeCheckingTestCase {
'''
}
+ // GROOVY-10846
+ void testClassLevelGenericsForPropertyRead() {
+ for (vis in ['','public','protected','@groovy.transform.PackageScope']) {
+ assertScript """
+ class A {
+ $vis String b
+ }
+ class C<X extends A, Y extends List<X>> {
+ void test(X x) {
+ x.b = 'blah'
+ }
+ }
+ A a = []
+ new C<A, List<A>>().test(a)
+ assert a.b == 'blah'
+ """
+ }
+ }
+
// GROOVY-6919
void testMethodLevelGenericsForPropertyRead() {
assertScript '''
@@ -4153,7 +4172,7 @@ class GenericsSTCTest extends StaticTypeCheckingTestCase {
}
}
- @NotYetImplemented // GROOVY-10055
+ // GROOVY-10055
void testSelfReferentialTypeParameter2() {
assertScript '''
abstract class A<Self extends A<Self>> {