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:
nobu 2013-12-14 04:02:00 +00:00
Родитель a370556cd2
Коммит b83d68a38f
3 изменённых файлов: 17 добавлений и 0 удалений

Просмотреть файл

@ -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>
* lib/scanf.rb (IO#scanf): fix mistaken use of rescue modifier.

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 (RTEST(rb_funcall(obj, rmiss, 2, sym, scope ? Qfalse : Qtrue))) {
me = 0;
defined_class = klass;
goto gen_method;
}

Просмотреть файл

@ -189,6 +189,17 @@ class TestMethod < Test::Unit::TestCase
assert_equal(c, c2.instance_method(:foo).owner)
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
o = Object.new
def o.foo; end