Skip to content

Commit 8f9b393

Browse files
committed
[Enumerable] Update include? to accept untyped
1 parent 7ca19b7 commit 8f9b393

File tree

2 files changed

+13
-2
lines changed

2 files changed

+13
-2
lines changed

core/enumerable.rbs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -725,7 +725,7 @@ module Enumerable[unchecked out Elem] : _Each[Elem]
725725
# {foo: 0, bar: 1, baz: 2}.include?('foo') # => false
726726
# {foo: 0, bar: 1, baz: 2}.include?(0) # => false
727727
#
728-
def include?: (Elem arg0) -> bool
728+
def include?: (untyped object) -> bool
729729

730730
# <!--
731731
# rdoc-file=enum.c
@@ -1571,7 +1571,7 @@ module Enumerable[unchecked out Elem] : _Each[Elem]
15711571
# {foo: 0, bar: 1, baz: 2}.include?('foo') # => false
15721572
# {foo: 0, bar: 1, baz: 2}.include?(0) # => false
15731573
#
1574-
def member?: (Elem arg0) -> bool
1574+
alias member? include?
15751575

15761576
# <!-- rdoc-file=enum.c -->
15771577
# Returns the result of applying a reducer to an initial value and the first

test/stdlib/Enumerable_test.rb

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -265,4 +265,15 @@ def test_one_p
265265
assert_send_type '(Class) -> bool', TestEnumerable.new, :one?, String
266266
assert_send_type '() { (String) -> bool } -> bool', TestEnumerable.new, :one? do |x| x == '0' end
267267
end
268+
269+
def test_include?(method: :include?)
270+
with_untyped.and '1' do |element|
271+
assert_send_type '(untyped) -> bool',
272+
TestEnumerable.new, method, element
273+
end
274+
end
275+
276+
def test_member?
277+
test_include?(method: :member?)
278+
end
268279
end

0 commit comments

Comments
 (0)