Skip to content

Commit bea24fc

Browse files
committed
GROOVY-10807
1 parent 69f15cb commit bea24fc

File tree

3 files changed

+27
-2
lines changed

3 files changed

+27
-2
lines changed

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

+23
Original file line numberDiff line numberDiff line change
@@ -7931,4 +7931,27 @@ public void testCompileStatic10791() {
79317931

79327932
runConformTest(sources, "works");
79337933
}
7934+
7935+
@Test
7936+
public void testCompileStatic10807() {
7937+
assumeTrue(isParrotParser());
7938+
7939+
//@formatter:off
7940+
String[] sources = {
7941+
"Main.groovy",
7942+
"@groovy.transform.CompileStatic\n" +
7943+
"class C {\n" +
7944+
" public static final Comparator<String> BY_DISPLAY_NAME = Comparator.<String,String>comparing(C::getDisplayName)\n" +
7945+
" static String getDisplayName(String component) {\n" +
7946+
" return component\n" +
7947+
" }\n" +
7948+
"}\n" +
7949+
"def list = ['foo','bar','baz']\n" +
7950+
"list.sort(C.BY_DISPLAY_NAME)\n" +
7951+
"print list\n",
7952+
};
7953+
//@formatter:on
7954+
7955+
runConformTest(sources, "[bar, baz, foo]");
7956+
}
79347957
}

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

+2-1
Original file line numberDiff line numberDiff line change
@@ -3239,7 +3239,8 @@ protected void inferClosureParameterTypes(final ClassNode receiver, final Expres
32393239
Expression emc = typeCheckingContext.getEnclosingMethodCall();
32403240
if (emc instanceof MethodCallExpression) {
32413241
MethodCallExpression mce = (MethodCallExpression) emc;
3242-
if (mce.getArguments() == arguments) {
3242+
if (mce.getArguments() == arguments // GROOVY-10807 ::
3243+
|| expression.getCode() == GENERATED_EMPTY_STATEMENT){
32433244
GenericsType[] typeArguments = mce.getGenericsTypes();
32443245
if (typeArguments != null) {
32453246
int n = typeParameters.length;

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

+2-1
Original file line numberDiff line numberDiff line change
@@ -2979,7 +2979,8 @@ protected void inferClosureParameterTypes(final ClassNode receiver, final Expres
29792979
Expression emc = typeCheckingContext.getEnclosingMethodCall();
29802980
if (emc instanceof MethodCallExpression) {
29812981
MethodCallExpression mce = (MethodCallExpression) emc;
2982-
if (mce.getArguments() == arguments) {
2982+
if (mce.getArguments() == arguments // GROOVY-10807 ::
2983+
|| expression.getCode() == GENERATED_EMPTY_STATEMENT){
29832984
GenericsType[] typeArguments = mce.getGenericsTypes();
29842985
if (typeArguments != null) {
29852986
int n = typeParameters.length;

0 commit comments

Comments
 (0)