Closures that are not inside of a method (e.g. they are defined using @Field) and have explicit return statements cause an NPE during compilation
For Closures that are inside of a method and have explicit return statements, the sandbox transforms the return statement and inserts a checked cast to the return type of the surrounding method, which is incorrect
[x] Make sure you are opening from a topic/feature/bugfix branch (right side) and not your main branch!
[x] Ensure that the pull request title represents the desired changelog entry
[x] Please describe what you did
[x] Link to relevant issues in GitHub or Jira
[x] Link to relevant pull requests, esp. upstream and downstream changes
[x] Ensure you have provided tests - that demonstrates feature works or fixes the issue
Fixes #99
The code related to intercepting implicit Groovy casts in method return values in https://github.com/jenkinsci/groovy-sandbox/commit/520243213bcd8c81322e8e683daa8d555bb4f484 caused two related bugs for closure expressions with explicit return statements:
@Field
) and have explicit return statements cause an NPE during compilation