groovy-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From emil...@apache.org
Subject [groovy] 01/01: GROOVY-9341: fix "this" support for nested lambda expressions
Date Thu, 19 Dec 2019 00:39:22 GMT
This is an automated email from the ASF dual-hosted git repository.

emilles pushed a commit to branch GROOVY-9341
in repository https://gitbox.apache.org/repos/asf/groovy.git

commit be8fa032ef236f2bced98a8d89b45b110687d5b1
Author: Eric Milles <eric.milles@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()
---
 .../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


Mime
View raw message