1
0
Fork 0
mirror of https://github.com/ruby/ruby.git synced 2022-11-09 12:17:21 -05:00

* insns.def (invokesuper): reverted r36612 so that super in an

aliased method will not call the same method.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@36613 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
shugo 2012-08-03 16:32:52 +00:00
parent 2d3d84155d
commit 9bef3f0519
3 changed files with 48 additions and 2 deletions

View file

@ -1,3 +1,8 @@
Sat Aug 4 01:27:40 2012 Shugo Maeda <shugo@ruby-lang.org>
* insns.def (invokesuper): reverted r36612 so that super in an
aliased method will not call the same method.
Fri Aug 3 19:26:10 2012 Shugo Maeda <shugo@ruby-lang.org>
* insns.def (invokesuper): don't skip the same class. instead, use

View file

@ -1045,7 +1045,12 @@ invokesuper
while (ip && !ip->klass) {
ip = ip->parent_iseq;
}
me = rb_method_entry_get_with_omod(Qnil, klass, id, &klass);
me = rb_method_entry(klass, id, &klass);
if (me && me->def->type == VM_METHOD_TYPE_ISEQ &&
me->def->body.iseq == ip) {
klass = RCLASS_SUPER(klass);
me = rb_method_entry_get_with_omod(Qnil, klass, id, &klass);
}
CALL_METHOD(num, blockptr, flag, id, me, recv, klass);
}

View file

@ -210,6 +210,42 @@ class TestSuper < Test::Unit::TestCase
# [Bug #3351]
def test_double_include
assert_equal([:Base, :Override, :Override], DoubleInclude::B.new.foo)
assert_equal([:Base, :Override], DoubleInclude::B.new.foo)
# should be changed as follows?
# assert_equal([:Base, :Override, :Override], DoubleInclude::B.new.foo)
end
module DoubleInclude2
class Base
def foo
[:Base]
end
end
module Override
def foo
super << :Override
end
end
class A < Base
def foo
super << :A
end
end
class B < A
def foo
super << :B
end
end
B.send(:include, Override)
A.send(:include, Override)
end
def test_double_include
assert_equal([:Base, :Override, :A, :Override, :B],
DoubleInclude2::B.new.foo)
end
end