mirror of
https://github.com/ruby/ruby.git
synced 2022-11-09 12:17:21 -05:00
* iseq.c (rb_iseq_clone): sets local_iseq and klass properly.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@26867 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
parent
fec209551a
commit
e3c25091cd
3 changed files with 24 additions and 0 deletions
|
@ -1,3 +1,7 @@
|
||||||
|
Thu Mar 11 01:04:48 2010 Shugo Maeda <shugo@ruby-lang.org>
|
||||||
|
|
||||||
|
* iseq.c (rb_iseq_clone): sets local_iseq and klass properly.
|
||||||
|
|
||||||
Wed Mar 10 21:25:41 2010 Yusuke Endoh <mame@tsg.ne.jp>
|
Wed Mar 10 21:25:41 2010 Yusuke Endoh <mame@tsg.ne.jp>
|
||||||
|
|
||||||
* enum.c (min_ii, max_ii, minmax_ii): remove wrong optimization that
|
* enum.c (min_ii, max_ii, minmax_ii): remove wrong optimization that
|
||||||
|
|
4
iseq.c
4
iseq.c
|
@ -1344,11 +1344,15 @@ rb_iseq_clone(VALUE iseqval, VALUE newcbase)
|
||||||
if (!iseq1->orig) {
|
if (!iseq1->orig) {
|
||||||
iseq1->orig = iseqval;
|
iseq1->orig = iseqval;
|
||||||
}
|
}
|
||||||
|
if (iseq0->local_iseq == iseq0) {
|
||||||
|
iseq1->local_iseq = iseq1;
|
||||||
|
}
|
||||||
if (newcbase) {
|
if (newcbase) {
|
||||||
iseq1->cref_stack = NEW_BLOCK(newcbase);
|
iseq1->cref_stack = NEW_BLOCK(newcbase);
|
||||||
if (iseq0->cref_stack->nd_next) {
|
if (iseq0->cref_stack->nd_next) {
|
||||||
iseq1->cref_stack->nd_next = iseq0->cref_stack->nd_next;
|
iseq1->cref_stack->nd_next = iseq0->cref_stack->nd_next;
|
||||||
}
|
}
|
||||||
|
iseq1->klass = newcbase;
|
||||||
}
|
}
|
||||||
|
|
||||||
return newiseq;
|
return newiseq;
|
||||||
|
|
|
@ -220,4 +220,20 @@ class TestClass < Test::Unit::TestCase
|
||||||
assert_raise(SyntaxError) { eval("class C; return; end") }
|
assert_raise(SyntaxError) { eval("class C; return; end") }
|
||||||
assert_raise(SyntaxError) { eval("class C; yield; end") }
|
assert_raise(SyntaxError) { eval("class C; yield; end") }
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def test_clone
|
||||||
|
original = Class.new {
|
||||||
|
def foo
|
||||||
|
return super()
|
||||||
|
end
|
||||||
|
}
|
||||||
|
mod = Module.new {
|
||||||
|
def foo
|
||||||
|
return "mod#foo"
|
||||||
|
end
|
||||||
|
}
|
||||||
|
copy = original.clone
|
||||||
|
copy.send(:include, mod)
|
||||||
|
assert_equal("mod#foo", copy.new.foo)
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
Loading…
Add table
Reference in a new issue