summaryrefslogtreecommitdiff
path: root/eval.c
diff options
context:
space:
mode:
Diffstat (limited to 'eval.c')
-rw-r--r--eval.c11
1 files changed, 7 insertions, 4 deletions
diff --git a/eval.c b/eval.c
index 615df9c..3e9548d 100644
--- a/eval.c
+++ b/eval.c
@@ -230,6 +230,10 @@ rb_clear_cache_by_class(klass)
}
}
+static ID init, alloc, eqq, each, aref, aset, match, missing;
+static ID added, singleton_added;
+static ID __id__, __send__;
+
void
rb_add_method(klass, mid, node, noex)
VALUE klass;
@@ -243,6 +247,9 @@ rb_add_method(klass, mid, node, noex)
if (ruby_safe_level >= 4 && (klass == rb_cObject || !OBJ_TAINTED(klass))) {
rb_raise(rb_eSecurityError, "Insecure: can't define method");
}
+ if (mid == init) {
+ noex = NOEX_PRIVATE | (noex & NOEX_NOSUPER);
+ }
if (OBJ_FROZEN(klass)) rb_error_frozen("class/module");
rb_clear_cache_by_id(mid);
body = NEW_METHOD(node, noex);
@@ -313,10 +320,6 @@ rb_get_method_body(klassp, idp, noexp)
return body;
}
-static ID init, alloc, eqq, each, aref, aset, match, missing;
-static ID added, singleton_added;
-static ID __id__, __send__;
-
static void
remove_method(klass, mid)
VALUE klass;