summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorNobuyoshi Nakada <nobu@ruby-lang.org>2020-07-26 13:20:19 +0900
committerNobuyoshi Nakada <nobu@ruby-lang.org>2021-09-17 11:14:08 +0900
commitfd918d1afa89405c194e90476373f936b3577df0 (patch)
tree07838c9b7ac04483ed314541f0581c8b8f68a5b3
parent178ee1e801acb33d13b3e8a630f6ca4926c68fbc (diff)
Removed Module.allocate [Bug #17048]
Notes
Notes: Merged: https://github.com/ruby/ruby/pull/4858
-rw-r--r--object.c2
-rw-r--r--spec/ruby/core/module/allocate_spec.rb14
-rw-r--r--test/ruby/test_module.rb12
3 files changed, 2 insertions, 26 deletions
diff --git a/object.c b/object.c
index 5263618697..56095e9af6 100644
--- a/object.c
+++ b/object.c
@@ -4612,6 +4612,7 @@ InitVM_Object(void)
rb_define_method(rb_cModule, "attr_accessor", rb_mod_attr_accessor, -1);
rb_define_alloc_func(rb_cModule, rb_module_s_alloc);
+ rb_undef_method(rb_singleton_class(rb_cModule), "allocate");
rb_define_method(rb_cModule, "initialize", rb_mod_initialize, 0);
rb_define_method(rb_cModule, "initialize_clone", rb_mod_initialize_clone, -1);
rb_define_method(rb_cModule, "instance_methods", rb_class_instance_methods, -1); /* in class.c */
@@ -4643,6 +4644,7 @@ InitVM_Object(void)
rb_define_method(rb_cModule, "deprecate_constant", rb_mod_deprecate_constant, -1); /* in variable.c */
rb_define_method(rb_cModule, "singleton_class?", rb_mod_singleton_p, 0);
+ rb_define_method(rb_singleton_class(rb_cClass), "allocate", rb_class_alloc_m, 0);
rb_define_method(rb_cClass, "allocate", rb_class_alloc_m, 0);
rb_define_method(rb_cClass, "new", rb_class_new_instance_pass_kw, -1);
rb_define_method(rb_cClass, "initialize", rb_class_initialize, -1);
diff --git a/spec/ruby/core/module/allocate_spec.rb b/spec/ruby/core/module/allocate_spec.rb
deleted file mode 100644
index 3b2c4119c3..0000000000
--- a/spec/ruby/core/module/allocate_spec.rb
+++ /dev/null
@@ -1,14 +0,0 @@
-require_relative '../../spec_helper'
-
-describe "Module.allocate" do
- it "returns an instance of Module" do
- mod = Module.allocate
- mod.should be_an_instance_of(Module)
- end
-
- it "returns a fully-formed instance of Module" do
- mod = Module.allocate
- mod.constants.should_not == nil
- mod.methods.should_not == nil
- end
-end
diff --git a/test/ruby/test_module.rb b/test/ruby/test_module.rb
index bbe84cd9ff..b36b8b7810 100644
--- a/test/ruby/test_module.rb
+++ b/test/ruby/test_module.rb
@@ -3094,18 +3094,6 @@ class TestModule < Test::Unit::TestCase
assert_match(/::Foo$/, mod.name, '[Bug #14895]')
end
- def test_include_allocated
- assert_raise(ArgumentError) do
- Module.new {include Module.allocate}
- end
- assert_raise(ArgumentError) do
- Module.new {prepend Module.allocate}
- end
- assert_raise(ArgumentError) do
- Object.new.extend Module.allocate
- end
- end
-
private
def assert_top_method_is_private(method)