should be compared with called_id

me->called_id and me->def->original_id can be different sometimes
so we should compare with called_id, which is mtbl's key.
(fix GH-PR #2869)
This commit is contained in:
Koichi Sasada 2020-02-13 03:28:40 +09:00
Родитель bc1dbed16c
Коммит 99a8742067
2 изменённых файлов: 11 добавлений и 4 удалений

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

@ -585,15 +585,22 @@ class TestSuper < Test::Unit::TestCase
end end
def test_super_with_define_method def test_super_with_define_method
superklass = Class.new do superklass1 = Class.new do
def foo; :foo; end def foo; :foo; end
def bar; :bar; end def bar; :bar; end
def boo; :boo; end
end end
subklass = Class.new(superklass) superklass2 = Class.new(superklass1) do
[:foo, :bar].each do |sym| alias baz boo
def boo; :boo2; end
end
subklass = Class.new(superklass2)
[:foo, :bar, :baz, :boo].each do |sym|
subklass.define_method(sym){ super() } subklass.define_method(sym){ super() }
end end
assert_equal :foo, subklass.new.foo assert_equal :foo, subklass.new.foo
assert_equal :bar, subklass.new.bar assert_equal :bar, subklass.new.bar
assert_equal :boo, subklass.new.baz
assert_equal :boo2, subklass.new.boo
end end
end end

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

@ -3161,7 +3161,7 @@ vm_search_super_method(const rb_control_frame_t *reg_cfp, struct rb_call_data *c
if (LIKELY(RB_DEBUG_COUNTER_INC_UNLESS(mc_global_state_miss, if (LIKELY(RB_DEBUG_COUNTER_INC_UNLESS(mc_global_state_miss,
GET_GLOBAL_METHOD_STATE() == cc->method_state) && GET_GLOBAL_METHOD_STATE() == cc->method_state) &&
cc->class_serial[0] == RCLASS_SERIAL(klass)) && cc->class_serial[0] == RCLASS_SERIAL(klass)) &&
cc->me && ci->mid == cc->me->def->original_id) { cc->me && ci->mid == cc->me->called_id) {
VM_ASSERT(cc->call != NULL); VM_ASSERT(cc->call != NULL);
RB_DEBUG_COUNTER_INC(mc_inline_hit); RB_DEBUG_COUNTER_INC(mc_inline_hit);
return; return;