File tree Expand file tree Collapse file tree 3 files changed +7
-7
lines changed
src/main/java/org/truffleruby/core/module Expand file tree Collapse file tree 3 files changed +7
-7
lines changed Original file line number Diff line number Diff line change @@ -25,6 +25,7 @@ Bug fixes:
25
25
* Process#exec: set close-on-exec to false for fd redirection (#1805 , @XrXr , @rafaelfranca ).
26
26
* Building C extensions should now work with frozen string literals (#1786 ).
27
27
* Keep the Truffle working directory in sync with the native working directory.
28
+ * Fixed ` Module#to_s ` and ` Module#inspect ` to not return an extra ` #<Class: ` for singleton classes.
28
29
29
30
Compatibility:
30
31
Load Diff This file was deleted.
Original file line number Diff line number Diff line change @@ -1854,19 +1854,19 @@ protected DynamicObject toS(DynamicObject module) {
1854
1854
final ModuleFields fields = Layouts .MODULE .getFields (module );
1855
1855
if (RubyGuards .isSingletonClass (module )) {
1856
1856
final DynamicObject attached = Layouts .CLASS .getAttached (module );
1857
- final String name ;
1858
- if (Layouts .CLASS .isClass (attached ) || Layouts .MODULE .isModule (attached )) {
1857
+ final String attachedName ;
1858
+ if (Layouts .MODULE .isModule (attached )) {
1859
+ attachedName = Layouts .MODULE .getFields (attached ).getName ();
1860
+ } else {
1859
1861
if (callRbInspect == null ) {
1860
1862
CompilerDirectives .transferToInterpreterAndInvalidate ();
1861
1863
callRbInspect = insert (CallDispatchHeadNode .createPrivate ());
1862
1864
}
1863
1865
final Object inspectResult = callRbInspect
1864
1866
.call (coreLibrary ().getTruffleTypeModule (), "rb_inspect" , attached );
1865
- name = StringOperations .getString ((DynamicObject ) inspectResult );
1866
- } else {
1867
- name = fields .getName ();
1867
+ attachedName = StringOperations .getString ((DynamicObject ) inspectResult );
1868
1868
}
1869
- moduleName = "#<Class:" + name + ">" ;
1869
+ moduleName = "#<Class:" + attachedName + ">" ;
1870
1870
} else if (fields .isRefinement ()) {
1871
1871
final String refinedClass = Layouts .MODULE .getFields (fields .getRefinedClass ()).getName ();
1872
1872
final String refinementNamespace = Layouts .MODULE .getFields (fields .getRefinementNamespace ()).getName ();
You can’t perform that action at this time.
0 commit comments