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/05/17 19:58:33 UTC
[groovy] branch GROOVY_4_0_X updated: GROOVY-10624: add test case
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 7e53af5ae9 GROOVY-10624: add test case
7e53af5ae9 is described below
commit 7e53af5ae925d143d810e569266624d4d098780d
Author: Eric Milles <er...@thomsonreuters.com>
AuthorDate: Tue May 17 14:10:33 2022 -0500
GROOVY-10624: add test case
---
.../groovy/transform/stc/StaticTypeCheckingVisitor.java | 2 +-
src/test/groovy/transform/stc/GenericsSTCTest.groovy | 14 +++++++++++++-
2 files changed, 14 insertions(+), 2 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 5b61567007..1959534633 100644
--- a/src/main/java/org/codehaus/groovy/transform/stc/StaticTypeCheckingVisitor.java
+++ b/src/main/java/org/codehaus/groovy/transform/stc/StaticTypeCheckingVisitor.java
@@ -2286,7 +2286,7 @@ public class StaticTypeCheckingVisitor extends ClassCodeVisitorSupport {
&& parameters.length == argumentTypes.length - 1) {
ctor = typeCheckMapConstructor(call, receiver, arguments);
} else {
- if (asBoolean(receiver.getGenericsTypes())) { // GROOVY-10283, GROOVY-10316, GROOVY-10482, et al.
+ if (asBoolean(receiver.getGenericsTypes())) { // GROOVY-10283, GROOVY-10316, GROOVY-10482, GROOVY-10624, et al.
Map<GenericsTypeName, GenericsType> context = extractPlaceHoldersVisibleToDeclaration(receiver, ctor, argumentList);
parameters = Arrays.stream(parameters).map(p -> new Parameter(applyGenericsContext(context, p.getType()), p.getName())).toArray(Parameter[]::new);
}
diff --git a/src/test/groovy/transform/stc/GenericsSTCTest.groovy b/src/test/groovy/transform/stc/GenericsSTCTest.groovy
index 7967c9a586..9e1f53534f 100644
--- a/src/test/groovy/transform/stc/GenericsSTCTest.groovy
+++ b/src/test/groovy/transform/stc/GenericsSTCTest.groovy
@@ -1301,7 +1301,19 @@ class GenericsSTCTest extends StaticTypeCheckingTestCase {
A<T> p
}
def b = new B<>(new A<>(1L))
- A<Long> x = b.p // Cannot assign A<Object> to: A<Long>
+ A<Long> x = b.p // Cannot assign A<Object> to A<Long>
+ '''
+ }
+
+ // GROOVY-10624
+ void testDiamondInferrenceFromConstructor29() {
+ assertScript '''
+ class A<T> {
+ }
+ class B<T> {
+ B(A<T> a) { }
+ }
+ B<Float> x = new B<>(new A<>()) // Cannot assign B<Object> to B<Float>
'''
}