mirror of
https://github.com/ruby/ruby.git
synced 2022-11-09 12:17:21 -05:00
proc.c: skip prepends
* proc.c (mnew): skip prepending modules and return the method bound on the given class. [ruby-core:52160] [Bug #7836] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@39224 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
parent
aae1d28b6f
commit
4b75145278
3 changed files with 33 additions and 0 deletions
|
@ -1,3 +1,8 @@
|
|||
Wed Feb 13 18:37:50 2013 Nobuyoshi Nakada <nobu@ruby-lang.org>
|
||||
|
||||
* proc.c (mnew): skip prepending modules and return the method bound
|
||||
on the given class. [ruby-core:52160] [Bug #7836]
|
||||
|
||||
Wed Feb 13 18:11:59 2013 Nobuyoshi Nakada <nobu@ruby-lang.org>
|
||||
|
||||
* proc.c (method_original_name): new methods Method#original_name and
|
||||
|
|
1
proc.c
1
proc.c
|
@ -941,6 +941,7 @@ mnew(VALUE klass, VALUE obj, ID id, VALUE mclass, int scope)
|
|||
rb_method_flag_t flag = NOEX_UNDEF;
|
||||
|
||||
again:
|
||||
if (klass) klass = RCLASS_ORIGIN(klass);
|
||||
me = rb_method_entry_without_refinements(klass, id, &defined_class);
|
||||
if (UNDEFINED_METHOD_ENTRY_P(me)) {
|
||||
ID rmiss = rb_intern("respond_to_missing?");
|
||||
|
|
|
@ -534,4 +534,31 @@ class TestMethod < Test::Unit::TestCase
|
|||
assert_equal(x.singleton_class, x.method(:bar).owner)
|
||||
assert(x.method(:foo) != x.method(:bar), bug7613)
|
||||
end
|
||||
|
||||
def test_included
|
||||
m = Module.new {
|
||||
def foo
|
||||
end
|
||||
}
|
||||
c = Class.new {
|
||||
def foo
|
||||
end
|
||||
include m
|
||||
}
|
||||
assert_equal(c, c.instance_method(:foo).owner)
|
||||
end
|
||||
|
||||
def test_prepended
|
||||
bug7836 = '[ruby-core:52160] [Bug #7836]'
|
||||
m = Module.new {
|
||||
def foo
|
||||
end
|
||||
}
|
||||
c = Class.new {
|
||||
def foo
|
||||
end
|
||||
prepend m
|
||||
}
|
||||
assert_equal(c, c.instance_method(:foo).owner, bug7836)
|
||||
end
|
||||
end
|
||||
|
|
Loading…
Reference in a new issue