[前][次][番号順一覧][スレッド一覧]

ruby-changes:60025

From: Koichi <ko1@a...>
Date: Thu, 13 Feb 2020 03:32:25 +0900 (JST)
Subject: [ruby-changes:60025] 99a8742067 (master): should be compared with called_id

https://git.ruby-lang.org/ruby.git/commit/?id=99a8742067

From 99a8742067ba262eb324615bfac770d1aea53b07 Mon Sep 17 00:00:00 2001
From: Koichi Sasada <ko1@a...>
Date: Thu, 13 Feb 2020 03:28:40 +0900
Subject: 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)

diff --git a/test/ruby/test_super.rb b/test/ruby/test_super.rb
index 7c4beff..3d5af3d 100644
--- a/test/ruby/test_super.rb
+++ b/test/ruby/test_super.rb
@@ -585,15 +585,22 @@ class TestSuper < Test::Unit::TestCase https://github.com/ruby/ruby/blob/trunk/test/ruby/test_super.rb#L585
   end
 
   def test_super_with_define_method
-    superklass = Class.new do
+    superklass1 = Class.new do
       def foo; :foo; end
       def bar; :bar; end
+      def boo; :boo; end
     end
-    subklass = Class.new(superklass)
-    [:foo, :bar].each do |sym|
+    superklass2 = Class.new(superklass1) do
+      alias baz boo
+      def boo; :boo2; end
+    end
+    subklass = Class.new(superklass2)
+    [:foo, :bar, :baz, :boo].each do |sym|
       subklass.define_method(sym){ super() }
     end
     assert_equal :foo, subklass.new.foo
     assert_equal :bar, subklass.new.bar
+    assert_equal :boo, subklass.new.baz
+    assert_equal :boo2, subklass.new.boo
   end
 end
diff --git a/vm_insnhelper.c b/vm_insnhelper.c
index 9404b0d..acd5de4 100644
--- a/vm_insnhelper.c
+++ b/vm_insnhelper.c
@@ -3161,7 +3161,7 @@ vm_search_super_method(const rb_control_frame_t *reg_cfp, struct rb_call_data *c https://github.com/ruby/ruby/blob/trunk/vm_insnhelper.c#L3161
 	if (LIKELY(RB_DEBUG_COUNTER_INC_UNLESS(mc_global_state_miss,
 			GET_GLOBAL_METHOD_STATE() == cc->method_state) &&
 			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);
 	    RB_DEBUG_COUNTER_INC(mc_inline_hit);
 	    return;
-- 
cgit v0.10.2


--
ML: ruby-changes@q...
Info: http://www.atdot.net/~ko1/quickml/

[前][次][番号順一覧][スレッド一覧]