Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Make the dot-colon method reference frozen #2267

Merged
merged 7 commits into from
Aug 30, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion insns.def
Original file line number Diff line number Diff line change
Expand Up @@ -699,7 +699,7 @@ checktype
ret = (TYPE(val) == (int)type) ? Qtrue : Qfalse;
}

/* get method reference. */
/* get frozen method reference. */
DEFINE_INSN
methodref
(ID id)
Expand Down
13 changes: 13 additions & 0 deletions test/ruby/test_method.rb
Original file line number Diff line number Diff line change
Expand Up @@ -1141,6 +1141,19 @@ def o.method(m); nil; end
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))
Expand Down