|
45 | 45 | import org.truffleruby.core.hash.ReHashable;
|
46 | 46 | import org.truffleruby.core.inlined.CoreMethods;
|
47 | 47 | import org.truffleruby.core.kernel.AtExitManager;
|
| 48 | +import org.truffleruby.core.kernel.KernelNodes; |
48 | 49 | import org.truffleruby.core.kernel.TraceManager;
|
49 | 50 | import org.truffleruby.core.module.ModuleOperations;
|
50 | 51 | import org.truffleruby.core.module.RubyModule;
|
@@ -433,24 +434,36 @@ private TruffleNFIPlatform createNativePlatform() {
|
433 | 434 | }
|
434 | 435 |
|
435 | 436 | @TruffleBoundary
|
436 |
| - public static Object send(Object object, String methodName, Object... arguments) { |
| 437 | + public static Object send(Object receiver, String methodName, Object... arguments) { |
437 | 438 | final InternalMethod method = ModuleOperations
|
438 |
| - .lookupMethodUncached(MetaClassNode.getUncached().execute(object), methodName, null); |
| 439 | + .lookupMethodUncached(MetaClassNode.getUncached().execute(receiver), methodName, null); |
439 | 440 | if (method == null || method.isUndefined()) {
|
440 |
| - return null; |
| 441 | + final RubyContext context = RubyLanguage.getCurrentContext(); |
| 442 | + final String message = String.format( |
| 443 | + "undefined method `%s' for %s when using RubyContext#send() which ignores #method_missing", |
| 444 | + methodName, |
| 445 | + KernelNodes.ToSNode.uncachedBasicToS(receiver)); |
| 446 | + throw new RaiseException( |
| 447 | + context, |
| 448 | + context.getCoreExceptions().noMethodError( |
| 449 | + message, |
| 450 | + receiver, |
| 451 | + methodName, |
| 452 | + arguments, |
| 453 | + EncapsulatingNodeReference.getCurrent().get())); |
441 | 454 | }
|
442 | 455 |
|
443 | 456 | return IndirectCallNode.getUncached().call(
|
444 | 457 | method.getCallTarget(),
|
445 |
| - RubyArguments.pack(null, null, method, null, object, Nil.INSTANCE, arguments)); |
| 458 | + RubyArguments.pack(null, null, method, null, receiver, Nil.INSTANCE, arguments)); |
446 | 459 | }
|
447 | 460 |
|
448 | 461 | @TruffleBoundary
|
449 |
| - public static Object send(Node currentNode, Object object, String methodName, Object... arguments) { |
| 462 | + public static Object send(Node currentNode, Object receiver, String methodName, Object... arguments) { |
450 | 463 | final EncapsulatingNodeReference callNodeRef = EncapsulatingNodeReference.getCurrent();
|
451 | 464 | final Node prev = callNodeRef.set(currentNode);
|
452 | 465 | try {
|
453 |
| - return send(object, methodName, arguments); |
| 466 | + return send(receiver, methodName, arguments); |
454 | 467 | } finally {
|
455 | 468 | callNodeRef.set(prev);
|
456 | 469 | }
|
|
0 commit comments