Actions
Feature #20317
openRemoving the `allocate` method should cause `new` to fail
Feature #20317:
Removing the `allocate` method should cause `new` to fail
Status:
Open
Assignee:
-
Target version:
-
Description
When you remove the allocate
method from a class the you can't allocate the class via the allocate
method. However, you can allocate the class via the new
method:
class Foo; end
Foo.singleton_class.undef_method(:allocate)
begin
Foo.allocate # doesn't work, of course
rescue NoMethodError
end
begin
Class.instance_method(:allocate).bind_call(Foo) # also doesn't work
rescue TypeError
end
Foo.new # works?
I think that when we remove the allocate
method, the new
method should also fail as there is no allocate
method for new
to call.
Actions