vm_method.c: check if frozen [Fix GH-1096]
* vm_method.c (set_method_visibility): should fail if the receiver is frozen. [ruby-core:71489] [Bug #11687] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@52579 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
parent
9fec02ad20
commit
4ea616b387
@ -1,3 +1,8 @@
|
|||||||
|
Sun Nov 15 18:28:43 2015 Kenichi Kamiya <kachick1@gmail.com>
|
||||||
|
|
||||||
|
* vm_method.c (set_method_visibility): should fail if the receiver
|
||||||
|
is frozen. [ruby-core:71489] [Bug #11687]
|
||||||
|
|
||||||
Sat Nov 14 22:15:07 2015 Tanaka Akira <akr@fsij.org>
|
Sat Nov 14 22:15:07 2015 Tanaka Akira <akr@fsij.org>
|
||||||
|
|
||||||
* ext/socket/lib/socket.rb: Specify frozen_string_literal: true.
|
* ext/socket/lib/socket.rb: Specify frozen_string_literal: true.
|
||||||
|
@ -624,13 +624,22 @@ class TestModule < Test::Unit::TestCase
|
|||||||
end
|
end
|
||||||
|
|
||||||
def test_freeze
|
def test_freeze
|
||||||
m = Module.new
|
m = Module.new do
|
||||||
|
def self.baz; end
|
||||||
|
def bar; end
|
||||||
|
end
|
||||||
m.freeze
|
m.freeze
|
||||||
assert_raise(RuntimeError) do
|
assert_raise(RuntimeError) do
|
||||||
m.module_eval do
|
m.module_eval do
|
||||||
def foo; end
|
def foo; end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
assert_raise(RuntimeError) do
|
||||||
|
m.__send__ :private, :bar
|
||||||
|
end
|
||||||
|
assert_raise(RuntimeError) do
|
||||||
|
m.private_class_method :baz
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
def test_attr_obsoleted_flag
|
def test_attr_obsoleted_flag
|
||||||
|
@ -1552,6 +1552,7 @@ set_method_visibility(VALUE self, int argc, const VALUE *argv, rb_method_visibil
|
|||||||
{
|
{
|
||||||
int i;
|
int i;
|
||||||
|
|
||||||
|
rb_check_frozen(self);
|
||||||
if (argc == 0) {
|
if (argc == 0) {
|
||||||
rb_warning("%"PRIsVALUE" with no argument is just ignored",
|
rb_warning("%"PRIsVALUE" with no argument is just ignored",
|
||||||
QUOTE_ID(rb_frame_callee()));
|
QUOTE_ID(rb_frame_callee()));
|
||||||
|
Loading…
x
Reference in New Issue
Block a user