mirror of
https://github.com/ruby/ruby.git
synced 2022-11-09 12:17:21 -05:00
defined: me in cfp
* insns.def (defined): use method entry and id in cfp for proper superclass, since klass in iseq is shared by dynamically defined methods from the same block. [ruby-core:45831][Bug #6644] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@36369 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
parent
2642b69096
commit
35784d1019
3 changed files with 28 additions and 11 deletions
|
@ -1,3 +1,9 @@
|
||||||
|
Thu Jul 12 05:11:41 2012 Nobuyoshi Nakada <nobu@ruby-lang.org>
|
||||||
|
|
||||||
|
* insns.def (defined): use method entry and id in cfp for proper
|
||||||
|
superclass, since klass in iseq is shared by dynamically defined
|
||||||
|
methods from the same block. [ruby-core:45831][Bug #6644]
|
||||||
|
|
||||||
Thu Jul 12 01:49:07 2012 NARUSE, Yui <naruse@ruby-lang.org>
|
Thu Jul 12 01:49:07 2012 NARUSE, Yui <naruse@ruby-lang.org>
|
||||||
|
|
||||||
* lib/net/http.rb (Net::HTTP#connect): use local_host and local_port
|
* lib/net/http.rb (Net::HTTP#connect): use local_host and local_port
|
||||||
|
@ -10,7 +16,7 @@ Wed Jul 11 17:36:39 2012 Nobuyoshi Nakada <nobu@ruby-lang.org>
|
||||||
|
|
||||||
Wed Jul 11 12:38:20 2012 NAKAMURA Usaku <usa@ruby-lang.org>
|
Wed Jul 11 12:38:20 2012 NAKAMURA Usaku <usa@ruby-lang.org>
|
||||||
|
|
||||||
* ext/openssl/ossl_pkey_ec.c (ossl_ec_point_mul): nonstatic initializer
|
* ext/openssl/ossl_pkey_ec.c (ossl_ec_point_mul): nonstatic initializer
|
||||||
of an aggregate type is a C99ism.
|
of an aggregate type is a C99ism.
|
||||||
|
|
||||||
* ext/openssl/ossl_pkey_ec.c (ossl_ec_point_mul): get rid of VC++
|
* ext/openssl/ossl_pkey_ec.c (ossl_ec_point_mul): get rid of VC++
|
||||||
|
|
15
insns.def
15
insns.def
|
@ -826,16 +826,11 @@ defined
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case DEFINED_ZSUPER:{
|
case DEFINED_ZSUPER:{
|
||||||
rb_iseq_t *iseq = GET_ISEQ();
|
const rb_method_entry_t *me = GET_CFP()->me;
|
||||||
while (iseq) {
|
if (me) {
|
||||||
if (iseq->defined_method_id) {
|
VALUE klass = vm_search_normal_superclass(me->klass, GET_SELF());
|
||||||
break;
|
ID id = me->def ? me->def->original_id : me->called_id;
|
||||||
}
|
if (rb_method_boundp(klass, id, 0)) {
|
||||||
iseq = iseq->parent_iseq;
|
|
||||||
}
|
|
||||||
if (iseq) {
|
|
||||||
VALUE klass = vm_search_normal_superclass(iseq->klass, GET_SELF());
|
|
||||||
if (rb_method_boundp(klass, iseq->defined_method_id, 0)) {
|
|
||||||
expr_type = "super";
|
expr_type = "super";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -136,4 +136,20 @@ class TestDefined < Test::Unit::TestCase
|
||||||
bug5786 = '[ruby-dev:45021]'
|
bug5786 = '[ruby-dev:45021]'
|
||||||
assert_nil(defined?(raise("[Bug#5786]")::A), bug5786)
|
assert_nil(defined?(raise("[Bug#5786]")::A), bug5786)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def test_define_method
|
||||||
|
bug6644 = '[ruby-core:45831]'
|
||||||
|
a = Class.new do
|
||||||
|
def self.def_f!;
|
||||||
|
singleton_class.send(:define_method, :f) { defined? super }
|
||||||
|
end
|
||||||
|
end
|
||||||
|
aa = Class.new(a)
|
||||||
|
a.def_f!
|
||||||
|
assert_nil(a.f)
|
||||||
|
assert_nil(aa.f)
|
||||||
|
aa.def_f!
|
||||||
|
assert_equal("super", aa.f, bug6644)
|
||||||
|
assert_nil(a.f, bug6644)
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
Loading…
Reference in a new issue