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 2025/05/22 17:15:32 UTC
(groovy) branch GROOVY-11664 created (now 06dc049d44)
This is an automated email from the ASF dual-hosted git repository.
emilles pushed a change to branch GROOVY-11664
in repository https://gitbox.apache.org/repos/asf/groovy.git
at 06dc049d44 GROOVY-11664: STC: combine generics of same-type witnesses
This branch includes the following new commits:
new 06dc049d44 GROOVY-11664: STC: combine generics of same-type witnesses
The 1 revisions listed above as "new" are entirely new to this
repository and will be described in separate emails. The revisions
listed as "add" were already present in the repository and have only
been added to this reference.
(groovy) 01/01: GROOVY-11664: STC: combine generics of same-type witnesses
Posted by em...@apache.org.
This is an automated email from the ASF dual-hosted git repository.
emilles pushed a commit to branch GROOVY-11664
in repository https://gitbox.apache.org/repos/asf/groovy.git
commit 06dc049d444281b16ea28d8133d81afdb3e30231
Author: Eric Milles <er...@thomsonreuters.com>
AuthorDate: Thu May 22 12:04:18 2025 -0500
GROOVY-11664: STC: combine generics of same-type witnesses
---
.../groovy/transform/stc/StaticTypeCheckingSupport.java | 8 ++++++++
src/test/groovy/groovy/transform/stc/GenericsSTCTest.groovy | 13 +++++++++++++
2 files changed, 21 insertions(+)
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 2a57b95f6e..7d8a8edca0 100644
--- a/src/main/java/org/codehaus/groovy/transform/stc/StaticTypeCheckingSupport.java
+++ b/src/main/java/org/codehaus/groovy/transform/stc/StaticTypeCheckingSupport.java
@@ -1537,6 +1537,14 @@ public abstract class StaticTypeCheckingSupport {
}
return true; // incompatible
}
+ if (!fixedPlaceHolders.contains(entry.getKey())
+ && !resolved.isPlaceholder() && !resolved.isWildcard()
+ && !candidate.isPlaceholder() && !candidate.isWildcard()) {
+ // resolved "T=Object" and candidate "T=Object" or "T=String"; or
+ // GROOVY-11664: resolved "T=Class<A>" and candidate "T=Class<B>"
+ ClassNode oldT = resolved.getType(), newT = candidate.getType();
+ resolvedMethodGenerics.put(entry.getKey(), new GenericsType(lowestUpperBound(oldT, newT)));
+ }
}
connections.keySet().removeAll(fixedPlaceHolders); // GROOVY-10337
diff --git a/src/test/groovy/groovy/transform/stc/GenericsSTCTest.groovy b/src/test/groovy/groovy/transform/stc/GenericsSTCTest.groovy
index 332490a0cb..4e7ebc3833 100644
--- a/src/test/groovy/groovy/transform/stc/GenericsSTCTest.groovy
+++ b/src/test/groovy/groovy/transform/stc/GenericsSTCTest.groovy
@@ -263,6 +263,19 @@ class GenericsSTCTest extends StaticTypeCheckingTestCase {
def list = Arrays.asList(new A(), new B(), new C())
assert list.size() == 3
'''
+
+ // GROOVY-11664:
+ assertScript '''
+ class A {}
+ class B extends A {}
+ class C extends B {}
+ @ASTTest(phase=INSTRUCTION_SELECTION, value={
+ def type = node.getNodeMetaData(INFERRED_TYPE)
+ assert type.toString(false) == 'java.util.List<java.lang.Class<? extends A>>'
+ })
+ def list = Arrays.asList(A.class, B.class, C.class)
+ assert list.size() == 3
+ '''
}
// GROOVY-10062