summaryrefslogtreecommitdiff
path: root/vm_insnhelper.c
diff options
context:
space:
mode:
author卜部昌平 <shyouhei@ruby-lang.org>2019-09-19 10:37:30 +0900
committer卜部昌平 <shyouhei@ruby-lang.org>2019-09-19 15:18:10 +0900
commitfcfe36b7332a29fd6835ba65984448477acc5bcc (patch)
treedcf7d313a616485b89435e7b22898c7628e6d40f /vm_insnhelper.c
parentd74fa8e55ce64904f2f99dfef4cbdff94e290672 (diff)
fix spec failure
See also https://travis-ci.org/ruby/ruby/jobs/586452224
Notes
Notes: Merged: https://github.com/ruby/ruby/pull/2468
Diffstat (limited to 'vm_insnhelper.c')
-rw-r--r--vm_insnhelper.c12
1 files changed, 10 insertions, 2 deletions
diff --git a/vm_insnhelper.c b/vm_insnhelper.c
index 66c50cdf59..bea8d10037 100644
--- a/vm_insnhelper.c
+++ b/vm_insnhelper.c
@@ -1380,7 +1380,7 @@ __attribute__((__artificial__))
#endif
#endif
static inline vm_call_handler
-calccall(const struct rb_call_cache *cc, const rb_callable_method_entry_t *me)
+calccall(const struct rb_call_info *ci, const struct rb_call_cache *cc, const rb_callable_method_entry_t *me)
{
if (UNLIKELY(!me)) {
return vm_call_general; /* vm_call_method_nome() situation */
@@ -1391,6 +1391,14 @@ calccall(const struct rb_call_cache *cc, const rb_callable_method_entry_t *me)
else if (UNLIKELY(cc->def != me->def)) {
return vm_call_general; /* cc->me was refined elsewhere */
}
+ /* "Calling a formerly-public method, which is now privatised, with an
+ * explicit receiver" is the only situation we have to check here. A
+ * formerly-private method now publicised is an absolutely safe thing.
+ * Calling a private method without specifying a receiver is also safe. */
+ else if ((METHOD_ENTRY_VISI(cc->me) != METHOD_VISI_PUBLIC) &&
+ !(ci->flag & VM_CALL_FCALL)) {
+ return vm_call_general;
+ }
else {
return cc->call;
}
@@ -1406,7 +1414,7 @@ rb_vm_search_method_slowpath(const struct rb_call_info *ci, struct rb_call_cache
RCLASS_SERIAL(klass),
me,
me ? me->def : NULL,
- calccall(cc, me),
+ calccall(ci, cc, me),
};
VM_ASSERT(callable_method_entry_p(cc->me));
}