From 6753328d7f95f84aa9d7292456187a2fb183b527 Mon Sep 17 00:00:00 2001
From: Eloy Duran <eloy.de.enige@gmail.com>
Date: Tue, 19 Jan 2010 19:32:05 +0100
Subject: [PATCH] When including a module into class Class or class Module, copy the methods to the metaclass of NSObject.
---
class.c | 6 ++++++
eval.c | 2 +-
2 files changed, 7 insertions(+), 1 deletions(-)
diff --git a/class.c b/class.c
index 91846b6..c3c5c5a 100644
|
a
|
b
|
|
| 628 | 628 | // to the original class too. |
| 629 | 629 | rb_vm_copy_methods((Class)module, (Class)klass); |
| 630 | 630 | |
| | 631 | // When including into the class Class, also copy the methods to the |
| | 632 | // singleton class of NSObject. |
| | 633 | if (klass == rb_cClass || klass == rb_cModule) { |
| | 634 | rb_vm_copy_methods((Class)module, *(Class *)rb_cNSObject); |
| | 635 | } |
| | 636 | |
| 631 | 637 | if (orig_klass != 0 && orig_klass != klass) { |
| 632 | 638 | Method m = class_getInstanceMethod((Class)orig_klass, selInitialize); |
| 633 | 639 | Method m2 = class_getInstanceMethod((Class)klass, selInitialize); |
diff --git a/eval.c b/eval.c
index a72fb2e..106fe31 100644
|
a
|
b
|
|
| 520 | 520 | Check_Type(include, T_CLASS); |
| 521 | 521 | break; |
| 522 | 522 | } |
| 523 | | if (RCLASS_RUBY(include)) { |
| | 523 | if (include != rb_cClass && include != rb_cModule && RCLASS_RUBY(include)) { |
| 524 | 524 | VALUE sinclude = rb_make_singleton_class(RCLASS_SUPER(include)); |
| 525 | 525 | RCLASS_SET_SUPER(include, sinclude); |
| 526 | 526 | include = sinclude; |