You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@groovy.apache.org by em...@apache.org on 2020/10/07 01:49:15 UTC
[groovy] branch GROOVY-9771 created (now fbe5a4c)
This is an automated email from the ASF dual-hosted git repository.
emilles pushed a change to branch GROOVY-9771
in repository https://gitbox.apache.org/repos/asf/groovy.git.
at fbe5a4c GROOVY-9771: visit receiver for private field access
This branch includes the following new commits:
new fbe5a4c GROOVY-9771: visit receiver for private field access
The 1 revisions listed above as "new" are entirely new to this
repository and will be described in separate emails. The revisions
listed as "add" were already present in the repository and have only
been added to this reference.
[groovy] 01/01: GROOVY-9771: visit receiver for private field access
Posted by em...@apache.org.
This is an automated email from the ASF dual-hosted git repository.
emilles pushed a commit to branch GROOVY-9771
in repository https://gitbox.apache.org/repos/asf/groovy.git
commit fbe5a4c44df1d070ac50326967791d35d86e71ed
Author: Eric Milles <er...@thomsonreuters.com>
AuthorDate: Tue Oct 6 20:48:58 2020 -0500
GROOVY-9771: visit receiver for private field access
---
.../StaticTypesBinaryExpressionMultiTypeDispatcher.java | 3 +++
.../groovy/classgen/asm/sc/bugs/Groovy7361Bug.groovy | 16 ++++++++++++++++
2 files changed, 19 insertions(+)
diff --git a/src/main/java/org/codehaus/groovy/classgen/asm/sc/StaticTypesBinaryExpressionMultiTypeDispatcher.java b/src/main/java/org/codehaus/groovy/classgen/asm/sc/StaticTypesBinaryExpressionMultiTypeDispatcher.java
index 6df100c..9ad87e9 100644
--- a/src/main/java/org/codehaus/groovy/classgen/asm/sc/StaticTypesBinaryExpressionMultiTypeDispatcher.java
+++ b/src/main/java/org/codehaus/groovy/classgen/asm/sc/StaticTypesBinaryExpressionMultiTypeDispatcher.java
@@ -44,6 +44,7 @@ import org.codehaus.groovy.classgen.asm.VariableSlotLoader;
import org.codehaus.groovy.classgen.asm.WriterController;
import org.codehaus.groovy.syntax.Token;
import org.codehaus.groovy.syntax.TokenUtil;
+import org.codehaus.groovy.transform.sc.StaticCompilationVisitor;
import org.objectweb.asm.Label;
import org.objectweb.asm.MethodVisitor;
@@ -401,6 +402,8 @@ public class StaticTypesBinaryExpressionMultiTypeDispatcher extends BinaryExpres
if (rhsValueLoader instanceof VariableSlotLoader && enclosing instanceof BinaryExpression) {
rhsValueLoader.putNodeMetaData(INFERRED_TYPE, controller.getTypeChooser().resolveType(enclosing, controller.getClassNode()));
}
+ // GROOVY-9771
+ receiver.visit(new StaticCompilationVisitor(controller.getSourceUnit(), controller.getClassNode()));
// replace assignment to a subscript operator with a method call
// e.g. x[5] = 10 -> methodCall(x, "putAt", [5, 10])
diff --git a/src/test/org/codehaus/groovy/classgen/asm/sc/bugs/Groovy7361Bug.groovy b/src/test/org/codehaus/groovy/classgen/asm/sc/bugs/Groovy7361Bug.groovy
index 9878851..1a26703 100644
--- a/src/test/org/codehaus/groovy/classgen/asm/sc/bugs/Groovy7361Bug.groovy
+++ b/src/test/org/codehaus/groovy/classgen/asm/sc/bugs/Groovy7361Bug.groovy
@@ -87,4 +87,20 @@ final class Groovy7361Bug extends StaticTypeCheckingTestCase implements StaticCo
new B().checkMap()
'''
}
+
+ // GROOVY-9771
+ void testShouldNotThrowClassCastExceptionForSubscriptPrivateAccess() {
+ assertScript '''
+ class C {
+ private final Map<String, Boolean> map = [:]
+ void checkMap() {
+ { ->
+ map['key'] = true
+ }.call()
+ assert map == [key: true]
+ }
+ }
+ new C().checkMap()
+ '''
+ }
}