Skip to content

Commit 623da1d

Browse files
committed
GROOVY-9906
1 parent 9647879 commit 623da1d

File tree

4 files changed

+36
-0
lines changed

4 files changed

+36
-0
lines changed

base-test/org.eclipse.jdt.groovy.core.tests.compiler/src/org/eclipse/jdt/groovy/core/tests/basic/GroovySimpleTests.java

+21
Original file line numberDiff line numberDiff line change
@@ -4618,6 +4618,27 @@ public void testGroovy9336() {
46184618
runConformTest(sources, "65536.0");
46194619
}
46204620

4621+
@Test // https://issues.apache.org/jira/browse/GROOVY-9906
4622+
public void testGroovy9906() {
4623+
//@formatter:off
4624+
String[] sources = {
4625+
"Main.groovy",
4626+
"abstract class A {\n" +
4627+
" void m(String a, String b, String c) {}\n" +
4628+
" void m(String a, String... zeroPlus) {}\n" +
4629+
"}\n" +
4630+
"class C extends A {\n" +
4631+
" void test() {\n" +
4632+
" m('x', 'y', 'z')\n" + // ArrayIndexOutOfBoundsException: Index 2 out of bounds for length 2
4633+
" }\n" +
4634+
"}\n" +
4635+
"new C().test()\n",
4636+
};
4637+
//@formatter:on
4638+
4639+
runConformTest(sources, "");
4640+
}
4641+
46214642
// was worried <clinit> would surface in list of methods used to build the type declaration, but that doesn't appear to be the case
46224643
@Test
46234644
public void testExtendingGroovyObjects_clinit() {

base/org.codehaus.groovy25/src/org/codehaus/groovy/ast/ClassNode.java

+5
Original file line numberDiff line numberDiff line change
@@ -1420,8 +1420,13 @@ public MethodNode tryFindPossibleMethod(final String name, final Expression argu
14201420

14211421
private boolean hasExactMatchingCompatibleType(MethodNode current, MethodNode newCandidate, int i) {
14221422
int lastParamIndex = newCandidate.getParameters().length - 1;
1423+
/* GRECLIPSE edit -- GROOVY-9906
14231424
return current.getParameters()[i].getType().equals(newCandidate.getParameters()[i].getType())
14241425
|| (isPotentialVarArg(newCandidate, lastParamIndex) && i >= lastParamIndex && current.getParameters()[i].getType().equals(newCandidate.getParameters()[lastParamIndex].getType().componentType));
1426+
*/
1427+
return (i <= lastParamIndex && current.getParameters()[i].getType().equals(newCandidate.getParameters()[i].getType()))
1428+
|| (i >= lastParamIndex && isPotentialVarArg(newCandidate, lastParamIndex) && current.getParameters()[i].getType().equals(newCandidate.getParameters()[lastParamIndex].getType().getComponentType()));
1429+
// GRECLIPSE end
14251430
}
14261431

14271432
private boolean hasCompatibleType(TupleExpression args, MethodNode method, int i) {

base/org.codehaus.groovy30/src/org/codehaus/groovy/ast/ClassNode.java

+5
Original file line numberDiff line numberDiff line change
@@ -1384,8 +1384,13 @@ public MethodNode tryFindPossibleMethod(final String name, final Expression argu
13841384

13851385
private boolean hasExactMatchingCompatibleType(MethodNode current, MethodNode newCandidate, int i) {
13861386
int lastParamIndex = newCandidate.getParameters().length - 1;
1387+
/* GRECLIPSE edit -- GROOVY-9906
13871388
return current.getParameters()[i].getType().equals(newCandidate.getParameters()[i].getType())
13881389
|| (isPotentialVarArg(newCandidate, lastParamIndex) && i >= lastParamIndex && current.getParameters()[i].getType().equals(newCandidate.getParameters()[lastParamIndex].getType().componentType));
1390+
*/
1391+
return (i <= lastParamIndex && current.getParameters()[i].getType().equals(newCandidate.getParameters()[i].getType()))
1392+
|| (i >= lastParamIndex && isPotentialVarArg(newCandidate, lastParamIndex) && current.getParameters()[i].getType().equals(newCandidate.getParameters()[lastParamIndex].getType().getComponentType()));
1393+
// GRECLIPSE end
13891394
}
13901395

13911396
private boolean hasCompatibleType(TupleExpression args, MethodNode method, int i) {

base/org.codehaus.groovy40/src/org/codehaus/groovy/ast/ClassNode.java

+5
Original file line numberDiff line numberDiff line change
@@ -1403,8 +1403,13 @@ public MethodNode tryFindPossibleMethod(final String name, final Expression argu
14031403

14041404
private boolean hasExactMatchingCompatibleType(MethodNode current, MethodNode newCandidate, int i) {
14051405
int lastParamIndex = newCandidate.getParameters().length - 1;
1406+
/* GRECLIPSE edit -- GROOVY-9906
14061407
return current.getParameters()[i].getType().equals(newCandidate.getParameters()[i].getType())
14071408
|| (isPotentialVarArg(newCandidate, lastParamIndex) && i >= lastParamIndex && current.getParameters()[i].getType().equals(newCandidate.getParameters()[lastParamIndex].getType().componentType));
1409+
*/
1410+
return (i <= lastParamIndex && current.getParameters()[i].getType().equals(newCandidate.getParameters()[i].getType()))
1411+
|| (i >= lastParamIndex && isPotentialVarArg(newCandidate, lastParamIndex) && current.getParameters()[i].getType().equals(newCandidate.getParameters()[lastParamIndex].getType().getComponentType()));
1412+
// GRECLIPSE end
14081413
}
14091414

14101415
private boolean hasCompatibleType(TupleExpression args, MethodNode method, int i) {

0 commit comments

Comments
 (0)