mirror of
https://github.com/ruby/ruby.git
synced 2022-11-09 12:17:21 -05:00
Make the dot-colon method reference frozen
[Feature #16103] Close: https://github.com/ruby/ruby/pull/2267
This commit is contained in:
parent
998ee350b9
commit
c45dd4d482
2 changed files with 14 additions and 1 deletions
|
@ -699,7 +699,7 @@ checktype
|
|||
ret = (TYPE(val) == (int)type) ? Qtrue : Qfalse;
|
||||
}
|
||||
|
||||
/* get method reference. */
|
||||
/* get frozen method reference. */
|
||||
DEFINE_INSN
|
||||
methodref
|
||||
(ID id)
|
||||
|
|
|
@ -1141,6 +1141,19 @@ class TestMethod < Test::Unit::TestCase
|
|||
assert_nil(o.method(:foo))
|
||||
end
|
||||
|
||||
def test_method_reference_freeze_state
|
||||
m = 1.:succ
|
||||
assert_predicate(m, :frozen?, "dot-symbol method reference should be frozen")
|
||||
m = 1.method(:succ)
|
||||
assert_not_predicate(m, :frozen?, "#method method reference should not be frozen")
|
||||
o = Object.new
|
||||
def o.foo; 42; end
|
||||
m = o.:foo
|
||||
assert_predicate(m, :frozen?, "dot-symbol method reference should be frozen")
|
||||
m = o.method(:foo)
|
||||
assert_not_predicate(m, :frozen?, "#method method reference should not be frozen")
|
||||
end
|
||||
|
||||
def test_umethod_bind_call
|
||||
foo = Base.instance_method(:foo)
|
||||
assert_equal(:base, foo.bind_call(Base.new))
|
||||
|
|
Loading…
Reference in a new issue