Skip to content

Commit 7178caa

Browse files
committed
Use target self as frame self for instance_eval. Fixes #2301.
This is a bit of a scary change, so pushing to a test branch for now.
1 parent 69317cc commit 7178caa

File tree

3 files changed

+6
-6
lines changed

3 files changed

+6
-6
lines changed

core/src/main/java/org/jruby/RubyBasicObject.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1688,7 +1688,7 @@ public IRubyObject instance_exec19(ThreadContext context, IRubyObject[] args, Bl
16881688
* with this implementation.
16891689
*/
16901690
protected IRubyObject yieldUnder(final ThreadContext context, RubyModule under, IRubyObject[] args, Block block, EvalType evalType) {
1691-
context.preExecuteUnder(under, block);
1691+
context.preExecuteUnder(this, under, block);
16921692

16931693
IRubyObject savedBindingSelf = block.getBinding().getSelf();
16941694
IRubyObject savedFrameSelf = block.getBinding().getFrame().getSelf();
@@ -1730,7 +1730,7 @@ private Block setupBlock(Block block, EvalType evalType) {
17301730
* with this implementation.
17311731
*/
17321732
protected IRubyObject yieldUnder(final ThreadContext context, RubyModule under, Block block, EvalType evalType) {
1733-
context.preExecuteUnder(under, block);
1733+
context.preExecuteUnder(this, under, block);
17341734

17351735
IRubyObject savedBindingSelf = block.getBinding().getSelf();
17361736
IRubyObject savedFrameSelf = block.getBinding().getFrame().getSelf();
@@ -1873,7 +1873,7 @@ protected RubyModule getInstanceEvalClass() {
18731873
public IRubyObject evalUnder(final ThreadContext context, RubyModule under, RubyString src, String file, int line, EvalType evalType) {
18741874
Visibility savedVisibility = context.getCurrentVisibility();
18751875
context.setCurrentVisibility(PUBLIC);
1876-
context.preExecuteUnder(under, Block.NULL_BLOCK);
1876+
context.preExecuteUnder(this, under, Block.NULL_BLOCK);
18771877
try {
18781878
return Interpreter.evalSimple(context, this, src, file, line, evalType);
18791879
} finally {

core/src/main/java/org/jruby/RubyModule.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1669,7 +1669,7 @@ private DynamicMethod createProcMethod(String name, Visibility visibility, RubyP
16691669

16701670
@Deprecated
16711671
public IRubyObject executeUnder(ThreadContext context, org.jruby.runtime.callback.Callback method, IRubyObject[] args, Block block) {
1672-
context.preExecuteUnder(this, block);
1672+
context.preExecuteUnder(this, this, block);
16731673
try {
16741674
return method.execute(this, args, block);
16751675
} finally {

core/src/main/java/org/jruby/runtime/ThreadContext.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -881,14 +881,14 @@ public void postNodeEval() {
881881
}
882882

883883
// XXX: Again, screwy evaling under previous frame's scope
884-
public void preExecuteUnder(RubyModule executeUnderClass, Block block) {
884+
public void preExecuteUnder(IRubyObject executeUnderObj, RubyModule executeUnderClass, Block block) {
885885
Frame frame = getCurrentFrame();
886886

887887
DynamicScope scope = getCurrentScope();
888888
StaticScope sScope = runtime.getStaticScopeFactory().newBlockScope(scope.getStaticScope());
889889
sScope.setModule(executeUnderClass);
890890
pushScope(DynamicScope.newDynamicScope(sScope, scope));
891-
pushCallFrame(frame.getKlazz(), frame.getName(), frame.getSelf(), block);
891+
pushCallFrame(frame.getKlazz(), frame.getName(), executeUnderObj, block);
892892
getCurrentFrame().setVisibility(getPreviousFrame().getVisibility());
893893
}
894894

0 commit comments

Comments
 (0)