Skip to content

Commit

Permalink
[Truffle] Add more Module#private_class_method.
Browse files Browse the repository at this point in the history
  • Loading branch information
bjfish committed Apr 27, 2015
1 parent 869a321 commit 4a0cede
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 5 deletions.
3 changes: 0 additions & 3 deletions spec/truffle/tags/core/module/private_class_method_tags.txt

This file was deleted.

Expand Up @@ -1464,14 +1464,19 @@ public RubyModule privateClassMethod(RubyModule module, Object... args) {

if (arg instanceof RubySymbol) {
methodName = arg.toString();
} else if (arg instanceof RubyString) {
methodName = ((RubyString) arg).toString();
} else {
throw new UnsupportedOperationException();
// TODO BF 26-APR-2015 the message could be improved to match MRI
CompilerDirectives.transferToInterpreter();
throw new RaiseException(getContext().getCoreLibrary().typeError(" is not a symbol", this));

This comment has been minimized.

Copy link
@nirvdrum

nirvdrum Apr 28, 2015

Contributor

Should this be indicating what is not a symbol? Or is that just an MRI quirk?

This comment has been minimized.

Copy link
@bjfish

bjfish Apr 28, 2015

Author Contributor

@nirvdrum They usually include more detail. I think the error message needs to be updated to (ruby pseudo-code)

"#{arg.inspect} is not a symbol"

Some MRI Examples

private_class_method Object.new
#<Object:0x007f973195fc48> is not a symbol

private_class_method ["test"]
["test"] is not a symbol
}

final InternalMethod method = ModuleOperations.lookupMethod(moduleSingleton, methodName);

if (method == null) {
throw new RuntimeException("Couldn't find method " + arg.toString());
CompilerDirectives.transferToInterpreter();
throw new RaiseException(getContext().getCoreLibrary().nameErrorUndefinedMethod(methodName, module, this));
}

moduleSingleton.addMethod(this, method.withVisibility(Visibility.PRIVATE));
Expand Down Expand Up @@ -1923,6 +1928,7 @@ public RubyModule removeMethod(RubyModule module, Object[] args) {
name = ((RubyString) arg).toString();
} else {
// TODO BF 9-APR-2015 the MRI message calls inspect for error message i think
CompilerDirectives.transferToInterpreter();
throw new RaiseException(getContext().getCoreLibrary().typeError(" is not a symbol", this));
}
module.removeMethod(this, name);
Expand Down

0 comments on commit 4a0cede

Please sign in to comment.