Details
-
Type:
Bug
-
Status:
Closed
-
Priority:
Major
-
Resolution: Fixed
-
Affects Version/s: 1.5.6
-
Fix Version/s: 1.6-rc-1, 1.5.8, 1.7-beta-1
-
Component/s: syntax
-
Labels:None
-
Environment:Microsoft Windows XP [Version 5.1.2600]
Java(TM) 2 Runtime Environment, Standard Edition (build 1.5.0_04-b05)
Groovy Version: 1.5.6 JVM: 1.5.0_04-b05
-
Number of attachments :
Description
Looking at this SSCCE, the local method selectSql gets called rather than the closure, when the closure should have scope preference. Please find below reference to the discussion about this issue on the groovy-user mailing-list.
public class Tester {
private String selectSql()
public String returnSql(Closure selectSql)
{ return selectSql() }}
Tester t = new Tester()
println t.returnSql()
The issue found in all 1.5.8, 1.6-RC-1, and 1.7-beta-1 branches.
Please find attached the fix for all 3 versions.
The modification has been made to AsmClassGenerator -> visitMethodCallExpression().
If it now sees a closure variable on the compile stack (an argument or a local variable) of the same name as a method on the class, the closure is given precedence over the method on the class.
Hope it helps.
Roshan