mirror of
https://github.com/ruby/ruby.git
synced 2025-09-23 20:44:00 +02:00
vm_insnhelper.c: iclass as klass in cfp
* vm_insnhelper.c (vm_call_method): follow iclasses as klass in cfp but not included modules. [ruby-core:47241] [Bug #6891] * vm_insnhelper.c (vm_call_bmethod): pass defined_class to follow proper ancestors. [ruby-core:47241] [Bug #6891] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@36736 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
parent
de83cb9b20
commit
ceece4650a
9 changed files with 103 additions and 23 deletions
|
@ -1398,4 +1398,58 @@ class TestModule < Test::Unit::TestCase
|
|||
assert_equal([:@@bar, :@@foo], m2.class_variables(true))
|
||||
assert_equal([:@@bar], m2.class_variables(false))
|
||||
end
|
||||
|
||||
Bug6891 = '[ruby-core:47241]'
|
||||
|
||||
def test_extend_module_with_protected_method
|
||||
list = []
|
||||
|
||||
x = Class.new {
|
||||
@list = list
|
||||
|
||||
extend Module.new {
|
||||
protected
|
||||
|
||||
def inherited(klass)
|
||||
@list << "protected"
|
||||
super(klass)
|
||||
end
|
||||
}
|
||||
|
||||
extend Module.new {
|
||||
def inherited(klass)
|
||||
@list << "public"
|
||||
super(klass)
|
||||
end
|
||||
}
|
||||
}
|
||||
|
||||
assert_nothing_raised(NoMethodError, Bug6891) {Class.new(x)}
|
||||
assert_equal(['public', 'protected'], list)
|
||||
end
|
||||
|
||||
def test_extend_module_with_protected_bmethod
|
||||
list = []
|
||||
|
||||
x = Class.new {
|
||||
extend Module.new {
|
||||
protected
|
||||
|
||||
define_method(:inherited) do |klass|
|
||||
list << "protected"
|
||||
super(klass)
|
||||
end
|
||||
}
|
||||
|
||||
extend Module.new {
|
||||
define_method(:inherited) do |klass|
|
||||
list << "public"
|
||||
super(klass)
|
||||
end
|
||||
}
|
||||
}
|
||||
|
||||
assert_nothing_raised(NoMethodError, Bug6891) {Class.new(x)}
|
||||
assert_equal(['public', 'protected'], list)
|
||||
end
|
||||
end
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue