groovy

Parameter values not available in nested closures

Details

  • Type: Bug Bug
  • Status: Closed Closed
  • Priority: Major Major
  • Resolution: Fixed
  • Affects Version/s: 1.0-JSR-5
  • Fix Version/s: 1.0-JSR-6
  • Component/s: None
  • Labels:
    None
  • Number of attachments :
    1

Description

If a closure nested at a level greater than or equal to 2 accesses a method parameter, it does not read that parameter's value - rather it uses the reference itself as the value. This is difficult to explain, but I have attached a reproduction recipe to highlight the problem.

I don't know whether this is specific to builders or not, but I suspect it is probably a general problem. Strangely, local variables declared within the method are read correctly. This at least means that there is a reasonable workaround, which is to assign the problem parameter values to local variables.

Activity

Hide
Guillaume Laforge added a comment -

Is it still a bug in JSR-06 ?

Show
Guillaume Laforge added a comment - Is it still a bug in JSR-06 ?
Hide
Peter Ledbrook added a comment -

No. JSR-06 contains the fix.

Show
Peter Ledbrook added a comment - No. JSR-06 contains the fix.

People

Vote (0)
Watch (0)

Dates

  • Created:
    Updated:
    Resolved: