Skip to content

Commit

Permalink
[Truffle] Handle #to_s on String subclasses.
Browse files Browse the repository at this point in the history
  • Loading branch information
nirvdrum committed Mar 6, 2015
1 parent a6fc17e commit 7fdec90
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 2 deletions.
1 change: 0 additions & 1 deletion spec/truffle/tags/core/string/to_s_tags.txt

This file was deleted.

Expand Up @@ -1727,10 +1727,20 @@ public ToSNode(ToSNode prev) {
super(prev);
}

@Specialization
@Specialization(guards = "!isStringSubclass")
public RubyString toS(RubyString string) {
return string;
}

@Specialization(guards = "isStringSubclass")
public Object toSOnSubclass(VirtualFrame frame, RubyString string) {
return ruby(frame, "''.replace(self)", "self", string);
}

public boolean isStringSubclass(RubyString string) {
return string.getLogicalClass() != getContext().getCoreLibrary().getStringClass();
}

}

@CoreMethod(names = {"to_sym", "intern"})
Expand Down

0 comments on commit 7fdec90

Please sign in to comment.