Skip to content

Commit

Permalink
GroovyEngine Inspector: override only Closure vars with function def
Browse files Browse the repository at this point in the history
  • Loading branch information
mattirn committed Sep 15, 2020
1 parent 0d4fc5d commit ff28596
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion groovy/src/main/java/org/jline/script/GroovyEngine.java
Original file line number Diff line number Diff line change
Expand Up @@ -853,7 +853,8 @@ public Inspector(GroovyEngine groovyEngine) {
}
for (Map.Entry<String,String> entry : groovyEngine.methods.entrySet()) {
Matcher m = PATTERN_FUNCTION_BODY.matcher(entry.getValue());
if (m.matches()) {
if (m.matches() && sharedData.hasVariable(entry.getKey())
&& sharedData.getVariable(entry.getKey()) instanceof Closure) {
sharedData.setVariable(entry.getKey(), execute("{" + m.group(1) + "->" + m.group(2) + "}"));
}
}
Expand Down

0 comments on commit ff28596

Please sign in to comment.