Skip to content

Commit

Permalink
GROOVY-10269
Browse files Browse the repository at this point in the history
  • Loading branch information
eric-milles committed Oct 12, 2021
1 parent 904bb93 commit 267a782
Show file tree
Hide file tree
Showing 3 changed files with 37 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -3985,6 +3985,37 @@ public void testTypeChecked10254() {
runConformTest(sources, "42");
}

@Test
public void testTypeChecked10269() {
assumeTrue(isParrotParser());

//@formatter:off
String[] sources = {
"Main.groovy",
"import java.util.function.Consumer\n" +
"void foo(Integer y) {\n" +
"}\n" +
"void bar(Consumer<Integer> x) {\n" +
"}\n" +
"@groovy.transform.TypeChecked\n" +
"void test() {\n" +
" def baz = { Consumer<Integer> x -> }\n" +
" bar(this::foo)\n" +
" baz(this::foo)\n" +
"}\n" +
"test()\n",
};
//@formatter:on

runNegativeTest(sources,
"----------\n" +
"1. ERROR in Main.groovy (at line 10)\n" +
"\tbaz(this::foo)\n" +
"\t ^^^^^^^^^\n" +
"Groovy:The argument is a method reference, but the parameter type is not a functional interface\n" +
"----------\n");
}

@Test
public void testTypeChecked10280() {
//@formatter:off
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4060,7 +4060,9 @@ private void inferMethodReferenceType(final ClassNode receiver, final ArgumentLi
methodReferenceParamIndexList.add(i);
}
}

// GRECLIPSE add -- GROOVY-10269
if (methodReferenceParamIndexList.isEmpty()) return;
// GRECLIPSE end
visitMethodCallArguments(receiver, new ArgumentListExpression(newArgumentExpressionList), true, selectedMethod);

for (Integer methodReferenceParamIndex : methodReferenceParamIndexList) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3818,7 +3818,9 @@ private void inferMethodReferenceType(final ClassNode receiver, final ArgumentLi
methodReferenceParamIndexList.add(i);
}
}

// GRECLIPSE add -- GROOVY-10269
if (methodReferenceParamIndexList.isEmpty()) return;
// GRECLIPSE end
visitMethodCallArguments(receiver, args(newArgumentExpressionList), true, selectedMethod);

for (int index : methodReferenceParamIndexList) {
Expand Down

0 comments on commit 267a782

Please sign in to comment.