aboutsummaryrefslogtreecommitdiffstats
path: root/class.c
diff options
context:
space:
mode:
authorJeremy Evans <code@jeremyevans.net>2020-06-03 12:14:49 -0700
committerJeremy Evans <code@jeremyevans.net>2020-06-18 08:18:31 -0700
commit41582d5866ae34c57094f70f95c3d31f4a1fa4ff (patch)
tree2de16cd0f2bcdd4172f67ba4ae5f65c7541fe9e2 /class.c
parent750203c514e0e9a49f7d53fb54084e6844fca42a (diff)
downloadruby-41582d5866ae34c57094f70f95c3d31f4a1fa4ff.tar.gz
Make Module#prepend affect the iclasses of the module
3556a834a2847e52162d1d3302d4c64390df1694 added support for Module#include to affect the iclasses of the module. It didn't add support for Module#prepend because there were bugs in the object model and GC at the time that prevented it. Those problems have been addressed in ad729a1d11c6c57efd2e92803b4e937db0f75252 and 98286e9850936e27e8ae5e4f20858cc9c13d2dde, and now adding support for it is straightforward and does not break any tests or specs. Fixes [Bug #9573]
Diffstat (limited to 'class.c')
-rw-r--r--class.c7
1 files changed, 7 insertions, 0 deletions
diff --git a/class.c b/class.c
index 4dbf5a2f35..7719b06208 100644
--- a/class.c
+++ b/class.c
@@ -1141,6 +1141,13 @@ rb_prepend_module(VALUE klass, VALUE module)
if (changed) {
rb_vm_check_redefinition_by_prepend(klass);
}
+ if (RB_TYPE_P(klass, T_MODULE)) {
+ rb_subclass_entry_t *iclass = RCLASS_EXT(klass)->subclasses;
+ while (iclass) {
+ include_modules_at(iclass->klass, iclass->klass, module, FALSE);
+ iclass = iclass->next;
+ }
+ }
}
/*