mirror of
https://github.com/ruby/ruby.git
synced 2022-11-09 12:17:21 -05:00
proc.c: method by respond_to_missing?
* proc.c (mnew_from_me): method by respond_to_missing? should be owned by the original class. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@44198 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
parent
a370556cd2
commit
b83d68a38f
3 changed files with 17 additions and 0 deletions
|
@ -1,3 +1,8 @@
|
||||||
|
Sat Dec 14 13:01:45 2013 Nobuyoshi Nakada <nobu@ruby-lang.org>
|
||||||
|
|
||||||
|
* proc.c (mnew_from_me): method by respond_to_missing? should be
|
||||||
|
owned by the original class.
|
||||||
|
|
||||||
Sat Dec 14 11:55:31 2013 Nobuyoshi Nakada <nobu@ruby-lang.org>
|
Sat Dec 14 11:55:31 2013 Nobuyoshi Nakada <nobu@ruby-lang.org>
|
||||||
|
|
||||||
* lib/scanf.rb (IO#scanf): fix mistaken use of rescue modifier.
|
* lib/scanf.rb (IO#scanf): fix mistaken use of rescue modifier.
|
||||||
|
|
1
proc.c
1
proc.c
|
@ -1139,6 +1139,7 @@ mnew_from_me(rb_method_entry_t *me, VALUE defined_class, VALUE klass,
|
||||||
if (obj != Qundef && !rb_method_basic_definition_p(klass, rmiss)) {
|
if (obj != Qundef && !rb_method_basic_definition_p(klass, rmiss)) {
|
||||||
if (RTEST(rb_funcall(obj, rmiss, 2, sym, scope ? Qfalse : Qtrue))) {
|
if (RTEST(rb_funcall(obj, rmiss, 2, sym, scope ? Qfalse : Qtrue))) {
|
||||||
me = 0;
|
me = 0;
|
||||||
|
defined_class = klass;
|
||||||
|
|
||||||
goto gen_method;
|
goto gen_method;
|
||||||
}
|
}
|
||||||
|
|
|
@ -189,6 +189,17 @@ class TestMethod < Test::Unit::TestCase
|
||||||
assert_equal(c, c2.instance_method(:foo).owner)
|
assert_equal(c, c2.instance_method(:foo).owner)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def test_owner_missing
|
||||||
|
c = Class.new do
|
||||||
|
def respond_to_missing?(name, bool)
|
||||||
|
name == :foo
|
||||||
|
end
|
||||||
|
end
|
||||||
|
c2 = Class.new(c)
|
||||||
|
assert_equal(c, c.new.method(:foo).owner)
|
||||||
|
assert_equal(c2, c2.new.method(:foo).owner)
|
||||||
|
end
|
||||||
|
|
||||||
def test_receiver_name_owner
|
def test_receiver_name_owner
|
||||||
o = Object.new
|
o = Object.new
|
||||||
def o.foo; end
|
def o.foo; end
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue