@@ -217,35 +217,62 @@ public RubyUnboundMethod unbind() {
217
217
@ JRubyMethod (name = {"inspect" , "to_s" })
218
218
@ Override
219
219
public IRubyObject inspect () {
220
- StringBuilder buf = new StringBuilder ("#<" );
221
- char delimeter = '#' ;
222
-
223
- buf .append (getMetaClass ().getRealClass ().getName ()).append (": " );
220
+ Ruby runtime = getRuntime ();
221
+ ThreadContext context = runtime .getCurrentContext ();
222
+
223
+ RubyString str = RubyString .newString (runtime , "#<" );
224
+ String sharp = "#" ;
224
225
226
+ str .catString (getType ().getName ()).catString (": " );
227
+
228
+ RubyModule definedClass ;
229
+ RubyModule mklass = method .getImplementationClass ();
230
+
231
+ if (method instanceof AliasMethod ) {
232
+ definedClass = method .getRealMethod ().getImplementationClass ();
233
+ }
234
+ else {
235
+ definedClass = method .getDefinedClass ();
236
+ }
237
+
238
+ if (definedClass .isIncluded ()) {
239
+ definedClass = definedClass .getMetaClass ();
240
+ }
241
+
225
242
if (implementationModule .isSingleton ()) {
226
243
IRubyObject attached = ((MetaClass ) implementationModule ).getAttached ();
227
244
if (receiver == null ) {
228
- buf . append ( implementationModule . inspect (). toString ());
245
+ str . cat19 ( inspect (context , implementationModule ). convertToString ());
229
246
} else if (receiver == attached ) {
230
- buf . append ( attached . inspect (). toString ());
231
- delimeter = '.' ;
247
+ str . cat19 ( inspect (context , attached ). convertToString ());
248
+ sharp = "." ;
232
249
} else {
233
- buf .append (receiver .inspect ().toString ());
234
- buf .append ('(' ).append (attached .inspect ().toString ()).append (')' );
235
- delimeter = '.' ;
250
+ str .cat19 (inspect (context , receiver ).convertToString ());
251
+ str .catString ("(" );
252
+ str .cat19 (inspect (context , attached ).convertToString ());
253
+ str .catString (")" );
254
+ sharp = "." ;
236
255
}
237
256
} else {
238
- buf .append (originModule .getName ());
239
-
257
+ str .catString (originModule .getName ());
240
258
if (implementationModule != originModule ) {
241
- buf .append ('(' ).append (implementationModule .getName ()).append (')' );
259
+ str .catString ("(" );
260
+ str .catString (implementationModule .getName ());
261
+ str .catString (")" );
242
262
}
243
263
}
244
-
245
- buf .append (delimeter ).append (methodName ).append ('>' );
246
-
247
- RubyString str = getRuntime ().newString (buf .toString ());
248
- str .setTaint (isTaint ());
264
+ str .catString (sharp );
265
+ str .catString (this .methodName );
266
+ if (!methodName .equals (method .getName ())) {
267
+ str .catString ("(" );
268
+ str .catString (method .getName ());
269
+ str .catString (")" );
270
+ }
271
+ if (method .isNotImplemented ()) {
272
+ str .catString (" (not-implemented)" );
273
+ }
274
+ str .catString (">" );
275
+
249
276
return str ;
250
277
}
251
278
0 commit comments