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 2018/02/09 01:05:41 UTC
[2/2] groovy git commit: Refine the fix of GROOVY-8474: support
primitive type
Refine the fix of GROOVY-8474: support primitive type
(cherry picked from commit 05866b3)
Project: http://git-wip-us.apache.org/repos/asf/groovy/repo
Commit: http://git-wip-us.apache.org/repos/asf/groovy/commit/2d60daf6
Tree: http://git-wip-us.apache.org/repos/asf/groovy/tree/2d60daf6
Diff: http://git-wip-us.apache.org/repos/asf/groovy/diff/2d60daf6
Branch: refs/heads/GROOVY_2_6_X
Commit: 2d60daf6f91fdc4a855e9d043c8a401b4c456abc
Parents: 6541df3
Author: sunlan <su...@apache.org>
Authored: Fri Feb 9 09:01:32 2018 +0800
Committer: sunlan <su...@apache.org>
Committed: Fri Feb 9 09:05:14 2018 +0800
----------------------------------------------------------------------
.../groovy/classgen/AsmClassGenerator.java | 7 +-
src/test/groovy/bugs/Groovy8474Bug.groovy | 128 +++++++++++++++++++
2 files changed, 134 insertions(+), 1 deletion(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/groovy/blob/2d60daf6/src/main/java/org/codehaus/groovy/classgen/AsmClassGenerator.java
----------------------------------------------------------------------
diff --git a/src/main/java/org/codehaus/groovy/classgen/AsmClassGenerator.java b/src/main/java/org/codehaus/groovy/classgen/AsmClassGenerator.java
index e7cb2fe..8123e83 100644
--- a/src/main/java/org/codehaus/groovy/classgen/AsmClassGenerator.java
+++ b/src/main/java/org/codehaus/groovy/classgen/AsmClassGenerator.java
@@ -1103,8 +1103,13 @@ public class AsmClassGenerator extends ClassGenerator {
throw new RuntimeParserException("Cannot access private field[" + fieldName + "] of " + classNode.getName() + "'s super class", expression);
}
+ OperandStack operandStack = controller.getOperandStack();
+ operandStack.doAsType(fieldNode.getType());
+
mv.visitVarInsn(ALOAD, 0);
- mv.visitInsn(SWAP);
+ operandStack.push(classNode);
+
+ operandStack.swap();
String owner = BytecodeHelper.getClassInternalName(classNode.getSuperClass().getName());
String desc = BytecodeHelper.getTypeDescription(fieldNode.getType());
http://git-wip-us.apache.org/repos/asf/groovy/blob/2d60daf6/src/test/groovy/bugs/Groovy8474Bug.groovy
----------------------------------------------------------------------
diff --git a/src/test/groovy/bugs/Groovy8474Bug.groovy b/src/test/groovy/bugs/Groovy8474Bug.groovy
index 7a6f397..ab64c75 100644
--- a/src/test/groovy/bugs/Groovy8474Bug.groovy
+++ b/src/test/groovy/bugs/Groovy8474Bug.groovy
@@ -104,6 +104,134 @@ class Groovy8474Bug extends GroovyTestCase {
'''
}
+ void testSettingSuperProperty5() {
+ assertScript '''
+ class T {
+ Integer group
+ }
+
+ class S extends T {
+ S() {
+ super.group = 1
+ }
+ }
+
+ assert 1 == new S().group
+ '''
+ }
+
+ void testSettingSuperProperty6() {
+ assertScript '''
+ class T {
+ Long group
+ }
+
+ class S extends T {
+ S() {
+ super.group = 1
+ }
+ }
+
+ assert 1 == new S().group
+ '''
+ }
+
+ void testSettingSuperProperty7() {
+ assertScript '''
+ class T {
+ Long group
+ }
+
+ class S extends T {
+ S() {
+ super.group = Long.MAX_VALUE
+ }
+ }
+
+ assert Long.MAX_VALUE == new S().group
+ '''
+ }
+
+ void testSettingSuperProperty8() {
+ assertScript '''
+ class T {
+ int group
+ }
+
+ class S extends T {
+ S() {
+ super.group = Integer.MAX_VALUE
+ }
+ }
+
+ assert Integer.MAX_VALUE == new S().group
+ '''
+ }
+
+ void testSettingSuperProperty9() {
+ assertScript '''
+ class T {
+ long group
+ }
+
+ class S extends T {
+ S() {
+ super.group = Long.MAX_VALUE
+ }
+ }
+
+ assert Long.MAX_VALUE == new S().group
+ '''
+ }
+
+ void testSettingSuperProperty10() {
+ assertScript '''
+ class T {
+ int group
+ }
+
+ class S extends T {
+ S() {
+ super.group = 1
+ }
+ }
+
+ assert 1 == new S().group
+ '''
+ }
+
+ void testSettingSuperProperty11() {
+ assertScript '''
+ class T {
+ long group
+ }
+
+ class S extends T {
+ S() {
+ super.group = 123456789123456789
+ }
+ }
+
+ assert 123456789123456789 == new S().group
+ '''
+ }
+
+ void testSettingSuperProperty12() {
+ assertScript '''
+ class T {
+ boolean group
+ }
+
+ class S extends T {
+ S() {
+ super.group = true
+ }
+ }
+
+ assert true == new S().group
+ '''
+ }
+
void testSettingSuperProtectedField() {
assertScript '''
class T {