ruby-changes:57368
From: Nobuyoshi <ko1@a...>
Date: Thu, 29 Aug 2019 17:05:23 +0900 (JST)
Subject: [ruby-changes:57368] Nobuyoshi Nakada: abe12d8b96 (master): Freeze method reference operator object
https://git.ruby-lang.org/ruby.git/commit/?id=abe12d8b96 From abe12d8b96be3c12618811f22ca01788366f99f8 Mon Sep 17 00:00:00 2001 From: Nobuyoshi Nakada <nobu@r...> Date: Thu, 29 Aug 2019 16:58:21 +0900 Subject: Freeze method reference operator object [Feature #16103] diff --git a/insns.def b/insns.def index 0233014..3b82d4e 100644 --- a/insns.def +++ b/insns.def @@ -707,6 +707,7 @@ methodref https://github.com/ruby/ruby/blob/trunk/insns.def#L707 (VALUE ret) { ret = rb_obj_method(val, ID2SYM(id)); + RB_OBJ_FREEZE_RAW(ret); } /**********************************************************/ diff --git a/test/ruby/test_method.rb b/test/ruby/test_method.rb index ba425a4..acaf43e 100644 --- a/test/ruby/test_method.rb +++ b/test/ruby/test_method.rb @@ -1120,16 +1120,20 @@ class TestMethod < Test::Unit::TestCase https://github.com/ruby/ruby/blob/trunk/test/ruby/test_method.rb#L1120 def test_method_reference_operator m = 1.:succ + assert_predicate(m, :frozen?) assert_equal(1.method(:succ), m) assert_equal(2, m.()) m = 1.:+ + assert_predicate(m, :frozen?) assert_equal(1.method(:+), m) assert_equal(42, m.(41)) m = 1.:-@ + assert_predicate(m, :frozen?) assert_equal(1.method(:-@), m) assert_equal(-1, m.()) o = Object.new def o.foo; 42; end + assert_predicate(o.:foo, :frozen?) m = o.method(:foo) assert_equal(m, o.:foo) def o.method(m); nil; end -- cgit v0.10.2 -- ML: ruby-changes@q... Info: http://www.atdot.net/~ko1/quickml/