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 2019/11/26 18:51:36 UTC
[groovy] branch master updated: add test case for super attribte
expression
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 528fde0 add test case for super attribte expression
528fde0 is described below
commit 528fde0edb57b4c369c6e224afa4b06fd0f5fda8
Author: Eric Milles <er...@thomsonreuters.com>
AuthorDate: Tue Nov 26 12:51:30 2019 -0600
add test case for super attribte expression
---
.../groovy/classgen/AsmClassGenerator.java | 7 +++++++
.../groovy/classgen/asm/sc/bugs/Groovy7300.groovy | 22 +++++++++++++++++++++-
2 files changed, 28 insertions(+), 1 deletion(-)
diff --git a/src/main/java/org/codehaus/groovy/classgen/AsmClassGenerator.java b/src/main/java/org/codehaus/groovy/classgen/AsmClassGenerator.java
index 680aa30..825a278 100644
--- a/src/main/java/org/codehaus/groovy/classgen/AsmClassGenerator.java
+++ b/src/main/java/org/codehaus/groovy/classgen/AsmClassGenerator.java
@@ -1123,6 +1123,13 @@ public class AsmClassGenerator extends ClassGenerator {
if (field != null) {
visitFieldExpression(new FieldExpression(field));
visited = true;
+ } else if (isSuperExpression(objectExpression)) {
+ if (controller.getCompileStack().isLHS()) {
+ setPropertyOfSuperClass(classNode, expression, controller.getMethodVisitor());
+ } else {
+ visitMethodCallExpression(new MethodCallExpression(objectExpression, "get" + capitalize(name), MethodCallExpression.NO_ARGUMENTS));
+ }
+ visited = true;
}
}
}
diff --git a/src/test/org/codehaus/groovy/classgen/asm/sc/bugs/Groovy7300.groovy b/src/test/org/codehaus/groovy/classgen/asm/sc/bugs/Groovy7300.groovy
index 4cc1598..3fba642 100644
--- a/src/test/org/codehaus/groovy/classgen/asm/sc/bugs/Groovy7300.groovy
+++ b/src/test/org/codehaus/groovy/classgen/asm/sc/bugs/Groovy7300.groovy
@@ -46,7 +46,7 @@ final class Groovy7300 extends StaticTypeCheckingTestCase implements StaticCompi
'''
}
- void testShouldNotThrowStackOverflowWithSuper() {
+ void testShouldNotThrowStackOverflowWithSuper1() {
assertScript '''
class A {
private String field1 = 'test'
@@ -71,4 +71,24 @@ final class Groovy7300 extends StaticTypeCheckingTestCase implements StaticCompi
assert b.field1 == 'test 2'
'''
}
+
+ void testShouldNotThrowStackOverflowWithSuper2() {
+ assertScript '''
+ class A {
+ private String field = 'value'
+ String getField() { return field }
+ void setField(String value) { field = value }
+ }
+
+ class B extends A {
+ @Override
+ String getField() {
+ super.@field = 'reset'
+ return super.field
+ }
+ }
+
+ assert new B().field == 'reset'
+ '''
+ }
}