Properly resolve refinements in defined? on method call [Bug #16932]
This commit is contained in:
parent
3ced77a82a
commit
8340c773e5
Notes:
git
2020-06-04 02:13:23 +09:00
@ -301,4 +301,32 @@ class TestDefined < Test::Unit::TestCase
|
|||||||
def test_top_level_constant_not_defined
|
def test_top_level_constant_not_defined
|
||||||
assert_nil(defined?(TestDefined::Object))
|
assert_nil(defined?(TestDefined::Object))
|
||||||
end
|
end
|
||||||
|
|
||||||
|
class RefinedClass
|
||||||
|
end
|
||||||
|
|
||||||
|
module RefiningModule
|
||||||
|
refine RefinedClass do
|
||||||
|
def pub
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
def self.call_without_using(x = RefinedClass.new)
|
||||||
|
defined?(x.pub)
|
||||||
|
end
|
||||||
|
|
||||||
|
using self
|
||||||
|
|
||||||
|
def self.call_with_using(x = RefinedClass.new)
|
||||||
|
defined?(x.pub)
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
def test_defined_refined_call_without_using
|
||||||
|
assert(!RefiningModule.call_without_using, "refined public method without using")
|
||||||
|
end
|
||||||
|
|
||||||
|
def test_defined_refined_call_with_using
|
||||||
|
assert(RefiningModule.call_with_using, "refined public method with using")
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
@ -3660,7 +3660,7 @@ vm_defined(rb_execution_context_t *ec, rb_control_frame_t *reg_cfp, rb_num_t op_
|
|||||||
break;
|
break;
|
||||||
case DEFINED_METHOD:{
|
case DEFINED_METHOD:{
|
||||||
VALUE klass = CLASS_OF(v);
|
VALUE klass = CLASS_OF(v);
|
||||||
const rb_method_entry_t *me = rb_method_entry(klass, SYM2ID(obj));
|
const rb_method_entry_t *me = rb_method_entry_with_refinements(klass, SYM2ID(obj), NULL);
|
||||||
|
|
||||||
if (me) {
|
if (me) {
|
||||||
switch (METHOD_ENTRY_VISI(me)) {
|
switch (METHOD_ENTRY_VISI(me)) {
|
||||||
|
@ -1088,7 +1088,7 @@ method_entry_resolve_refinement(VALUE klass, ID id, int with_refinement, VALUE *
|
|||||||
return me;
|
return me;
|
||||||
}
|
}
|
||||||
|
|
||||||
const rb_method_entry_t *
|
MJIT_FUNC_EXPORTED const rb_method_entry_t *
|
||||||
rb_method_entry_with_refinements(VALUE klass, ID id, VALUE *defined_class_ptr)
|
rb_method_entry_with_refinements(VALUE klass, ID id, VALUE *defined_class_ptr)
|
||||||
{
|
{
|
||||||
return method_entry_resolve_refinement(klass, id, TRUE, defined_class_ptr);
|
return method_entry_resolve_refinement(klass, id, TRUE, defined_class_ptr);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user