object.c: skip prepending modules
* object.c (rb_obj_is_kind_of): skip prepending modules. [ruby-core:54742] [Bug #8357] * object.c (rb_class_inherited_p): ditto. [ruby-core:54736] [Bug #8357] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@40561 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
parent
908e701851
commit
a58c224dcf
@ -1,3 +1,11 @@
|
|||||||
|
Thu May 2 23:23:49 2013 Nobuyoshi Nakada <nobu@ruby-lang.org>
|
||||||
|
|
||||||
|
* object.c (rb_obj_is_kind_of): skip prepending modules.
|
||||||
|
[ruby-core:54742] [Bug #8357]
|
||||||
|
|
||||||
|
* object.c (rb_class_inherited_p): ditto.
|
||||||
|
[ruby-core:54736] [Bug #8357]
|
||||||
|
|
||||||
Thu May 2 22:11:47 2013 Nobuyoshi Nakada <nobu@ruby-lang.org>
|
Thu May 2 22:11:47 2013 Nobuyoshi Nakada <nobu@ruby-lang.org>
|
||||||
|
|
||||||
* bin/irb: remove dead code from sample/irb.rb.
|
* bin/irb: remove dead code from sample/irb.rb.
|
||||||
|
2
object.c
2
object.c
@ -599,6 +599,7 @@ rb_obj_is_kind_of(VALUE obj, VALUE c)
|
|||||||
VALUE cl = CLASS_OF(obj);
|
VALUE cl = CLASS_OF(obj);
|
||||||
|
|
||||||
c = class_or_module_required(c);
|
c = class_or_module_required(c);
|
||||||
|
c = RCLASS_ORIGIN(c);
|
||||||
while (cl) {
|
while (cl) {
|
||||||
if (cl == c || RCLASS_M_TBL(cl) == RCLASS_M_TBL(c))
|
if (cl == c || RCLASS_M_TBL(cl) == RCLASS_M_TBL(c))
|
||||||
return Qtrue;
|
return Qtrue;
|
||||||
@ -1511,6 +1512,7 @@ rb_class_inherited_p(VALUE mod, VALUE arg)
|
|||||||
if (!CLASS_OR_MODULE_P(arg)) {
|
if (!CLASS_OR_MODULE_P(arg)) {
|
||||||
rb_raise(rb_eTypeError, "compared with non class/module");
|
rb_raise(rb_eTypeError, "compared with non class/module");
|
||||||
}
|
}
|
||||||
|
arg = RCLASS_ORIGIN(arg);
|
||||||
while (mod) {
|
while (mod) {
|
||||||
if (RCLASS_M_TBL(mod) == RCLASS_M_TBL(arg))
|
if (RCLASS_M_TBL(mod) == RCLASS_M_TBL(arg))
|
||||||
return Qtrue;
|
return Qtrue;
|
||||||
|
@ -1408,6 +1408,13 @@ class TestModule < Test::Unit::TestCase
|
|||||||
c = labeled_class("c") {prepend b}
|
c = labeled_class("c") {prepend b}
|
||||||
assert_operator(c, :<, b, bug6654)
|
assert_operator(c, :<, b, bug6654)
|
||||||
assert_operator(c, :<, a, bug6654)
|
assert_operator(c, :<, a, bug6654)
|
||||||
|
bug8357 = '[ruby-core:54736] [Bug #8357]'
|
||||||
|
b = labeled_module("b") {prepend a}
|
||||||
|
c = labeled_class("c") {include b}
|
||||||
|
assert_operator(c, :<, b, bug8357)
|
||||||
|
assert_operator(c, :<, a, bug8357)
|
||||||
|
bug8357 = '[ruby-core:54742] [Bug #8357]'
|
||||||
|
assert_kind_of(b, c.new, bug8357)
|
||||||
end
|
end
|
||||||
|
|
||||||
def test_prepend_instance_methods
|
def test_prepend_instance_methods
|
||||||
@ -1487,14 +1494,14 @@ class TestModule < Test::Unit::TestCase
|
|||||||
|
|
||||||
def labeled_module(name, &block)
|
def labeled_module(name, &block)
|
||||||
Module.new do
|
Module.new do
|
||||||
singleton_class.class_eval {define_method(:to_s) {name}}
|
singleton_class.class_eval {define_method(:to_s) {name}; alias inspect to_s}
|
||||||
class_eval(&block) if block
|
class_eval(&block) if block
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
def labeled_class(name, superclass = Object, &block)
|
def labeled_class(name, superclass = Object, &block)
|
||||||
Class.new(superclass) do
|
Class.new(superclass) do
|
||||||
singleton_class.class_eval {define_method(:to_s) {name}}
|
singleton_class.class_eval {define_method(:to_s) {name}; alias inspect to_s}
|
||||||
class_eval(&block) if block
|
class_eval(&block) if block
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
Loading…
x
Reference in New Issue
Block a user