Skip to content

Commit 17ad59d

Browse files
committed
GROOVY-8499
1 parent 9f1a3b4 commit 17ad59d

File tree

4 files changed

+36
-1
lines changed

4 files changed

+36
-1
lines changed

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

+22
Original file line numberDiff line numberDiff line change
@@ -2821,6 +2821,28 @@ public void testCompileStatic8487() {
28212821
}
28222822
}
28232823

2824+
@Test
2825+
public void testCompileStatic8499() {
2826+
//@formatter:off
2827+
String[] sources = {
2828+
"Main.groovy",
2829+
"@groovy.transform.CompileStatic\n" +
2830+
"void test() {\n" +
2831+
" [].stream().map{item,xxxx ->}\n" +
2832+
"}\n" +
2833+
"test()\n",
2834+
};
2835+
//@formatter:on
2836+
2837+
runNegativeTest(sources,
2838+
"----------\n" +
2839+
"1. ERROR in Main.groovy (at line 3)\n" +
2840+
"\t[].stream().map{item,xxxx ->}\n" +
2841+
"\t ^^^^^^^^^^^^^^\n" +
2842+
"Groovy:Incorrect number of parameters. Expected 1 but found 2\n" +
2843+
"----------\n");
2844+
}
2845+
28242846
@Test
28252847
public void testCompileStatic8509() {
28262848
//@formatter:off

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

+4-1
Original file line numberDiff line numberDiff line change
@@ -3432,7 +3432,7 @@ protected void inferClosureParameterTypes(final ClassNode receiver, final Expres
34323432
doInferClosureParameterTypes(receiver, arguments, expression, selectedMethod, hintClass, resolverClass, options);
34333433
}
34343434
}
3435-
/* GRECLIPSE edit -- GROOVY-8917, GROOVY-9347, GROOVY-10047, GROOVY-10049
3435+
/* GRECLIPSE edit -- GROOVY-8499, GROOVY-8917, GROOVY-9347, GROOVY-10047, GROOVY-10049
34363436
} else if (isSAMType(param.getOriginType())) {
34373437
// SAM coercion
34383438
inferSAMType(param, receiver, selectedMethod, InvocationWriter.makeArgumentList(arguments), expression);
@@ -3506,6 +3506,9 @@ protected void inferClosureParameterTypes(final ClassNode receiver, final Expres
35063506
}
35073507
}
35083508
expression.putNodeMetaData(StaticTypesMarker.CLOSURE_ARGUMENTS, paramTypes);
3509+
if (paramTypes.length != samParamTypes.length) {
3510+
addError("Incorrect number of parameters. Expected " + samParamTypes.length + " but found " + paramTypes.length, expression);
3511+
}
35093512
}
35103513
}
35113514
// GRECLIPSE end

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

+5
Original file line numberDiff line numberDiff line change
@@ -3332,6 +3332,11 @@ protected void inferClosureParameterTypes(final ClassNode receiver, final Expres
33323332
paramTypes = Arrays.copyOf(samParamTypes, n);
33333333
}
33343334
expression.putNodeMetaData(CLOSURE_ARGUMENTS, paramTypes);
3335+
// GRECLIPSE add -- GROOVY-8499
3336+
if (paramTypes.length != samParamTypes.length) {
3337+
addError("Incorrect number of parameters. Expected " + samParamTypes.length + " but found " + paramTypes.length, expression);
3338+
}
3339+
// GRECLIPSE end
33353340
}
33363341
}
33373342
}

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

+5
Original file line numberDiff line numberDiff line change
@@ -3007,6 +3007,11 @@ protected void inferClosureParameterTypes(final ClassNode receiver, final Expres
30073007
}
30083008
}
30093009
expression.putNodeMetaData(CLOSURE_ARGUMENTS, paramTypes);
3010+
// GRECLIPSE add -- GROOVY-8499
3011+
if (paramTypes.length != samParamTypes.length) {
3012+
addError("Incorrect number of parameters. Expected " + samParamTypes.length + " but found " + paramTypes.length, expression);
3013+
}
3014+
// GRECLIPSE end
30103015
}
30113016
}
30123017
}

0 commit comments

Comments
 (0)