Skip to content
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
3 changes: 2 additions & 1 deletion core/symbol.rbs
Original file line number Diff line number Diff line change
Expand Up @@ -175,7 +175,8 @@ class Symbol
# Equivalent to `symbol.to_s =~ object`, including possible updates to global
# variables; see String#=~.
#
def =~: (untyped obj) -> Integer?
def =~: (Regexp regex) -> Integer?
| [T] (String::_MatchAgainst[self, T] object) -> T

# <!--
# rdoc-file=string.c
Expand Down
7 changes: 7 additions & 0 deletions test/stdlib/Symbol_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,13 @@ def test_match_op
:a, :=~, /a/
assert_send_type "(nil) -> nil",
:a, :=~, nil

matcher = BlankSlate.new
def matcher.=~(rhs)
:world
end
assert_send_type '(String::_MatchAgainst[String, Symbol]) -> Symbol',
:hello, :=~, matcher
end

def test_aref
Expand Down