diff --git a/lib/typeprof/core/env.rb b/lib/typeprof/core/env.rb index 6ef3510b1..cbf4fe783 100644 --- a/lib/typeprof/core/env.rb +++ b/lib/typeprof/core/env.rb @@ -281,6 +281,9 @@ class Array[Elem] class Hash[K, V] include _Each[[K, V]] end + class Object + include Hash::_Key + end RBS # Loading frequently used modules first will reduces constant resolution diff --git a/scenario/hash/key_check.rb b/scenario/hash/key_check.rb new file mode 100644 index 000000000..802eb31fa --- /dev/null +++ b/scenario/hash/key_check.rb @@ -0,0 +1,16 @@ +## update +def test + h = { a: 1, b: 2 } + h.key?(:a) + h.key?("not a symbol") + h.key?(Object.new) +end + +test + +## assert +class Object + def test: -> bool +end + +## diagnostics