mrb_method_search_vm() should gives the defined class.

Otherwise `super` may call a wrong method.
This commit is contained in:
Yukihiro "Matz" Matsumoto
2017-12-06 07:53:00 +09:00
parent 4a99f4949e
commit b00d45b095
2 changed files with 3 additions and 1 deletions
+1 -1
View File
@@ -186,7 +186,7 @@ typedef struct {
#ifdef MRB_METHOD_CACHE
struct mrb_cache_entry {
struct RClass *c;
struct RClass *c, *c0;
mrb_sym mid;
mrb_method_t m;
};
+2
View File
@@ -1398,6 +1398,7 @@ mrb_method_search_vm(mrb_state *mrb, struct RClass **cp, mrb_sym mid)
struct mrb_cache_entry *mc = &mrb->cache[h];
if (mc->c == c && mc->mid == mid) {
*cp = mc->c0;
return mc->m;
}
#endif
@@ -1413,6 +1414,7 @@ mrb_method_search_vm(mrb_state *mrb, struct RClass **cp, mrb_sym mid)
*cp = c;
#ifdef MRB_METHOD_CACHE
mc->c = oc;
mc->c0 = c;
mc->mid = mid;
mc->m = m;
#endif