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 c8e2dc27bc GROOVY-9995: infer ctor call diamond type from closure
target type
c8e2dc27bc is described below
commit c8e2dc27bc4ec406058bee35e26afb40c4ce822d
Author: Eric Milles <[email protected]>
AuthorDate: Tue Sep 6 08:24:52 2022 -0500
GROOVY-9995: infer ctor call diamond type from closure target type
---
.../org/codehaus/groovy/transform/stc/StaticTypeCheckingVisitor.java | 4 ++++
src/test/groovy/transform/stc/GenericsSTCTest.groovy | 2 +-
2 files changed, 5 insertions(+), 1 deletion(-)
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 95298fe936..545e9ad736 100644
---
a/src/main/java/org/codehaus/groovy/transform/stc/StaticTypeCheckingVisitor.java
+++
b/src/main/java/org/codehaus/groovy/transform/stc/StaticTypeCheckingVisitor.java
@@ -2258,6 +2258,10 @@ public class StaticTypeCheckingVisitor extends
ClassCodeVisitorSupport {
}
if (typeCheckingContext.getEnclosingClosure() != null) {
ClassNode inferredReturnType =
getInferredReturnType(typeCheckingContext.getEnclosingClosure().getClosureExpression());
+ // GROOVY-9995: return ctor call with diamond operator
+ if (expression instanceof ConstructorCallExpression) {
+ if (inferredReturnType != null)
inferDiamondType((ConstructorCallExpression) expression, inferredReturnType);
+ }
if (STRING_TYPE.equals(inferredReturnType) &&
StaticTypeCheckingSupport.isGStringOrGStringStringLUB(type)) {
type = STRING_TYPE; // GROOVY-9971: implicit "toString()"
before return
}
diff --git a/src/test/groovy/transform/stc/GenericsSTCTest.groovy
b/src/test/groovy/transform/stc/GenericsSTCTest.groovy
index bee56d40e3..0f05adc431 100644
--- a/src/test/groovy/transform/stc/GenericsSTCTest.groovy
+++ b/src/test/groovy/transform/stc/GenericsSTCTest.groovy
@@ -727,7 +727,7 @@ class GenericsSTCTest extends StaticTypeCheckingTestCase {
'''
}
- @NotYetImplemented // GROOVY-9995
+ // GROOVY-9995
void testDiamondInferrenceFromConstructor15() {
[
['Closure<A<Long>>', 'java.util.concurrent.Callable<A<Long>>'],