Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
Fix a few Module#define_method corners
  • Loading branch information
Evan Phoenix committed Nov 12, 2009
1 parent 0adcec2 commit cc6f8bc
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 15 deletions.
20 changes: 6 additions & 14 deletions kernel/common/method.rb
Expand Up @@ -184,14 +184,8 @@ def arity()
# Module anyway.

def bind(receiver)
if @defined_in.kind_of? MetaClass
unless @defined_in.attached_instance == receiver
raise TypeError, "Must be bound to #{@defined_in.attached_instance.inspect} only"
end
else
unless receiver.__kind_of__ @defined_in
raise TypeError, "Must be bound to an object of kind #{@defined_in}"
end
unless receiver.__kind_of__ @defined_in
raise TypeError, "Must be bound to an object of kind #{@defined_in}"
end
Method.new receiver, @defined_in, @compiled_method, @name
end
Expand Down Expand Up @@ -219,12 +213,10 @@ def source_location
end

def owner
def owner
if defined_in.class == Rubinius::IncludedModule
defined_in.module
else
defined_in
end
if defined_in.class == Rubinius::IncludedModule
defined_in.module
else
defined_in
end
end
end
2 changes: 1 addition & 1 deletion kernel/common/module.rb
Expand Up @@ -296,7 +296,7 @@ def define_method(name, meth = nil, &prc)
be.method = meth
cm = Rubinius::BlockEnvironment::AsMethod.new(be)
when Method
cm = Rubinius::DelegatedMethod.new(name, :call, meth, false)
cm = Rubinius::DelegatedMethod.new(name, :call_on_instance, meth.unbind, true)
when UnboundMethod
cm = Rubinius::DelegatedMethod.new(name, :call_on_instance, meth, true)
else
Expand Down

0 comments on commit cc6f8bc

Please sign in to comment.