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/03/15 17:01:46 UTC
[groovy] branch GROOVY-9984 created (now 3c18276)
This is an automated email from the ASF dual-hosted git repository.
emilles pushed a change to branch GROOVY-9984
in repository https://gitbox.apache.org/repos/asf/groovy.git.
at 3c18276 GROOVY-9984: don't use null arguments for return type generics inference
This branch includes the following new commits:
new 3c18276 GROOVY-9984: don't use null arguments for return type generics inference
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-9984: don't use null arguments for return
type generics inference
Posted by em...@apache.org.
This is an automated email from the ASF dual-hosted git repository.
emilles pushed a commit to branch GROOVY-9984
in repository https://gitbox.apache.org/repos/asf/groovy.git
commit 3c18276a5c404b5954712ebdb643aa5b05968008
Author: Eric Milles <er...@thomsonreuters.com>
AuthorDate: Mon Mar 15 11:26:13 2021 -0500
GROOVY-9984: don't use null arguments for return type generics inference
---
.../groovy/transform/stc/StaticTypeCheckingVisitor.java | 2 ++
src/test/groovy/transform/stc/GenericsSTCTest.groovy | 15 ++++++++++++++-
2 files changed, 16 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 75147ff..53495ff 100644
--- a/src/main/java/org/codehaus/groovy/transform/stc/StaticTypeCheckingVisitor.java
+++ b/src/main/java/org/codehaus/groovy/transform/stc/StaticTypeCheckingVisitor.java
@@ -5147,6 +5147,8 @@ public class StaticTypeCheckingVisitor extends ClassCodeVisitorSupport {
int paramLength = parameters.length;
if (expressions.size() >= paramLength) {
for (int i = 0; i < paramLength; i += 1) {
+ if (isNullConstant(expressions.get(i)))
+ continue; // GROOVY-9984: skip null
boolean lastArg = (i == paramLength - 1);
ClassNode paramType = parameters[i].getType();
ClassNode argumentType = getType(expressions.get(i));
diff --git a/src/test/groovy/transform/stc/GenericsSTCTest.groovy b/src/test/groovy/transform/stc/GenericsSTCTest.groovy
index ee6153e..79bbcf2 100644
--- a/src/test/groovy/transform/stc/GenericsSTCTest.groovy
+++ b/src/test/groovy/transform/stc/GenericsSTCTest.groovy
@@ -270,7 +270,7 @@ class GenericsSTCTest extends StaticTypeCheckingTestCase {
// GROOVY-9948
void testDiamondInferrenceFromConstructor7() {
assertScript '''
- @groovy.transform.TupleConstructor
+ @groovy.transform.TupleConstructor(defaults=false)
class C<T> {
T p
}
@@ -280,6 +280,19 @@ class GenericsSTCTest extends StaticTypeCheckingTestCase {
'''
}
+ // GROOVY-9984
+ void testDiamondInferrenceFromConstructor7a() {
+ assertScript '''
+ @groovy.transform.TupleConstructor(defaults=false)
+ class C<T> {
+ T p
+ }
+
+ C<Integer> c = new C<>(null)
+ assert c.p === null
+ '''
+ }
+
// GROOVY-9956
void testDiamondInferrenceFromConstructor8() {
assertScript '''