summaryrefslogtreecommitdiff
path: root/enum.c
diff options
context:
space:
mode:
authornobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2017-05-24 08:00:42 (GMT)
committernobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2017-05-24 08:00:42 (GMT)
commit5e25bfa2fbd659c7e0fe8c244633dc847218cee5 (patch)
tree0d9db068642ea6cd430e8c9a87e6dbc860bef5a7 /enum.c
parentda9d5db8bd14c2e2ed7ad32481f0937f6fc47c46 (diff)
enum.c: respect method visibility
* enum.c (ary_inject_op): should respect method visibility, do not optimize uncallable method. [ruby-core:81349] [Bug #13592] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@58871 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'enum.c')
-rw-r--r--enum.c7
1 files changed, 4 insertions, 3 deletions
diff --git a/enum.c b/enum.c
index 4e14e82..674c3cc 100644
--- a/enum.c
+++ b/enum.c
@@ -678,8 +678,9 @@ ary_inject_op(VALUE ary, VALUE init, VALUE op)
id = SYM2ID(op);
if (id == idPLUS) {
- if ((FIXNUM_P(v) || RB_TYPE_P(v, T_BIGNUM)) &&
- rb_method_basic_definition_p(rb_cInteger, idPLUS)) {
+ if (RB_INTEGER_TYPE_P(v) &&
+ rb_method_basic_definition_p(rb_cInteger, idPLUS) &&
+ rb_obj_respond_to(v, idPLUS, FALSE)) {
n = 0;
for (; i < RARRAY_LEN(ary); i++) {
e = RARRAY_AREF(ary, i);
@@ -705,7 +706,7 @@ ary_inject_op(VALUE ary, VALUE init, VALUE op)
}
}
for (; i < RARRAY_LEN(ary); i++) {
- v = rb_funcall(v, id, 1, RARRAY_AREF(ary, i));
+ v = rb_funcallv_public(v, id, 1, &RARRAY_CONST_PTR(ary)[i]);
}
return v;
}