Skip to content

Commit 35b49a1

Browse files
committed
GROOVY-9984
1 parent fcbfaab commit 35b49a1

File tree

4 files changed

+30
-0
lines changed

4 files changed

+30
-0
lines changed

base-test/org.eclipse.jdt.groovy.core.tests.compiler/src/org/eclipse/jdt/groovy/core/tests/xform/TypeCheckedTests.java

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1315,6 +1315,27 @@ public void testTypeChecked9977() {
13151315
runConformTest(sources, "-1");
13161316
}
13171317

1318+
@Test
1319+
public void testTypeChecked9984() {
1320+
//@formatter:off
1321+
String[] sources = {
1322+
"Main.groovy",
1323+
"@groovy.transform.TupleConstructor(defaults=false)\n" +
1324+
"class C<T> {\n" +
1325+
" T p\n" +
1326+
"}\n" +
1327+
"@groovy.transform.TypeChecked\n" +
1328+
"void test() {\n" +
1329+
" C<Integer> c = new C<>(null)\n" +
1330+
" print c.p\n" +
1331+
"}\n" +
1332+
"test()\n",
1333+
};
1334+
//@formatter:on
1335+
1336+
runConformTest(sources, "null");
1337+
}
1338+
13181339
@Test
13191340
public void testTypeChecked9991() {
13201341
if (Float.parseFloat(System.getProperty("java.specification.version")) > 8)

base/org.codehaus.groovy25/src/org/codehaus/groovy/transform/stc/StaticTypeCheckingVisitor.java

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5675,6 +5675,9 @@ protected ClassNode inferReturnTypeGenerics(
56755675
int paramLength = parameters.length;
56765676
if (expressions.size() >= paramLength) {
56775677
for (int i = 0; i < paramLength; i += 1) {
5678+
// GRECLIPSE add -- GROOVY-9984: skip null
5679+
if (isNullConstant(expressions.get(i))) continue;
5680+
// GRECLIPSE end
56785681
boolean lastArg = (i == paramLength - 1);
56795682
ClassNode type = parameters[i].getType();
56805683
/* GRECLIPSE edit -- GROOVY-9996

base/org.codehaus.groovy30/src/org/codehaus/groovy/transform/stc/StaticTypeCheckingVisitor.java

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5437,6 +5437,9 @@ protected ClassNode inferReturnTypeGenerics(final ClassNode receiver, final Meth
54375437
int paramLength = parameters.length;
54385438
if (expressions.size() >= paramLength) {
54395439
for (int i = 0; i < paramLength; i += 1) {
5440+
// GRECLIPSE add -- GROOVY-9984: skip null
5441+
if (isNullConstant(expressions.get(i))) continue;
5442+
// GRECLIPSE end
54405443
boolean lastArg = (i == paramLength - 1);
54415444
ClassNode paramType = parameters[i].getType();
54425445
/* GRECLIPSE edit -- GROOVY-9996

base/org.codehaus.groovy40/src/org/codehaus/groovy/transform/stc/StaticTypeCheckingVisitor.java

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5403,6 +5403,9 @@ protected ClassNode inferReturnTypeGenerics(final ClassNode receiver, final Meth
54035403
int paramLength = parameters.length;
54045404
if (expressions.size() >= paramLength) {
54055405
for (int i = 0; i < paramLength; i += 1) {
5406+
// GRECLIPSE add -- GROOVY-9984: skip null
5407+
if (isNullConstant(expressions.get(i))) continue;
5408+
// GRECLIPSE end
54065409
boolean lastArg = (i == paramLength - 1);
54075410
ClassNode paramType = parameters[i].getType();
54085411
/* GRECLIPSE edit -- GROOVY-9996

0 commit comments

Comments
 (0)