This is an automated email from the ASF dual-hosted git repository.
emilles pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/groovy.git
The following commit(s) were added to refs/heads/master by this push:
new cba20a0afe GROOVY-11092: STC (MCE): lambda argument destructuring
cba20a0afe is described below
commit cba20a0afe3bec185db87c20b769ad37c8180b30
Author: Eric Milles <[email protected]>
AuthorDate: Tue Jun 13 12:39:20 2023 -0500
GROOVY-11092: STC (MCE): lambda argument destructuring
---
.../org/codehaus/groovy/classgen/asm/sc/StaticInvocationWriter.java | 6 ------
src/test/groovy/transform/stc/LambdaTest.groovy | 6 ++++++
2 files changed, 6 insertions(+), 6 deletions(-)
diff --git
a/src/main/java/org/codehaus/groovy/classgen/asm/sc/StaticInvocationWriter.java
b/src/main/java/org/codehaus/groovy/classgen/asm/sc/StaticInvocationWriter.java
index 8a147fd9b3..4631287a4d 100644
---
a/src/main/java/org/codehaus/groovy/classgen/asm/sc/StaticInvocationWriter.java
+++
b/src/main/java/org/codehaus/groovy/classgen/asm/sc/StaticInvocationWriter.java
@@ -36,9 +36,7 @@ import org.codehaus.groovy.ast.expr.ConstantExpression;
import org.codehaus.groovy.ast.expr.ConstructorCallExpression;
import org.codehaus.groovy.ast.expr.Expression;
import org.codehaus.groovy.ast.expr.ExpressionTransformer;
-import org.codehaus.groovy.ast.expr.LambdaExpression;
import org.codehaus.groovy.ast.expr.MethodCallExpression;
-import org.codehaus.groovy.ast.expr.MethodReferenceExpression;
import org.codehaus.groovy.ast.expr.PropertyExpression;
import org.codehaus.groovy.ast.expr.SpreadExpression;
import org.codehaus.groovy.ast.expr.TupleExpression;
@@ -519,10 +517,6 @@ public class StaticInvocationWriter extends
InvocationWriter {
}
private void visitArgument(final Expression argument, final ClassNode
parameterType) {
- if (argument instanceof LambdaExpression || argument instanceof
MethodReferenceExpression) {
- // ensure target type available to the argument expression's
bytecode generator
- argument.getNodeMetaData(StaticTypesMarker.PARAMETER_TYPE, x ->
parameterType);
- }
argument.visit(controller.getAcg());
if (!isNullConstant(argument)) {
controller.getOperandStack().doGroovyCast(parameterType);
diff --git a/src/test/groovy/transform/stc/LambdaTest.groovy
b/src/test/groovy/transform/stc/LambdaTest.groovy
index 9999f92cac..b97fea6f82 100644
--- a/src/test/groovy/transform/stc/LambdaTest.groovy
+++ b/src/test/groovy/transform/stc/LambdaTest.groovy
@@ -828,6 +828,12 @@ final class LambdaTest {
}
fun = (one,two) -> { one + two }
'''
+ assertScript shell, '''
+ void test(Function<List<String>,String> f) {
+ assert f.apply(['foo','bar']) == 'foobar'
+ }
+ test((one, two) -> { one + two })
+ '''
}
@Test