summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--ChangeLog7
-rw-r--r--insns.def19
-rw-r--r--test/ruby/test_super.rb25
3 files changed, 29 insertions, 22 deletions
diff --git a/ChangeLog b/ChangeLog
index b8977fc4d3..50bbb8dbbf 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,10 @@
+Thu Aug 23 12:51:39 2012 Shugo Maeda <shugo@ruby-lang.org>
+
+ * insns.def (invokesuper): reverted r36640 partially to make super
+ in a thread work correctly. [ruby-core:47284] [Bug #6907]
+
+ * test/ruby/test_super.rb: related test.
+
Thu Aug 23 12:30:20 2012 NAKAMURA Usaku <usa@ruby-lang.org>
* win32/configure.bat: support --with(out)?-ext(ensions) options.
diff --git a/insns.def b/insns.def
index f9e582efb0..7c9dd6ae6c 100644
--- a/insns.def
+++ b/insns.def
@@ -1026,8 +1026,6 @@ invokesuper
int num = caller_setup_args(th, GET_CFP(), flag,
(int)op_argc, blockiseq, &blockptr);
VALUE recv, klass;
- rb_control_frame_t *cfp = GET_CFP();
- rb_control_frame_t *end_cfp = RUBY_VM_END_CONTROL_FRAME(th);
ID id;
const rb_method_entry_t *me;
rb_iseq_t *ip;
@@ -1038,20 +1036,9 @@ invokesuper
if (!NIL_P(RCLASS_REFINED_CLASS(klass))) {
klass = RCLASS_REFINED_CLASS(klass);
}
-
- recv = Qundef;
- while (RUBY_VM_VALID_CONTROL_FRAME_P(cfp, end_cfp)) {
- if (((VM_EP_LEP_P(cfp->ep) && cfp->iseq &&
- cfp->iseq->type == ISEQ_TYPE_METHOD) ||
- (cfp->me && cfp->me->def->type == VM_METHOD_TYPE_BMETHOD)) &&
- rb_obj_is_kind_of(cfp->self, klass)) {
- recv = cfp->self;
- break;
- }
- cfp = RUBY_VM_PREVIOUS_CONTROL_FRAME(cfp);
- }
- if (recv == Qundef) {
- rb_raise(rb_eNoMethodError, "super called outside of method");
+ recv = GET_SELF();
+ if (!rb_obj_is_kind_of(recv, klass)) {
+ rb_raise(rb_eNotImpError, "super from singleton method that is defined to multiple classes is not supported; this will be fixed in 2.0.0 or later");
}
vm_search_superclass(GET_CFP(), GET_ISEQ(), TOPN(num), &id, &klass);
diff --git a/test/ruby/test_super.rb b/test/ruby/test_super.rb
index 7208b362fc..dcd700858c 100644
--- a/test/ruby/test_super.rb
+++ b/test/ruby/test_super.rb
@@ -264,7 +264,9 @@ class TestSuper < Test::Unit::TestCase
end
}
obj = sub_class.new
- assert_equal [:super, obj], obj.foo
+ assert_raise(NotImplementedError) do
+ obj.foo
+ end
end
def test_super_in_instance_eval_with_define_method
@@ -282,7 +284,9 @@ class TestSuper < Test::Unit::TestCase
end
}
obj = sub_class.new
- assert_equal [:super, obj], obj.foo
+ assert_raise(NotImplementedError) do
+ obj.foo
+ end
end
def test_super_in_orphan_block
@@ -298,9 +302,7 @@ class TestSuper < Test::Unit::TestCase
end
}
obj = sub_class.new
- assert_raise(NoMethodError) do
- obj.foo.call
- end
+ assert_equal([:super, obj], obj.foo.call)
end
def test_super_in_orphan_block_with_instance_eval
@@ -318,7 +320,7 @@ class TestSuper < Test::Unit::TestCase
end
}
obj = sub_class.new
- assert_raise(NoMethodError) do
+ assert_raise(NotImplementedError) do
obj.foo.call
end
end
@@ -334,4 +336,15 @@ class TestSuper < Test::Unit::TestCase
}
assert_equal 'hi', y.hello
end
+
+ def test_super_in_thread
+ hoge = Class.new {
+ def bar; 'hoge'; end
+ }
+ foo = Class.new(hoge) {
+ def bar; Thread.new { super }.join.value; end
+ }
+
+ assert_equal 'hoge', foo.new.bar
+ end
end