Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[JENKINS-34599] Setting of final fields #33

Merged
merged 4 commits into from Jul 18, 2017
Merged
Diff settings

Always

Just for now

Next

Need to track scope also when transforming fields; otherwise we get a…

…n NPE from isLocalVariable.
  • Loading branch information...
jglick committed Jul 11, 2017
commit e6447ef32d554d1de7734bc76aa752ad0bc9fd4c
@@ -1,6 +1,7 @@
package org.kohsuke.groovy.sandbox;

import org.codehaus.groovy.ast.ClassCodeExpressionTransformer;
import org.codehaus.groovy.ast.FieldNode;
import org.codehaus.groovy.ast.MethodNode;
import org.codehaus.groovy.ast.Parameter;
import org.codehaus.groovy.ast.Variable;
@@ -45,6 +46,13 @@ public void visitMethod(MethodNode node) {
}
}

@Override
public void visitField(FieldNode node) {
try (StackVariableSet scope = new StackVariableSet(this)) {
super.visitField(node);
}
}

@Override
public void visitBlockStatement(BlockStatement block) {
try (StackVariableSet scope = new StackVariableSet(this)) {
ProTip! Use n and p to navigate between commits in a pull request.
You can’t perform that action at this time.