mirror of
https://github.com/ruby/ruby.git
synced 2022-11-09 12:17:21 -05:00
* vm_insnhelper.c (vm_method_search): return rb_cObject if there is no
super class. [ruby-dev:37587] * bootstraptest/test_method.rb: add tests for above. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@20981 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
parent
7c982059ea
commit
a71fb38d47
3 changed files with 51 additions and 3 deletions
|
@ -1,3 +1,10 @@
|
|||
Thu Dec 25 13:13:00 2008 Koichi Sasada <ko1@atdot.net>
|
||||
|
||||
* vm_insnhelper.c (vm_method_search): return rb_cObject if there is no
|
||||
super class. [ruby-dev:37587]
|
||||
|
||||
* bootstraptest/test_method.rb: add tests for above.
|
||||
|
||||
Thu Dec 25 12:49:12 2008 Koichi Sasada <ko1@atdot.net>
|
||||
|
||||
* proc.c (proc_new): should use proc_dup() if block has Proc.
|
||||
|
|
|
@ -1103,3 +1103,40 @@ assert_equal '["B", "A"]', %q{
|
|||
|
||||
C.new.m
|
||||
}
|
||||
|
||||
assert_equal 'ok', %q{
|
||||
module Foo
|
||||
def foo
|
||||
begin
|
||||
super
|
||||
rescue NoMethodError
|
||||
:ok
|
||||
end
|
||||
end
|
||||
module_function :foo
|
||||
end
|
||||
Foo.foo
|
||||
}, '[ruby-dev:37587]'
|
||||
|
||||
assert_equal 'Object#foo', %q{
|
||||
class Object
|
||||
def self.foo
|
||||
"Object.foo"
|
||||
end
|
||||
def foo
|
||||
"Object#foo"
|
||||
end
|
||||
end
|
||||
|
||||
module Foo
|
||||
def foo
|
||||
begin
|
||||
super
|
||||
rescue NoMethodError
|
||||
:ok
|
||||
end
|
||||
end
|
||||
module_function :foo
|
||||
end
|
||||
Foo.foo
|
||||
}, '[ruby-dev:37587]'
|
||||
|
|
|
@ -1172,20 +1172,24 @@ vm_method_search(VALUE id, VALUE klass, IC ic)
|
|||
static inline VALUE
|
||||
vm_search_normal_superclass(VALUE klass, VALUE recv)
|
||||
{
|
||||
VALUE sk = 0;
|
||||
|
||||
if (BUILTIN_TYPE(klass) == T_CLASS) {
|
||||
klass = RCLASS_SUPER(klass);
|
||||
sk = RCLASS_SUPER(klass);
|
||||
}
|
||||
else if (BUILTIN_TYPE(klass) == T_MODULE) {
|
||||
VALUE k = CLASS_OF(recv);
|
||||
while (k) {
|
||||
if (BUILTIN_TYPE(k) == T_ICLASS && RBASIC(k)->klass == klass) {
|
||||
klass = RCLASS_SUPER(k);
|
||||
sk = RCLASS_SUPER(k);
|
||||
break;
|
||||
}
|
||||
k = RCLASS_SUPER(k);
|
||||
}
|
||||
sk = rb_cObject;
|
||||
}
|
||||
return klass;
|
||||
|
||||
return sk;
|
||||
}
|
||||
|
||||
static void
|
||||
|
|
Loading…
Reference in a new issue