Skip to content

Commit

Permalink
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions core/src/main/java/org/jruby/Ruby.java
Original file line number Diff line number Diff line change
@@ -2886,7 +2886,7 @@ public void printError(RubyException excp) {
}

public void loadFile(String scriptName, InputStream in, boolean wrap) {
IRubyObject self = wrap ? TopSelfFactory.createTopSelf(this, true) : getTopSelf();
IRubyObject self = wrap ? getTopSelf().rbClone() : getTopSelf();
ThreadContext context = getCurrentContext();
String file = context.getFile();

@@ -2897,7 +2897,9 @@ public void loadFile(String scriptName, InputStream in, boolean wrap) {

if (wrap) {
// toss an anonymous module into the search path
((RootNode) parseResult).getStaticScope().setModule(RubyModule.newModule(this));
RubyModule wrapper = RubyModule.newModule(this);
((RubyBasicObject)self).extend(new IRubyObject[] {wrapper});
((RootNode) parseResult).getStaticScope().setModule(wrapper);
}

runInterpreter(context, parseResult, self);

0 comments on commit 7be804e

Please sign in to comment.