Permalink
Browse files

Fix JRUBY-6827

ClassCastException with DummyDynamicScope in String#rpartition? with -X+C

String#partition and rpartition need read/write of backref.
  • Loading branch information...
1 parent 8c0e98c commit ff42564963ac0d5b8b6471f23fd3441fb2db6fba @headius headius committed Aug 22, 2012
Showing with 17 additions and 3 deletions.
  1. +14 −0 spec/compiler/general_spec.rb
  2. +3 −3 src/org/jruby/RubyString.java
@@ -438,6 +438,20 @@ def main
result.should == [1,2,3]
end
+
+ if is19
+ it "prepares a proper caller scope for partition/rpartition (JRUBY-6827)" do
+ result = compile_and_run %q[
+ def foo
+ Object
+ "/Users/headius/projects/jruby/tmp/perfer/examples/file_stat.rb:4:in `(root)'".rpartition(/:\d+(?:$|:in )/).first
+ end
+
+ foo]
+
+ result.should == '/Users/headius/projects/jruby/tmp/perfer/examples/file_stat.rb'
+ end
+ end
it "does a bunch of other stuff" do
silence_warnings {
@@ -5376,12 +5376,12 @@ public IRubyObject center19(IRubyObject arg0, IRubyObject arg1) {
return justify19(arg0, arg1, 'c');
}
- @JRubyMethod
+ @JRubyMethod(reads = BACKREF, writes = BACKREF)
public IRubyObject partition(ThreadContext context, Block block) {
return RubyEnumerable.partition(context, this, block);
}
- @JRubyMethod
+ @JRubyMethod(reads = BACKREF, writes = BACKREF)
public IRubyObject partition(ThreadContext context, IRubyObject arg, Block block) {
Ruby runtime = context.runtime;
final int pos;
@@ -5410,7 +5410,7 @@ private IRubyObject partitionMismatch(Ruby runtime) {
return RubyArray.newArray(runtime, new IRubyObject[]{this, newEmptyString(runtime), newEmptyString(runtime)});
}
- @JRubyMethod(name = "rpartition")
+ @JRubyMethod(name = "rpartition", reads = BACKREF, writes = BACKREF)
public IRubyObject rpartition(ThreadContext context, IRubyObject arg) {
Ruby runtime = context.runtime;
final int pos;

0 comments on commit ff42564

Please sign in to comment.