зеркало из https://github.com/github/ruby.git
class.c: fix duplication of prepended module
* class.c (include_class_new): fix duplication of prepended module. since m_tbl of prepended module is always zero, copy from its copy iclass of original. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@36585 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
Родитель
bc08bdc013
Коммит
b283d01987
|
@ -1,3 +1,9 @@
|
|||
Wed Aug 1 00:33:19 2012 Nobuyoshi Nakada <nobu@ruby-lang.org>
|
||||
|
||||
* class.c (include_class_new): fix duplication of prepended module.
|
||||
since m_tbl of prepended module is always zero, copy from its
|
||||
copy iclass of original.
|
||||
|
||||
Tue Jul 31 18:22:34 2012 Nobuyoshi Nakada <nobu@ruby-lang.org>
|
||||
|
||||
* variable.c (classname): tell if found name is permanent. search
|
||||
|
|
2
class.c
2
class.c
|
@ -636,7 +636,7 @@ include_class_new(VALUE module, VALUE super)
|
|||
}
|
||||
RCLASS_IV_TBL(klass) = RCLASS_IV_TBL(module);
|
||||
RCLASS_CONST_TBL(klass) = RCLASS_CONST_TBL(module);
|
||||
RCLASS_M_TBL(klass) = RCLASS_M_TBL(module);
|
||||
RCLASS_M_TBL(klass) = RCLASS_M_TBL(RCLASS_ORIGIN(module));
|
||||
RCLASS_SUPER(klass) = super;
|
||||
if (RB_TYPE_P(module, T_ICLASS)) {
|
||||
RBASIC(klass)->klass = RBASIC(module)->klass;
|
||||
|
|
|
@ -1356,6 +1356,15 @@ class TestModule < Test::Unit::TestCase
|
|||
assert_equal([:m0, :m1, :m2, :c1], c1.new.x)
|
||||
assert_equal([c2, m0, m1, m2, c0], c2.ancestors[0, 5], bug6662)
|
||||
assert_equal([:c2, :m0, :m1, :m2, :c0], c2.new.x)
|
||||
|
||||
m3 = labeled_module("m3") {include m1; prepend m1}
|
||||
assert_equal([m3, m0, m1], m3.ancestors)
|
||||
m3 = labeled_module("m3") {prepend m1; include m1}
|
||||
assert_equal([m0, m1, m3], m3.ancestors)
|
||||
m3 = labeled_module("m3") {prepend m1; prepend m1}
|
||||
assert_equal([m0, m1, m3], m3.ancestors)
|
||||
m3 = labeled_module("m3") {include m1; include m1}
|
||||
assert_equal([m3, m0, m1], m3.ancestors)
|
||||
end
|
||||
|
||||
def labeled_module(name, &block)
|
||||
|
|
Загрузка…
Ссылка в новой задаче