You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@groovy.apache.org by su...@apache.org on 2019/12/19 03:09:32 UTC
[groovy] 03/05: GROOVY-9341: fix "this" support for nested lambda
expressions
This is an automated email from the ASF dual-hosted git repository.
sunlan pushed a commit to branch GROOVY_3_0_X
in repository https://gitbox.apache.org/repos/asf/groovy.git
commit 11cf59c0d4a7a67cc695c11193236f4b8e32c557
Author: Eric Milles <er...@thomsonreuters.com>
AuthorDate: Wed Dec 18 18:29:03 2019 -0600
GROOVY-9341: fix "this" support for nested lambda expressions
ClosureWriter#loadThis() writes call to Closure#getThisObject()
(cherry picked from commit 3a883ef8b3a5fc71352dbf95c6f741d10e99e203)
---
.../org/codehaus/groovy/classgen/asm/sc/StaticTypesLambdaWriter.java | 3 +--
src/test/groovy/transform/stc/LambdaTest.groovy | 4 ++--
2 files changed, 3 insertions(+), 4 deletions(-)
diff --git a/src/main/java/org/codehaus/groovy/classgen/asm/sc/StaticTypesLambdaWriter.java b/src/main/java/org/codehaus/groovy/classgen/asm/sc/StaticTypesLambdaWriter.java
index cfce5c5..67cf98e 100644
--- a/src/main/java/org/codehaus/groovy/classgen/asm/sc/StaticTypesLambdaWriter.java
+++ b/src/main/java/org/codehaus/groovy/classgen/asm/sc/StaticTypesLambdaWriter.java
@@ -177,8 +177,7 @@ public class StaticTypesLambdaWriter extends LambdaWriter implements AbstractFun
if (controller.isStaticMethod() || compileStack.isInSpecialConstructorCall() || !accessingInstanceMembers) {
operandStack.pushConstant(ConstantExpression.NULL);
} else {
- mv.visitVarInsn(ALOAD, 0);
- operandStack.push(controller.getClassNode());
+ loadThis();
}
operandStack.dup();
diff --git a/src/test/groovy/transform/stc/LambdaTest.groovy b/src/test/groovy/transform/stc/LambdaTest.groovy
index 48cf528..ac3f138 100644
--- a/src/test/groovy/transform/stc/LambdaTest.groovy
+++ b/src/test/groovy/transform/stc/LambdaTest.groovy
@@ -1031,7 +1031,7 @@ final class LambdaTest {
'''
}
- @Test @NotYetImplemented
+ @Test
void testNestedLambdaAccessingInstanceFields() {
assertScript '''
@groovy.transform.CompileStatic
@@ -1097,7 +1097,7 @@ final class LambdaTest {
'''
}
- @Test @NotYetImplemented
+ @Test
void testAccessingThis2() {
assertScript '''
@groovy.transform.CompileStatic