Project

General

Profile

Bug #10753 » 0001-vm_method.c-method-defined-should-not-use-refinement.patch

hanachin (Seiei Miyagi), 01/17/2015 06:47 PM

View differences:

test/ruby/test_refinement.rb
end;
end
def test_refined_method_defined
assert_separately([], <<-"end;")
bug10753 = '[ruby-core:67656] [Bug #10753]'
c = Class.new do
def refined_public; end
def refined_protected; end
def refined_private; end
public :refined_public
protected :refined_protected
private :refined_private
end
m = Module.new do
refine(c) do
def refined_public; end
def refined_protected; end
def refined_private; end
public :refined_public
protected :refined_protected
private :refined_private
end
end
using m
assert_equal(true, c.public_method_defined?(:refined_public), bug10753)
assert_equal(false, c.public_method_defined?(:refined_protected), bug10753)
assert_equal(false, c.public_method_defined?(:refined_private), bug10753)
assert_equal(false, c.protected_method_defined?(:refined_public), bug10753)
assert_equal(true, c.protected_method_defined?(:refined_protected), bug10753)
assert_equal(false, c.protected_method_defined?(:refined_private), bug10753)
assert_equal(false, c.private_method_defined?(:refined_public), bug10753)
assert_equal(false, c.private_method_defined?(:refined_protected), bug10753)
assert_equal(true, c.private_method_defined?(:refined_private), bug10753)
end;
end
def test_undefined_refined_method_defined
assert_separately([], <<-"end;")
bug10753 = '[ruby-core:67656] [Bug #10753]'
c = Class.new
m = Module.new do
refine(c) do
def undefined_refined_public; end
def undefined_refined_protected; end
def undefined_refined_private; end
public :undefined_refined_public
protected :undefined_refined_protected
private :undefined_refined_private
end
end
using m
assert_equal(false, c.public_method_defined?(:undefined_refined_public), bug10753)
assert_equal(false, c.public_method_defined?(:undefined_refined_protected), bug10753)
assert_equal(false, c.public_method_defined?(:undefined_refined_private), bug10753)
assert_equal(false, c.protected_method_defined?(:undefined_refined_public), bug10753)
assert_equal(false, c.protected_method_defined?(:undefined_refined_protected), bug10753)
assert_equal(false, c.protected_method_defined?(:undefined_refined_private), bug10753)
assert_equal(false, c.private_method_defined?(:undefined_refined_public), bug10753)
assert_equal(false, c.private_method_defined?(:undefined_refined_protected), bug10753)
assert_equal(false, c.private_method_defined?(:undefined_refined_private), bug10753)
end;
end
private
def eval_using(mod, s)
vm_method.c
const rb_method_entry_t *me;
ID id = rb_check_id(&mid);
if (!id) return Qfalse;
me = rb_method_entry(mod, id, 0);
me = rb_method_entry_without_refinements(mod, id, 0);
if (me) {
if (VISI_CHECK(me->flag, noex))
return Qtrue;
(3-3/3)