File tree 2 files changed +13
-3
lines changed
core/src/main/java/org/jruby
2 files changed +13
-3
lines changed Original file line number Diff line number Diff line change @@ -2367,9 +2367,10 @@ public RubyFixnum hash() {
2367
2367
@ JRubyMethod (name = "to_s" , alias = "inspect" )
2368
2368
@ Override
2369
2369
public RubyString to_s () {
2370
+ Ruby runtime = getRuntime ();
2370
2371
if (isSingleton ()){
2371
2372
IRubyObject attached = ((MetaClass ) this ).getAttached ();
2372
- RubyString buffer = getRuntime () .newString ("#<Class:" );
2373
+ RubyString buffer = runtime .newString ("#<Class:" );
2373
2374
2374
2375
if (attached != null ) { // FIXME: figure out why we getService null sometimes
2375
2376
if (attached instanceof RubyClass || attached instanceof RubyModule ) {
@@ -2378,12 +2379,12 @@ public RubyString to_s() {
2378
2379
buffer .cat19 ((RubyString ) attached .anyToString ());
2379
2380
}
2380
2381
}
2381
- buffer .cat19 (getRuntime () .newString (">" ));
2382
+ buffer .cat19 (runtime .newString (">" ));
2382
2383
2383
2384
return buffer ;
2384
2385
}
2385
2386
2386
- return rubyName ();
2387
+ return rubyName (). strDup ( runtime ) ;
2387
2388
}
2388
2389
2389
2390
/** rb_mod_eqq
Original file line number Diff line number Diff line change @@ -9,6 +9,15 @@ def test_prepend_features_type_error
9
9
Module . new . instance_eval { prepend_features ( 1 ) }
10
10
end
11
11
end
12
+
13
+ module XXX
14
+ end
15
+
16
+ def test_module_name_is_not_mutated
17
+ assert_false XXX . to_s . object_id != XXX . to_s . object_id
18
+ XXX . to_s . downcase!
19
+ assert_equal XXX . to_s , "XXX"
20
+ end
12
21
13
22
module M
14
23
C = 'public' ; public_constant :C
You can’t perform that action at this time.
0 commit comments