summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--ChangeLog9
-rw-r--r--proc.c8
-rw-r--r--test/ruby/test_method.rb15
3 files changed, 30 insertions, 2 deletions
diff --git a/ChangeLog b/ChangeLog
index b0dca87b1d..6bebbcbe29 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,8 +1,17 @@
+Fri Jan 8 23:35:18 2010 Yusuke Endoh <mame@tsg.ne.jp>
+
+ * proc.c (mnew): don't check visibility of method body if public
+ ZSUPER method is found. [ruby-dev:39767]
+
+ * test/ruby/test_method.rb: add a test for above.
+
Fri Jan 8 22:59:40 2010 Yusuke Endoh <mame@tsg.ne.jp>
* vm_method.c (rb_alias): skip ZSUPER method when searching body of
source method. [ruby-dev:39760]
+ * test/ruby/test_alias.rb: add a test for above.
+
Fri Jan 8 21:15:21 2010 NARUSE, Yui <naruse@ruby-lang.org>
* lib/net/http, lib/net/https: move content from net/https to
diff --git a/proc.c b/proc.c
index c64eb72fb1..543ee95923 100644
--- a/proc.c
+++ b/proc.c
@@ -894,6 +894,7 @@ mnew(VALUE klass, VALUE obj, ID id, VALUE mclass, int scope)
struct METHOD *data;
rb_method_entry_t *me, meb;
rb_method_definition_t *def = 0;
+ rb_method_flag_t flag = NOEX_UNDEF;
again:
me = rb_method_entry(klass, id);
@@ -921,8 +922,11 @@ mnew(VALUE klass, VALUE obj, ID id, VALUE mclass, int scope)
rb_print_undef(klass, id, 0);
}
def = me->def;
- if (scope && (me->flag & NOEX_MASK) != NOEX_PUBLIC) {
- rb_print_undef(rclass, def->original_id, (int)(me->flag & NOEX_MASK));
+ if (flag == NOEX_UNDEF) {
+ flag = me->flag;
+ if (scope && (flag & NOEX_MASK) != NOEX_PUBLIC) {
+ rb_print_undef(rclass, def->original_id, (int)(flag & NOEX_MASK));
+ }
}
if (def && def->type == VM_METHOD_TYPE_ZSUPER) {
klass = RCLASS_SUPER(me->klass);
diff --git a/test/ruby/test_method.rb b/test/ruby/test_method.rb
index d5d6a0e68d..08603c9981 100644
--- a/test/ruby/test_method.rb
+++ b/test/ruby/test_method.rb
@@ -312,4 +312,19 @@ class TestMethod < Test::Unit::TestCase
assert_equal([[:req, :a], [:opt, :b], [:rest, :c], [:req, :d], [:block, :e]], self.class.instance_method(:pmo7).parameters)
assert_equal([[:req], [:block, :b]], self.class.instance_method(:pma1).parameters)
end
+
+ def test_public_method_with_zsuper_method
+ c = Class.new
+ c.class_eval do
+ def foo
+ :ok
+ end
+ private :foo
+ end
+ d = Class.new(c)
+ d.class_eval do
+ public :foo
+ end
+ assert_equal(:ok, d.new.public_method(:foo).call)
+ end
end