Revert "Symbol refinements [Bug #15114]"
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@66150 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
parent
cd5b309575
commit
1a1dd5ccf4
1
method.h
1
method.h
@ -199,7 +199,6 @@ const rb_method_entry_t *rb_method_entry(VALUE klass, ID id);
|
|||||||
const rb_method_entry_t *rb_method_entry_without_refinements(VALUE klass, ID id, VALUE *defined_class);
|
const rb_method_entry_t *rb_method_entry_without_refinements(VALUE klass, ID id, VALUE *defined_class);
|
||||||
const rb_method_entry_t *rb_resolve_refined_method(VALUE refinements, const rb_method_entry_t *me);
|
const rb_method_entry_t *rb_resolve_refined_method(VALUE refinements, const rb_method_entry_t *me);
|
||||||
RUBY_SYMBOL_EXPORT_BEGIN
|
RUBY_SYMBOL_EXPORT_BEGIN
|
||||||
const rb_callable_method_entry_t *rb_resolve_refined_method_callable(VALUE refinements, const rb_callable_method_entry_t *me);
|
|
||||||
const rb_method_entry_t *rb_resolve_me_location(const rb_method_entry_t *, VALUE[5]);
|
const rb_method_entry_t *rb_resolve_me_location(const rb_method_entry_t *, VALUE[5]);
|
||||||
RUBY_SYMBOL_EXPORT_END
|
RUBY_SYMBOL_EXPORT_END
|
||||||
|
|
||||||
|
@ -161,32 +161,6 @@ class TestSymbol < Test::Unit::TestCase
|
|||||||
assert_equal(1, first, bug11594)
|
assert_equal(1, first, bug11594)
|
||||||
end
|
end
|
||||||
|
|
||||||
class TestToPRocArgWithRefinements; end
|
|
||||||
def _test_to_proc_arg_with_refinements_call(&block)
|
|
||||||
block.call TestToPRocArgWithRefinements.new
|
|
||||||
end
|
|
||||||
using Module.new {
|
|
||||||
refine TestToPRocArgWithRefinements do
|
|
||||||
def hoge
|
|
||||||
:hoge
|
|
||||||
end
|
|
||||||
end
|
|
||||||
}
|
|
||||||
def test_to_proc_arg_with_refinements
|
|
||||||
assert_equal(:hoge, _test_to_proc_arg_with_refinements_call(&:hoge))
|
|
||||||
end
|
|
||||||
|
|
||||||
using Module.new {
|
|
||||||
refine TestToPRocArgWithRefinements do
|
|
||||||
def hoge
|
|
||||||
:hogehoge
|
|
||||||
end
|
|
||||||
end
|
|
||||||
}
|
|
||||||
def test_to_proc_arg_with_refinements_override
|
|
||||||
assert_equal(:hogehoge, _test_to_proc_arg_with_refinements_call(&:hoge))
|
|
||||||
end
|
|
||||||
|
|
||||||
private def return_from_proc
|
private def return_from_proc
|
||||||
Proc.new { return 1 }.tap(&:call)
|
Proc.new { return 1 }.tap(&:call)
|
||||||
end
|
end
|
||||||
|
16
vm_args.c
16
vm_args.c
@ -851,17 +851,13 @@ refine_sym_proc_call(RB_BLOCK_CALL_FUNC_ARGLIST(yielded_arg, callback_arg))
|
|||||||
ID mid;
|
ID mid;
|
||||||
const rb_callable_method_entry_t *me;
|
const rb_callable_method_entry_t *me;
|
||||||
rb_execution_context_t *ec;
|
rb_execution_context_t *ec;
|
||||||
const VALUE symbol = RARRAY_AREF(callback_arg, 0);
|
|
||||||
const VALUE refinements = RARRAY_AREF(callback_arg, 1);
|
|
||||||
|
|
||||||
if (argc-- < 1) {
|
if (argc-- < 1) {
|
||||||
rb_raise(rb_eArgError, "no receiver given");
|
rb_raise(rb_eArgError, "no receiver given");
|
||||||
}
|
}
|
||||||
obj = *argv++;
|
obj = *argv++;
|
||||||
|
mid = SYM2ID(callback_arg);
|
||||||
mid = SYM2ID(symbol);
|
me = rb_callable_method_entry_with_refinements(CLASS_OF(obj), mid, NULL);
|
||||||
me = rb_resolve_refined_method_callable(refinements, (const rb_callable_method_entry_t *)rb_method_entry(CLASS_OF(obj), mid));
|
|
||||||
|
|
||||||
ec = GET_EC();
|
ec = GET_EC();
|
||||||
if (!NIL_P(blockarg)) {
|
if (!NIL_P(blockarg)) {
|
||||||
vm_passed_block_handler_set(ec, blockarg);
|
vm_passed_block_handler_set(ec, blockarg);
|
||||||
@ -889,8 +885,12 @@ vm_caller_setup_arg_block(const rb_execution_context_t *ec, rb_control_frame_t *
|
|||||||
const rb_cref_t *cref = vm_env_cref(reg_cfp->ep);
|
const rb_cref_t *cref = vm_env_cref(reg_cfp->ep);
|
||||||
if (cref && !NIL_P(cref->refinements)) {
|
if (cref && !NIL_P(cref->refinements)) {
|
||||||
VALUE ref = cref->refinements;
|
VALUE ref = cref->refinements;
|
||||||
VALUE callback_arg = rb_ary_new_from_args(2, block_code, ref);
|
VALUE func = rb_hash_lookup(ref, block_code);
|
||||||
VALUE func = rb_func_proc_new(refine_sym_proc_call, callback_arg);
|
if (NIL_P(func)) {
|
||||||
|
/* TODO: limit cached funcs */
|
||||||
|
func = rb_func_proc_new(refine_sym_proc_call, block_code);
|
||||||
|
rb_hash_aset(ref, block_code, func);
|
||||||
|
}
|
||||||
block_code = func;
|
block_code = func;
|
||||||
}
|
}
|
||||||
return block_code;
|
return block_code;
|
||||||
|
@ -967,7 +967,7 @@ rb_resolve_refined_method(VALUE refinements, const rb_method_entry_t *me)
|
|||||||
return resolve_refined_method(refinements, me, NULL);
|
return resolve_refined_method(refinements, me, NULL);
|
||||||
}
|
}
|
||||||
|
|
||||||
const rb_callable_method_entry_t *
|
static const rb_callable_method_entry_t *
|
||||||
rb_resolve_refined_method_callable(VALUE refinements, const rb_callable_method_entry_t *me)
|
rb_resolve_refined_method_callable(VALUE refinements, const rb_callable_method_entry_t *me)
|
||||||
{
|
{
|
||||||
VALUE defined_class = me->defined_class;
|
VALUE defined_class = me->defined_class;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user