Skip to content


[Truffle] Implementing more Module#remove_method.
Browse files Browse the repository at this point in the history
  • Loading branch information
bjfish committed Apr 9, 2015
1 parent c1376d2 commit f0b1605
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 13 deletions.
4 changes: 0 additions & 4 deletions spec/truffle/tags/core/module/remove_method_tags.txt
@@ -1,6 +1,2 @@
fails:Module#remove_method is a private method
fails:Module#remove_method requires multiple arguments
fails:Module#remove_method does not remove any instance methods when argument not given
fails:Module#remove_method raises a NameError when attempting to remove method further up the inheritance tree
fails:Module#remove_method raises a NameError when attempting to remove a missing method
fails:Module#remove_method on frozen instance does not raise exceptions when no arguments given
Expand Up @@ -1694,7 +1694,7 @@ Object removeConstant(RubyModule module, String name) {


@CoreMethod(names = "remove_method", required = 1)
@CoreMethod(names = "remove_method", argumentsAsArray = true, visibility = Visibility.PRIVATE)
public abstract static class RemoveMethodNode extends CoreMethodNode {

public RemoveMethodNode(RubyContext context, SourceSection sourceSection) {
Expand All @@ -1706,18 +1706,24 @@ public RemoveMethodNode(RemoveMethodNode prev) {

public RubyModule removeMethod(RubyModule module, RubyString name) {
public RubyModule removeMethod(RubyModule module, Object[] args) {

module.removeMethod(this, name.toString());
return module;
for (Object arg : args) {
final String name;

public RubyModule removeMethod(RubyModule module, RubySymbol name) {
if (arg instanceof RubySymbol) {
name = ((RubySymbol) arg).toString();
} else if (arg instanceof RubyString) {
name = ((RubyString) arg).toString();
} else {
// TODO BF 9-APR-2015 the MRI message calls inspect for error message i think
throw new RaiseException(getContext().getCoreLibrary().typeError(" is not a symbol", this));
module.removeMethod(this, name);


module.removeMethod(this, name.toString());
return module;

Expand Down

0 comments on commit f0b1605

Please sign in to comment.