Skip to content

Commit

Permalink
[Truffle] Fix error in Module#define_method with mis-matched classes.
Browse files Browse the repository at this point in the history
  • Loading branch information
chrisseaton committed Apr 5, 2015
1 parent 1001fa0 commit 5844ccd
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 1 deletion.
@@ -1 +1,2 @@
fails:Kernel#define_singleton_method when given an UnboundMethod defines any Child class method from any Parent's class methods
fails:Kernel#define_singleton_method when given an UnboundMethod will raise when attempting to define an object's singleton method from another object's singleton method
Expand Up @@ -972,9 +972,15 @@ public RubySymbol defineMethod(RubyModule module, String name, RubyMethod method
}

@Specialization
public RubySymbol defineMethod(RubyModule module, String name, RubyUnboundMethod method, UndefinedPlaceholder block) {
public RubySymbol defineMethod(VirtualFrame frame, RubyModule module, String name, RubyUnboundMethod method, UndefinedPlaceholder block) {
notDesignedForCompilation();

if (module instanceof RubyClass && !ModuleOperations.assignableTo((RubyClass) module, method.getOrigin())) {
ruby(frame, "raise TypeError, 'bind argument must be a subclass of " + method.getOrigin().getName() + "'");
}

// TODO CS 5-Apr-15 TypeError if the method came from a singleton

module.addMethod(this, method.getMethod().withNewName(name));

return getContext().getSymbolTable().getSymbol(name);
Expand Down

0 comments on commit 5844ccd

Please sign in to comment.