fix bug in keyword + protected combination

Test included for the situation formerly was not working.
This commit is contained in:
卜部昌平 2019-10-28 14:36:28 +09:00
Родитель a72cb6b11d
Коммит cc5580f175
2 изменённых файлов: 25 добавлений и 2 удалений

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

@ -4859,4 +4859,20 @@ class TestKeywordArgumentsSymProcRefinements < Test::Unit::TestCase
assert_equal([1, h3], c.call(**h3, &:m2))
assert_equal([1, h3], c.call(a: 1, **h2, &:m2))
end
def test_protected_kwarg
mock = Class.new do
def foo
bar('x', y: 'z')
end
protected
def bar(x, y)
nil
end
end
assert_nothing_raised do
mock.new.foo
end
end
end

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

@ -2879,10 +2879,17 @@ vm_call_method(rb_execution_context_t *ec, rb_control_frame_t *cfp, struct rb_ca
else {
/* caching method info to dummy cc */
VM_ASSERT(cc->me != NULL);
if (ci->flag & VM_CALL_KWARG) {
struct rb_kwarg_call_data *kcd = (void *)cd;
struct rb_kwarg_call_data cd_entry = *kcd;
return vm_call_method_each_type(ec, cfp, calling, (void *)&cd_entry);
}
else {
struct rb_call_data cd_entry = *cd;
return vm_call_method_each_type(ec, cfp, calling, &cd_entry);
}
}
}
return vm_call_method_each_type(ec, cfp, calling, cd);
default: