diff options
author | shugo <shugo@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2012-09-27 09:53:24 +0000 |
---|---|---|
committer | shugo <shugo@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2012-09-27 09:53:24 +0000 |
commit | 8940e3721010e8867242ecf72d23a647304581a1 (patch) | |
tree | 619e121d08b7d2a5a9151dd2cd5e72449eeed879 /vm_method.c | |
parent | e0bff65092ddd92058994feb33e69195fb216488 (diff) | |
download | ruby-8940e3721010e8867242ecf72d23a647304581a1.tar.gz |
* eval.c (rb_overlay_module, rb_mod_refine): accept a module as the
argument of Module#refine.
* vm_method.c (search_method): if klass is an iclass, lookup the
original module of the iclass in omod in order to allow
refinements of modules.
* test/ruby/test_refinement.rb: add tests for the above changes.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@37040 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'vm_method.c')
-rw-r--r-- | vm_method.c | 18 |
1 files changed, 14 insertions, 4 deletions
diff --git a/vm_method.c b/vm_method.c index 43b9ddb107..bf605e6f67 100644 --- a/vm_method.c +++ b/vm_method.c @@ -385,10 +385,20 @@ search_method(VALUE klass, ID id, VALUE omod, VALUE *defined_class_ptr) for (body = 0; klass; klass = RCLASS_SUPER(klass)) { st_table *m_tbl; - if (!NIL_P(omod) && klass != skipped_class && - !NIL_P(iclass = rb_hash_lookup(omod, klass))) { - skipped_class = klass; - klass = iclass; + if (!NIL_P(omod) && klass != skipped_class) { + VALUE c; + + if (BUILTIN_TYPE(klass) == T_ICLASS) { + c = RBASIC(klass)->klass; + } + else { + c = klass; + } + iclass = rb_hash_lookup(omod, c); + if (!NIL_P(iclass)) { + skipped_class = klass; + klass = iclass; + } } m_tbl = RCLASS_M_TBL(klass); if (!m_tbl) { |