You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@groovy.apache.org by cc...@apache.org on 2015/05/18 21:38:14 UTC
incubator-groovy git commit: GROOVY-7381: Setters with non-void
return type fail at runtime when statically compiled
Repository: incubator-groovy
Updated Branches:
refs/heads/master 02f918286 -> 149534c3d
GROOVY-7381: Setters with non-void return type fail at runtime when statically compiled
Closes #17
Project: http://git-wip-us.apache.org/repos/asf/incubator-groovy/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-groovy/commit/149534c3
Tree: http://git-wip-us.apache.org/repos/asf/incubator-groovy/tree/149534c3
Diff: http://git-wip-us.apache.org/repos/asf/incubator-groovy/diff/149534c3
Branch: refs/heads/master
Commit: 149534c3ded579e234921268c38142570813e974
Parents: 02f9182
Author: Shil S <sh...@gmail.com>
Authored: Sat May 16 11:17:05 2015 -0400
Committer: Cedric Champeau <cc...@apache.org>
Committed: Mon May 18 21:37:26 2015 +0200
----------------------------------------------------------------------
...ypesBinaryExpressionMultiTypeDispatcher.java | 2 +-
.../asm/sc/BugsStaticCompileTest.groovy | 23 ++++++++++++++++++++
2 files changed, 24 insertions(+), 1 deletion(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/incubator-groovy/blob/149534c3/src/main/org/codehaus/groovy/classgen/asm/sc/StaticTypesBinaryExpressionMultiTypeDispatcher.java
----------------------------------------------------------------------
diff --git a/src/main/org/codehaus/groovy/classgen/asm/sc/StaticTypesBinaryExpressionMultiTypeDispatcher.java b/src/main/org/codehaus/groovy/classgen/asm/sc/StaticTypesBinaryExpressionMultiTypeDispatcher.java
index 60e5966..a1088c4 100644
--- a/src/main/org/codehaus/groovy/classgen/asm/sc/StaticTypesBinaryExpressionMultiTypeDispatcher.java
+++ b/src/main/org/codehaus/groovy/classgen/asm/sc/StaticTypesBinaryExpressionMultiTypeDispatcher.java
@@ -262,7 +262,7 @@ public class StaticTypesBinaryExpressionMultiTypeDispatcher extends BinaryExpres
}
if (!isAttribute) {
String setter = "set" + MetaClassHelper.capitalize(property);
- MethodNode setterMethod = receiverType.getSetterMethod(setter);
+ MethodNode setterMethod = receiverType.getSetterMethod(setter, false);
ClassNode declaringClass = setterMethod!=null?setterMethod.getDeclaringClass():null;
if (isThisExpression && declaringClass!=null && declaringClass.equals(controller.getClassNode())) {
// this.x = ... shouldn't use a setter if in the same class
http://git-wip-us.apache.org/repos/asf/incubator-groovy/blob/149534c3/src/test/org/codehaus/groovy/classgen/asm/sc/BugsStaticCompileTest.groovy
----------------------------------------------------------------------
diff --git a/src/test/org/codehaus/groovy/classgen/asm/sc/BugsStaticCompileTest.groovy b/src/test/org/codehaus/groovy/classgen/asm/sc/BugsStaticCompileTest.groovy
index 518c903..b83ecab 100644
--- a/src/test/org/codehaus/groovy/classgen/asm/sc/BugsStaticCompileTest.groovy
+++ b/src/test/org/codehaus/groovy/classgen/asm/sc/BugsStaticCompileTest.groovy
@@ -1370,5 +1370,28 @@ println someInt
assert astTrees['Test$_foo_closure1'][1].contains('INVOKEVIRTUAL org/codehaus/groovy/classgen/asm/sc/Groovy6924Support.setFoo (Ljava/lang/String;)V')
}
}
+
+ // GROOVY-7381
+ void testNonVoidSetterCalls(){
+ assertScript '''
+ class Foo {
+ int num
+ String name
+
+ Foo setNum(int num){
+ this.num = num
+ this
+ }
+
+ Foo setName(String name){
+ this.name = name
+ this
+ }
+ }
+ Foo foo = new Foo().setNum(1).setName('fluent')
+ assert foo.num == 1
+ assert foo.name == 'fluent'
+ '''
+ }
}