Use RTEST to to check return value

rb_obj_is_kind_of returns a Ruby Qtrue or Qfalse. We should use RTEST
rather than assuming that Qfalse is 0.
This commit is contained in:
Peter Zhu 2022-11-04 09:02:58 -04:00
Родитель 76a6c5d6d1
Коммит 93f364d65e
1 изменённых файлов: 1 добавлений и 1 удалений

2
proc.c
Просмотреть файл

@ -2571,7 +2571,7 @@ convert_umethod_to_method_components(const struct METHOD *data, VALUE recv, VALU
VALUE refined_class = rb_refinement_module_get_refined_class(methclass);
if (!NIL_P(refined_class)) methclass = refined_class;
}
if (!RB_TYPE_P(methclass, T_MODULE) && !rb_obj_is_kind_of(recv, methclass)) {
if (!RB_TYPE_P(methclass, T_MODULE) && !RTEST(rb_obj_is_kind_of(recv, methclass))) {
if (FL_TEST(methclass, FL_SINGLETON)) {
rb_raise(rb_eTypeError,
"singleton method called for a different object");