rbs 2.8.4 → 3.8.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (434) hide show
  1. checksums.yaml +4 -4
  2. data/.github/dependabot.yml +12 -4
  3. data/.github/workflows/comments.yml +11 -11
  4. data/.github/workflows/dependabot.yml +30 -0
  5. data/.github/workflows/ruby.yml +40 -49
  6. data/.github/workflows/typecheck.yml +36 -0
  7. data/.github/workflows/windows.yml +28 -0
  8. data/.gitignore +1 -0
  9. data/.rubocop.yml +42 -2
  10. data/CHANGELOG.md +845 -1
  11. data/README.md +64 -4
  12. data/Rakefile +198 -18
  13. data/Steepfile +11 -11
  14. data/config.yml +311 -0
  15. data/core/array.rbs +2189 -1914
  16. data/core/basic_object.rbs +59 -84
  17. data/core/binding.rbs +7 -69
  18. data/core/builtin.rbs +210 -11
  19. data/core/class.rbs +37 -0
  20. data/core/comparable.rbs +23 -25
  21. data/core/complex.rbs +449 -227
  22. data/core/constants.rbs +29 -21
  23. data/core/data.rbs +415 -0
  24. data/core/dir.rbs +698 -415
  25. data/core/encoding.rbs +468 -843
  26. data/core/enumerable.rbs +495 -455
  27. data/core/enumerator/product.rbs +92 -0
  28. data/core/enumerator.rbs +106 -9
  29. data/core/env.rbs +1 -1
  30. data/core/errno.rbs +506 -605
  31. data/core/errors.rbs +15 -17
  32. data/core/exception.rbs +361 -145
  33. data/core/false_class.rbs +39 -26
  34. data/core/fiber.rbs +121 -14
  35. data/core/file.rbs +1262 -320
  36. data/core/file_test.rbs +62 -45
  37. data/core/float.rbs +187 -208
  38. data/core/gc.rbs +446 -196
  39. data/core/global_variables.rbs +29 -29
  40. data/core/hash.rbs +242 -349
  41. data/core/integer.rbs +246 -308
  42. data/core/io/buffer.rbs +373 -122
  43. data/core/io/wait.rbs +29 -17
  44. data/core/io.rbs +1881 -1518
  45. data/core/kernel.rbs +2116 -1538
  46. data/core/marshal.rbs +24 -14
  47. data/core/match_data.rbs +413 -166
  48. data/core/math.rbs +531 -291
  49. data/core/method.rbs +101 -32
  50. data/core/module.rbs +228 -64
  51. data/core/nil_class.rbs +106 -47
  52. data/core/numeric.rbs +206 -292
  53. data/core/object.rbs +73 -1168
  54. data/core/object_space/weak_key_map.rbs +166 -0
  55. data/core/object_space.rbs +5 -3
  56. data/core/proc.rbs +280 -39
  57. data/core/process.rbs +1318 -658
  58. data/core/ractor.rbs +200 -134
  59. data/core/random.rbs +21 -4
  60. data/core/range.rbs +309 -153
  61. data/core/rational.rbs +4 -12
  62. data/core/rb_config.rbs +64 -43
  63. data/core/rbs/unnamed/argf.rbs +411 -147
  64. data/core/rbs/unnamed/env_class.rbs +137 -253
  65. data/core/rbs/unnamed/random.rbs +49 -26
  66. data/core/refinement.rbs +16 -1
  67. data/core/regexp.rbs +1568 -862
  68. data/core/ruby_vm.rbs +719 -7
  69. data/core/rubygems/config_file.rbs +3 -0
  70. data/core/rubygems/errors.rbs +69 -6
  71. data/core/rubygems/rubygems.rbs +71 -17
  72. data/core/rubygems/version.rbs +11 -7
  73. data/{stdlib/set/0 → core}/set.rbs +80 -91
  74. data/core/signal.rbs +14 -8
  75. data/core/string.rbs +1732 -1607
  76. data/core/struct.rbs +467 -95
  77. data/core/symbol.rbs +215 -245
  78. data/core/thread.rbs +133 -89
  79. data/core/thread_group.rbs +9 -9
  80. data/core/time.rbs +1141 -841
  81. data/core/trace_point.rbs +181 -121
  82. data/core/true_class.rbs +58 -32
  83. data/core/unbound_method.rbs +103 -30
  84. data/core/warning.rbs +50 -5
  85. data/docs/CONTRIBUTING.md +1 -1
  86. data/docs/architecture.md +110 -0
  87. data/docs/collection.md +59 -5
  88. data/docs/data_and_struct.md +86 -0
  89. data/docs/gem.md +57 -0
  90. data/docs/rbs_by_example.md +16 -35
  91. data/docs/repo.md +1 -1
  92. data/docs/sigs.md +7 -7
  93. data/docs/stdlib.md +63 -5
  94. data/docs/syntax.md +255 -61
  95. data/docs/tools.md +1 -0
  96. data/ext/rbs_extension/extconf.rb +10 -0
  97. data/ext/rbs_extension/lexer.c +1741 -1548
  98. data/ext/rbs_extension/lexer.h +11 -1
  99. data/ext/rbs_extension/lexer.re +12 -6
  100. data/ext/rbs_extension/lexstate.c +26 -3
  101. data/ext/rbs_extension/location.c +119 -111
  102. data/ext/rbs_extension/location.h +32 -7
  103. data/ext/rbs_extension/main.c +3 -0
  104. data/ext/rbs_extension/parser.c +883 -481
  105. data/ext/rbs_extension/parserstate.c +65 -25
  106. data/ext/rbs_extension/parserstate.h +13 -3
  107. data/ext/rbs_extension/rbs_extension.h +1 -10
  108. data/ext/rbs_extension/unescape.c +7 -47
  109. data/goodcheck.yml +2 -2
  110. data/{ext/rbs_extension → include/rbs}/constants.h +26 -15
  111. data/include/rbs/ruby_objs.h +72 -0
  112. data/include/rbs.h +7 -0
  113. data/lib/rbs/annotate/annotations.rb +3 -3
  114. data/lib/rbs/annotate/formatter.rb +13 -3
  115. data/lib/rbs/annotate/rdoc_annotator.rb +1 -1
  116. data/lib/rbs/annotate/rdoc_source.rb +12 -3
  117. data/lib/rbs/ast/declarations.rb +85 -2
  118. data/lib/rbs/ast/directives.rb +39 -0
  119. data/lib/rbs/ast/members.rb +49 -15
  120. data/lib/rbs/ast/type_param.rb +104 -15
  121. data/lib/rbs/ast/visitor.rb +137 -0
  122. data/lib/rbs/buffer.rb +5 -0
  123. data/lib/rbs/cli/colored_io.rb +48 -0
  124. data/lib/rbs/cli/diff.rb +83 -0
  125. data/lib/rbs/cli/validate.rb +356 -0
  126. data/lib/rbs/cli.rb +253 -143
  127. data/lib/rbs/collection/cleaner.rb +8 -1
  128. data/lib/rbs/collection/config/lockfile.rb +92 -0
  129. data/lib/rbs/collection/config/lockfile_generator.rb +154 -65
  130. data/lib/rbs/collection/config.rb +19 -46
  131. data/lib/rbs/collection/installer.rb +12 -13
  132. data/lib/rbs/collection/sources/base.rb +2 -2
  133. data/lib/rbs/collection/sources/git.rb +146 -69
  134. data/lib/rbs/collection/sources/local.rb +81 -0
  135. data/lib/rbs/collection/sources/rubygems.rb +10 -12
  136. data/lib/rbs/collection/sources/stdlib.rb +14 -13
  137. data/lib/rbs/collection/sources.rb +15 -2
  138. data/lib/rbs/collection.rb +2 -1
  139. data/lib/rbs/definition.rb +13 -16
  140. data/lib/rbs/definition_builder/ancestor_builder.rb +100 -24
  141. data/lib/rbs/definition_builder/method_builder.rb +4 -4
  142. data/lib/rbs/definition_builder.rb +489 -584
  143. data/lib/rbs/diff.rb +125 -0
  144. data/lib/rbs/environment/use_map.rb +77 -0
  145. data/lib/rbs/environment.rb +406 -105
  146. data/lib/rbs/environment_loader.rb +48 -44
  147. data/lib/rbs/environment_walker.rb +1 -1
  148. data/lib/rbs/errors.rb +175 -56
  149. data/lib/rbs/file_finder.rb +28 -0
  150. data/lib/rbs/location_aux.rb +8 -7
  151. data/lib/rbs/locator.rb +37 -15
  152. data/lib/rbs/method_type.rb +23 -0
  153. data/lib/rbs/namespace.rb +1 -0
  154. data/lib/rbs/parser/lex_result.rb +15 -0
  155. data/lib/rbs/parser/token.rb +23 -0
  156. data/lib/rbs/parser_aux.rb +22 -13
  157. data/lib/rbs/prototype/helpers.rb +48 -22
  158. data/lib/rbs/prototype/node_usage.rb +99 -0
  159. data/lib/rbs/prototype/rb.rb +125 -31
  160. data/lib/rbs/prototype/rbi.rb +49 -36
  161. data/lib/rbs/prototype/runtime/helpers.rb +59 -0
  162. data/lib/rbs/prototype/runtime/reflection.rb +19 -0
  163. data/lib/rbs/prototype/runtime/value_object_generator.rb +279 -0
  164. data/lib/rbs/prototype/runtime.rb +273 -159
  165. data/lib/rbs/resolver/constant_resolver.rb +24 -8
  166. data/lib/rbs/resolver/type_name_resolver.rb +41 -7
  167. data/lib/rbs/sorter.rb +153 -123
  168. data/lib/rbs/substitution.rb +19 -0
  169. data/lib/rbs/subtractor.rb +201 -0
  170. data/lib/rbs/test/errors.rb +24 -11
  171. data/lib/rbs/test/guaranteed.rb +30 -0
  172. data/lib/rbs/test/hook.rb +45 -40
  173. data/lib/rbs/test/setup.rb +1 -1
  174. data/lib/rbs/test/tester.rb +1 -1
  175. data/lib/rbs/test/type_check.rb +120 -23
  176. data/lib/rbs/test.rb +6 -3
  177. data/lib/rbs/type_alias_dependency.rb +13 -3
  178. data/lib/rbs/type_alias_regularity.rb +21 -14
  179. data/lib/rbs/type_name.rb +18 -13
  180. data/lib/rbs/types.rb +352 -18
  181. data/lib/rbs/unit_test/convertibles.rb +176 -0
  182. data/lib/rbs/unit_test/spy.rb +136 -0
  183. data/lib/rbs/unit_test/type_assertions.rb +341 -0
  184. data/lib/rbs/unit_test/with_aliases.rb +143 -0
  185. data/lib/rbs/unit_test.rb +6 -0
  186. data/lib/rbs/validator.rb +55 -30
  187. data/lib/rbs/variance_calculator.rb +26 -23
  188. data/lib/rbs/vendorer.rb +3 -3
  189. data/lib/rbs/version.rb +1 -1
  190. data/lib/rbs/writer.rb +69 -22
  191. data/lib/rbs.rb +7 -2
  192. data/lib/rdoc/discover.rb +1 -1
  193. data/lib/rdoc_plugin/parser.rb +5 -5
  194. data/rbs.gemspec +12 -2
  195. data/schema/decls.json +1 -1
  196. data/schema/members.json +15 -10
  197. data/sig/ancestor_builder.rbs +4 -0
  198. data/sig/ancestor_graph.rbs +22 -2
  199. data/sig/annotate/formatter.rbs +2 -2
  200. data/sig/annotate/rdoc_annotater.rbs +1 -1
  201. data/sig/cli/colored_io.rbs +15 -0
  202. data/sig/cli/diff.rbs +21 -0
  203. data/sig/cli/validate.rbs +43 -0
  204. data/sig/cli.rbs +4 -0
  205. data/sig/collection/config/lockfile.rbs +74 -0
  206. data/sig/collection/config/lockfile_generator.rbs +66 -0
  207. data/sig/collection/config.rbs +5 -48
  208. data/sig/collection/installer.rbs +1 -1
  209. data/sig/collection/sources.rbs +105 -33
  210. data/sig/constant.rbs +1 -1
  211. data/sig/declarations.rbs +42 -3
  212. data/sig/definition.rbs +26 -10
  213. data/sig/definition_builder.rbs +103 -81
  214. data/sig/diff.rbs +28 -0
  215. data/sig/directives.rbs +61 -0
  216. data/sig/environment.rbs +175 -29
  217. data/sig/environment_loader.rbs +20 -18
  218. data/sig/errors.rbs +123 -2
  219. data/sig/file_finder.rbs +28 -0
  220. data/sig/location.rbs +0 -3
  221. data/sig/locator.rbs +14 -2
  222. data/sig/manifest.yaml +0 -1
  223. data/sig/members.rbs +32 -9
  224. data/sig/method_types.rbs +10 -4
  225. data/sig/namespace.rbs +2 -3
  226. data/sig/parser.rbs +55 -16
  227. data/sig/prototype/helpers.rbs +4 -0
  228. data/sig/prototype/node_usage.rbs +20 -0
  229. data/sig/prototype/rb.rbs +10 -2
  230. data/sig/prototype/rbi.rbs +2 -0
  231. data/sig/prototype/runtime.rbs +182 -0
  232. data/sig/rbs.rbs +1 -1
  233. data/sig/rdoc/rbs.rbs +4 -0
  234. data/sig/repository.rbs +7 -5
  235. data/sig/resolver/constant_resolver.rbs +3 -4
  236. data/sig/resolver/context.rbs +1 -1
  237. data/sig/resolver/type_name_resolver.rbs +5 -1
  238. data/sig/shims/bundler.rbs +38 -0
  239. data/sig/shims/rubygems.rbs +19 -0
  240. data/sig/sorter.rbs +23 -5
  241. data/sig/substitution.rbs +6 -0
  242. data/sig/subtractor.rbs +37 -0
  243. data/sig/test/errors.rbs +52 -0
  244. data/sig/test/guranteed.rbs +9 -0
  245. data/sig/test/type_check.rbs +19 -0
  246. data/sig/test.rbs +82 -0
  247. data/sig/type_alias_dependency.rbs +31 -0
  248. data/sig/type_alias_regularity.rbs +12 -6
  249. data/sig/type_param.rbs +45 -9
  250. data/sig/typename.rbs +8 -5
  251. data/sig/types.rbs +119 -12
  252. data/sig/unit_test/convertibles.rbs +154 -0
  253. data/sig/unit_test/spy.rbs +28 -0
  254. data/sig/unit_test/type_assertions.rbs +194 -0
  255. data/sig/unit_test/with_aliases.rbs +136 -0
  256. data/sig/use_map.rbs +35 -0
  257. data/sig/validator.rbs +12 -5
  258. data/sig/variance_calculator.rbs +3 -1
  259. data/sig/vendorer.rbs +1 -1
  260. data/sig/visitor.rbs +47 -0
  261. data/sig/writer.rbs +6 -2
  262. data/src/constants.c +153 -0
  263. data/src/ruby_objs.c +793 -0
  264. data/stdlib/base64/0/base64.rbs +298 -45
  265. data/stdlib/benchmark/0/benchmark.rbs +12 -3
  266. data/stdlib/bigdecimal/0/big_decimal.rbs +62 -198
  267. data/stdlib/cgi/0/core.rbs +68 -15
  268. data/stdlib/cgi/0/manifest.yaml +1 -0
  269. data/stdlib/coverage/0/coverage.rbs +50 -11
  270. data/stdlib/csv/0/csv.rbs +90 -119
  271. data/stdlib/csv/0/manifest.yaml +1 -0
  272. data/stdlib/date/0/date.rbs +806 -735
  273. data/stdlib/date/0/date_time.rbs +70 -211
  274. data/stdlib/dbm/0/dbm.rbs +0 -2
  275. data/stdlib/delegate/0/delegator.rbs +184 -0
  276. data/stdlib/delegate/0/kernel.rbs +47 -0
  277. data/stdlib/delegate/0/simple_delegator.rbs +96 -0
  278. data/stdlib/did_you_mean/0/did_you_mean.rbs +3 -8
  279. data/stdlib/digest/0/digest.rbs +48 -35
  280. data/stdlib/erb/0/erb.rbs +15 -39
  281. data/stdlib/etc/0/etc.rbs +174 -54
  282. data/stdlib/fileutils/0/fileutils.rbs +1234 -385
  283. data/stdlib/forwardable/0/forwardable.rbs +4 -4
  284. data/stdlib/io-console/0/io-console.rbs +82 -17
  285. data/stdlib/ipaddr/0/ipaddr.rbs +11 -6
  286. data/stdlib/json/0/json.rbs +434 -151
  287. data/stdlib/kconv/0/kconv.rbs +166 -0
  288. data/stdlib/logger/0/formatter.rbs +0 -2
  289. data/stdlib/logger/0/log_device.rbs +1 -3
  290. data/stdlib/logger/0/logger.rbs +465 -328
  291. data/stdlib/minitest/0/kernel.rbs +2 -2
  292. data/stdlib/minitest/0/minitest/abstract_reporter.rbs +4 -1
  293. data/stdlib/minitest/0/minitest/assertion.rbs +1 -0
  294. data/stdlib/minitest/0/minitest/assertions.rbs +58 -13
  295. data/stdlib/minitest/0/minitest/backtrace_filter.rbs +7 -0
  296. data/stdlib/minitest/0/minitest/bench_spec.rbs +8 -8
  297. data/stdlib/minitest/0/minitest/benchmark.rbs +17 -16
  298. data/stdlib/minitest/0/minitest/compress.rbs +13 -0
  299. data/stdlib/minitest/0/minitest/error_on_warning.rbs +3 -0
  300. data/stdlib/minitest/0/minitest/mock.rbs +9 -5
  301. data/stdlib/minitest/0/minitest/parallel/executor.rbs +4 -0
  302. data/stdlib/minitest/0/minitest/parallel/test/class_methods.rbs +0 -1
  303. data/stdlib/minitest/0/minitest/pride_io.rbs +8 -0
  304. data/stdlib/minitest/0/minitest/pride_lol.rbs +2 -0
  305. data/stdlib/minitest/0/minitest/progress_reporter.rbs +1 -1
  306. data/stdlib/minitest/0/minitest/reportable.rbs +2 -0
  307. data/stdlib/minitest/0/minitest/runnable.rbs +33 -1
  308. data/stdlib/minitest/0/minitest/spec/dsl/instance_methods.rbs +1 -1
  309. data/stdlib/minitest/0/minitest/spec/dsl.rbs +10 -6
  310. data/stdlib/minitest/0/minitest/spec.rbs +1 -1
  311. data/stdlib/minitest/0/minitest/statistics_reporter.rbs +5 -0
  312. data/stdlib/minitest/0/minitest/summary_reporter.rbs +0 -7
  313. data/stdlib/minitest/0/minitest/test/lifecycle_hooks.rbs +7 -7
  314. data/stdlib/minitest/0/minitest/test.rbs +7 -14
  315. data/stdlib/minitest/0/minitest/unexpected_error.rbs +2 -0
  316. data/stdlib/minitest/0/minitest/unexpected_warning.rbs +6 -0
  317. data/stdlib/minitest/0/minitest/unit.rbs +1 -2
  318. data/stdlib/minitest/0/minitest.rbs +41 -892
  319. data/stdlib/monitor/0/monitor.rbs +91 -10
  320. data/stdlib/mutex_m/0/mutex_m.rbs +0 -2
  321. data/stdlib/net-http/0/manifest.yaml +1 -1
  322. data/stdlib/net-http/0/net-http.rbs +3858 -964
  323. data/stdlib/net-protocol/0/manifest.yaml +2 -0
  324. data/stdlib/net-protocol/0/net-protocol.rbs +56 -0
  325. data/stdlib/net-smtp/0/manifest.yaml +2 -0
  326. data/stdlib/net-smtp/0/net-smtp.rbs +55 -0
  327. data/stdlib/nkf/0/nkf.rbs +35 -5
  328. data/stdlib/objspace/0/objspace.rbs +40 -18
  329. data/stdlib/observable/0/observable.rbs +217 -0
  330. data/stdlib/open-uri/0/manifest.yaml +4 -0
  331. data/stdlib/open-uri/0/open-uri.rbs +393 -0
  332. data/stdlib/open3/0/open3.rbs +147 -0
  333. data/stdlib/openssl/0/manifest.yaml +1 -0
  334. data/stdlib/openssl/0/openssl.rbs +681 -316
  335. data/stdlib/optparse/0/optparse.rbs +100 -65
  336. data/stdlib/pathname/0/pathname.rbs +24 -15
  337. data/stdlib/pp/0/manifest.yaml +2 -0
  338. data/stdlib/pp/0/pp.rbs +300 -0
  339. data/stdlib/prettyprint/0/prettyprint.rbs +2 -6
  340. data/stdlib/pstore/0/pstore.rbs +370 -156
  341. data/stdlib/psych/0/core_ext.rbs +12 -0
  342. data/stdlib/{yaml → psych}/0/dbm.rbs +3 -3
  343. data/stdlib/psych/0/manifest.yaml +3 -0
  344. data/stdlib/psych/0/psych.rbs +402 -0
  345. data/stdlib/{yaml → psych}/0/store.rbs +2 -2
  346. data/stdlib/pty/0/pty.rbs +63 -11
  347. data/stdlib/rdoc/0/code_object.rbs +51 -0
  348. data/stdlib/rdoc/0/comment.rbs +59 -0
  349. data/stdlib/rdoc/0/context.rbs +153 -0
  350. data/stdlib/rdoc/0/markup.rbs +117 -0
  351. data/stdlib/rdoc/0/parser.rbs +56 -0
  352. data/stdlib/rdoc/0/rdoc.rbs +13 -380
  353. data/stdlib/rdoc/0/ri.rbs +17 -0
  354. data/stdlib/rdoc/0/store.rbs +48 -0
  355. data/stdlib/rdoc/0/top_level.rbs +97 -0
  356. data/stdlib/resolv/0/resolv.rbs +16 -79
  357. data/stdlib/ripper/0/ripper.rbs +1648 -0
  358. data/stdlib/securerandom/0/securerandom.rbs +7 -2
  359. data/stdlib/shellwords/0/shellwords.rbs +11 -12
  360. data/stdlib/singleton/0/singleton.rbs +0 -3
  361. data/stdlib/socket/0/addrinfo.rbs +13 -18
  362. data/stdlib/socket/0/basic_socket.rbs +5 -10
  363. data/stdlib/socket/0/ip_socket.rbs +0 -2
  364. data/stdlib/socket/0/socket.rbs +77 -46
  365. data/stdlib/socket/0/tcp_server.rbs +0 -5
  366. data/stdlib/socket/0/tcp_socket.rbs +36 -3
  367. data/stdlib/socket/0/udp_socket.rbs +4 -5
  368. data/stdlib/socket/0/unix_server.rbs +0 -5
  369. data/stdlib/socket/0/unix_socket.rbs +2 -4
  370. data/{core/string_io.rbs → stdlib/stringio/0/stringio.rbs} +188 -107
  371. data/stdlib/strscan/0/string_scanner.rbs +1269 -425
  372. data/stdlib/tempfile/0/tempfile.rbs +224 -61
  373. data/stdlib/time/0/time.rbs +48 -35
  374. data/stdlib/timeout/0/timeout.rbs +17 -8
  375. data/stdlib/tmpdir/0/tmpdir.rbs +10 -3
  376. data/stdlib/tsort/0/tsort.rbs +0 -4
  377. data/stdlib/uri/0/common.rbs +271 -144
  378. data/stdlib/uri/0/file.rbs +5 -0
  379. data/stdlib/uri/0/ftp.rbs +1 -1
  380. data/stdlib/uri/0/generic.rbs +26 -22
  381. data/stdlib/uri/0/http.rbs +4 -4
  382. data/stdlib/uri/0/ldap.rbs +1 -1
  383. data/stdlib/uri/0/mailto.rbs +84 -0
  384. data/stdlib/uri/0/rfc2396_parser.rbs +3 -0
  385. data/stdlib/yaml/0/manifest.yaml +1 -2
  386. data/stdlib/yaml/0/yaml.rbs +1 -199
  387. data/stdlib/zlib/0/buf_error.rbs +10 -0
  388. data/stdlib/zlib/0/data_error.rbs +10 -0
  389. data/stdlib/zlib/0/deflate.rbs +210 -0
  390. data/stdlib/zlib/0/error.rbs +20 -0
  391. data/stdlib/zlib/0/gzip_file/crc_error.rbs +12 -0
  392. data/stdlib/zlib/0/gzip_file/error.rbs +23 -0
  393. data/stdlib/zlib/0/gzip_file/length_error.rbs +12 -0
  394. data/stdlib/zlib/0/gzip_file/no_footer.rbs +11 -0
  395. data/stdlib/zlib/0/gzip_file.rbs +156 -0
  396. data/stdlib/zlib/0/gzip_reader.rbs +293 -0
  397. data/stdlib/zlib/0/gzip_writer.rbs +166 -0
  398. data/stdlib/zlib/0/inflate.rbs +180 -0
  399. data/stdlib/zlib/0/mem_error.rbs +10 -0
  400. data/stdlib/zlib/0/need_dict.rbs +13 -0
  401. data/stdlib/zlib/0/stream_end.rbs +11 -0
  402. data/stdlib/zlib/0/stream_error.rbs +11 -0
  403. data/stdlib/zlib/0/version_error.rbs +11 -0
  404. data/stdlib/zlib/0/zlib.rbs +1 -3
  405. data/stdlib/zlib/0/zstream.rbs +200 -0
  406. data/templates/include/rbs/constants.h.erb +20 -0
  407. data/templates/include/rbs/ruby_objs.h.erb +10 -0
  408. data/templates/src/constants.c.erb +36 -0
  409. data/templates/src/ruby_objs.c.erb +27 -0
  410. data/templates/template.rb +122 -0
  411. metadata +136 -36
  412. data/Gemfile +0 -33
  413. data/Gemfile.lock +0 -118
  414. data/core/deprecated.rbs +0 -9
  415. data/ext/rbs_extension/constants.c +0 -135
  416. data/ext/rbs_extension/ruby_objs.c +0 -525
  417. data/ext/rbs_extension/ruby_objs.h +0 -43
  418. data/lib/rbs/constant_table.rb +0 -167
  419. data/lib/rbs/parser_compat/lexer_error.rb +0 -6
  420. data/lib/rbs/parser_compat/located_value.rb +0 -7
  421. data/lib/rbs/parser_compat/semantics_error.rb +0 -6
  422. data/lib/rbs/parser_compat/syntax_error.rb +0 -6
  423. data/lib/rbs/test/spy.rb +0 -6
  424. data/lib/rbs/type_name_resolver.rb +0 -67
  425. data/sig/constant_table.rbs +0 -30
  426. data/sig/shims/abstract_syntax_tree.rbs +0 -25
  427. data/sig/shims/pp.rbs +0 -3
  428. data/sig/shims/ripper.rbs +0 -8
  429. data/sig/shims.rbs +0 -69
  430. data/sig/type_name_resolver.rbs +0 -26
  431. data/stdlib/minitest/0/manifest.yaml +0 -2
  432. data/stdlib/prime/0/integer-extension.rbs +0 -41
  433. data/stdlib/prime/0/manifest.yaml +0 -2
  434. data/stdlib/prime/0/prime.rbs +0 -372
data/core/hash.rbs CHANGED
@@ -1,19 +1,18 @@
1
1
  # <!-- rdoc-file=hash.c -->
2
- # A Hash maps each of its unique keys to a specific value.
2
+ # A `Hash` maps each of its unique keys to a specific value.
3
3
  #
4
- # A Hash has certain similarities to an Array, but:
4
+ # A `Hash` has certain similarities to an Array, but:
5
5
  # * An Array index is always an Integer.
6
- # * A Hash key can be (almost) any object.
6
+ # * A `Hash` key can be (almost) any object.
7
7
  #
8
+ # ### `Hash` Data Syntax
8
9
  #
9
- # ### Hash Data Syntax
10
- #
11
- # The older syntax for Hash data uses the "hash rocket," `=>`:
10
+ # The older syntax for `Hash` data uses the "hash rocket," `=>`:
12
11
  #
13
12
  # h = {:foo => 0, :bar => 1, :baz => 2}
14
13
  # h # => {:foo=>0, :bar=>1, :baz=>2}
15
14
  #
16
- # Alternatively, but only for a Hash key that's a Symbol, you can use a newer
15
+ # Alternatively, but only for a `Hash` key that's a Symbol, you can use a newer
17
16
  # JSON-style syntax, where each bareword becomes a Symbol:
18
17
  #
19
18
  # h = {foo: 0, bar: 1, baz: 2}
@@ -35,8 +34,8 @@
35
34
  # # Raises SyntaxError (syntax error, unexpected ':', expecting =>):
36
35
  # h = {0: 'zero'}
37
36
  #
38
- # Hash value can be omitted, meaning that value will be fetched from the context
39
- # by the name of the key:
37
+ # `Hash` value can be omitted, meaning that value will be fetched from the
38
+ # context by the name of the key:
40
39
  #
41
40
  # x = 0
42
41
  # y = 100
@@ -45,24 +44,24 @@
45
44
  #
46
45
  # ### Common Uses
47
46
  #
48
- # You can use a Hash to give names to objects:
47
+ # You can use a `Hash` to give names to objects:
49
48
  #
50
49
  # person = {name: 'Matz', language: 'Ruby'}
51
50
  # person # => {:name=>"Matz", :language=>"Ruby"}
52
51
  #
53
- # You can use a Hash to give names to method arguments:
52
+ # You can use a `Hash` to give names to method arguments:
54
53
  #
55
54
  # def some_method(hash)
56
55
  # p hash
57
56
  # end
58
57
  # some_method({foo: 0, bar: 1, baz: 2}) # => {:foo=>0, :bar=>1, :baz=>2}
59
58
  #
60
- # Note: when the last argument in a method call is a Hash, the curly braces may
61
- # be omitted:
59
+ # Note: when the last argument in a method call is a `Hash`, the curly braces
60
+ # may be omitted:
62
61
  #
63
62
  # some_method(foo: 0, bar: 1, baz: 2) # => {:foo=>0, :bar=>1, :baz=>2}
64
63
  #
65
- # You can use a Hash to initialize an object:
64
+ # You can use a `Hash` to initialize an object:
66
65
  #
67
66
  # class Dev
68
67
  # attr_accessor :name, :language
@@ -74,58 +73,56 @@
74
73
  # matz = Dev.new(name: 'Matz', language: 'Ruby')
75
74
  # matz # => #<Dev: @name="Matz", @language="Ruby">
76
75
  #
77
- # ### Creating a Hash
78
- #
79
- # You can create a Hash object explicitly with:
76
+ # ### Creating a `Hash`
80
77
  #
81
- # * A [hash literal](doc/syntax/literals_rdoc.html#label-Hash+Literals).
78
+ # You can create a `Hash` object explicitly with:
82
79
  #
80
+ # * A [hash literal](rdoc-ref:syntax/literals.rdoc@Hash+Literals).
83
81
  #
84
82
  # You can convert certain objects to Hashes with:
85
83
  #
86
- # * Method [Hash](Kernel.html#method-i-Hash).
87
- #
84
+ # * Method #Hash.
88
85
  #
89
- # You can create a Hash by calling method Hash.new.
86
+ # You can create a `Hash` by calling method Hash.new.
90
87
  #
91
- # Create an empty Hash:
88
+ # Create an empty `Hash`:
92
89
  #
93
90
  # h = Hash.new
94
91
  # h # => {}
95
92
  # h.class # => Hash
96
93
  #
97
- # You can create a Hash by calling method Hash.[].
94
+ # You can create a `Hash` by calling method Hash.[].
98
95
  #
99
- # Create an empty Hash:
96
+ # Create an empty `Hash`:
100
97
  #
101
98
  # h = Hash[]
102
99
  # h # => {}
103
100
  #
104
- # Create a Hash with initial entries:
101
+ # Create a `Hash` with initial entries:
105
102
  #
106
103
  # h = Hash[foo: 0, bar: 1, baz: 2]
107
104
  # h # => {:foo=>0, :bar=>1, :baz=>2}
108
105
  #
109
- # You can create a Hash by using its literal form (curly braces).
106
+ # You can create a `Hash` by using its literal form (curly braces).
110
107
  #
111
- # Create an empty Hash:
108
+ # Create an empty `Hash`:
112
109
  #
113
110
  # h = {}
114
111
  # h # => {}
115
112
  #
116
- # Create a Hash with initial entries:
113
+ # Create a `Hash` with initial entries:
117
114
  #
118
115
  # h = {foo: 0, bar: 1, baz: 2}
119
116
  # h # => {:foo=>0, :bar=>1, :baz=>2}
120
117
  #
121
- # ### Hash Value Basics
118
+ # ### `Hash` Value Basics
122
119
  #
123
- # The simplest way to retrieve a Hash value (instance method #[]):
120
+ # The simplest way to retrieve a `Hash` value (instance method #[]):
124
121
  #
125
122
  # h = {foo: 0, bar: 1, baz: 2}
126
123
  # h[:foo] # => 0
127
124
  #
128
- # The simplest way to create or update a Hash value (instance method #[]=):
125
+ # The simplest way to create or update a `Hash` value (instance method #[]=):
129
126
  #
130
127
  # h = {foo: 0, bar: 1, baz: 2}
131
128
  # h[:bat] = 3 # => 3
@@ -133,7 +130,7 @@
133
130
  # h[:foo] = 4 # => 4
134
131
  # h # => {:foo=>4, :bar=>1, :baz=>2, :bat=>3}
135
132
  #
136
- # The simplest way to delete a Hash entry (instance method #delete):
133
+ # The simplest way to delete a `Hash` entry (instance method #delete):
137
134
  #
138
135
  # h = {foo: 0, bar: 1, baz: 2}
139
136
  # h.delete(:bar) # => 1
@@ -141,15 +138,14 @@
141
138
  #
142
139
  # ### Entry Order
143
140
  #
144
- # A Hash object presents its entries in the order of their creation. This is
141
+ # A `Hash` object presents its entries in the order of their creation. This is
145
142
  # seen in:
146
143
  #
147
144
  # * Iterative methods such as `each`, `each_key`, `each_pair`, `each_value`.
148
145
  # * Other order-sensitive methods such as `shift`, `keys`, `values`.
149
146
  # * The String returned by method `inspect`.
150
147
  #
151
- #
152
- # A new Hash has its initial ordering per the given entries:
148
+ # A new `Hash` has its initial ordering per the given entries:
153
149
  #
154
150
  # h = Hash[foo: 0, bar: 1]
155
151
  # h # => {:foo=>0, :bar=>1}
@@ -170,18 +166,18 @@
170
166
  # h[:foo] = 5
171
167
  # h # => {:bar=>1, :baz=>3, :foo=>5}
172
168
  #
173
- # ### Hash Keys
169
+ # ### `Hash` Keys
174
170
  #
175
- # #### Hash Key Equivalence
171
+ # #### `Hash` Key Equivalence
176
172
  #
177
173
  # Two objects are treated as the same hash key when their `hash` value is
178
174
  # identical and the two objects are `eql?` to each other.
179
175
  #
180
- # #### Modifying an Active Hash Key
176
+ # #### Modifying an Active `Hash` Key
181
177
  #
182
- # Modifying a Hash key while it is in use damages the hash's index.
178
+ # Modifying a `Hash` key while it is in use damages the hash's index.
183
179
  #
184
- # This Hash has keys that are Arrays:
180
+ # This `Hash` has keys that are Arrays:
185
181
  #
186
182
  # a0 = [ :foo, :bar ]
187
183
  # a1 = [ :baz, :bat ]
@@ -195,7 +191,7 @@
195
191
  # a0[0] = :bam
196
192
  # a0.hash # => 1069447059
197
193
  #
198
- # And damages the Hash index:
194
+ # And damages the `Hash` index:
199
195
  #
200
196
  # h.include?(a0) # => false
201
197
  # h[a0] # => nil
@@ -215,10 +211,10 @@
215
211
  # first_key = h.keys.first
216
212
  # first_key.frozen? # => true
217
213
  #
218
- # #### User-Defined Hash Keys
214
+ # #### User-Defined `Hash` Keys
219
215
  #
220
- # To be useable as a Hash key, objects must implement the methods `hash` and
221
- # `eql?`. Note: this requirement does not apply if the Hash uses
216
+ # To be usable as a `Hash` key, objects must implement the methods `hash` and
217
+ # `eql?`. Note: this requirement does not apply if the `Hash` uses
222
218
  # #compare_by_identity since comparison will then rely on the keys' object id
223
219
  # instead of `hash` and `eql?`.
224
220
  #
@@ -247,7 +243,7 @@
247
243
  # alias eql? ==
248
244
  #
249
245
  # def hash
250
- # @author.hash ^ @title.hash # XOR
246
+ # [self.class, @author, @title].hash
251
247
  # end
252
248
  # end
253
249
  #
@@ -307,7 +303,7 @@
307
303
  #
308
304
  # #### Default Proc
309
305
  #
310
- # When the default proc for a Hash is set (i.e., not `nil`), the default value
306
+ # When the default proc for a `Hash` is set (i.e., not `nil`), the default value
311
307
  # returned by method #[] is determined by the default proc alone.
312
308
  #
313
309
  # You can retrieve the default proc with method #default_proc:
@@ -324,8 +320,8 @@
324
320
  # h.default_proc.class # => Proc
325
321
  #
326
322
  # When the default proc is set (i.e., not `nil`) and method #[] is called with
327
- # with a non-existent key, #[] calls the default proc with both the Hash object
328
- # itself and the missing key, then returns the proc's return value:
323
+ # with a non-existent key, #[] calls the default proc with both the `Hash`
324
+ # object itself and the missing key, then returns the proc's return value:
329
325
  #
330
326
  # h = Hash.new { |hash, key| "Default value for #{key}" }
331
327
  # h[:nosuch] # => "Default value for nosuch"
@@ -345,219 +341,160 @@
345
341
  # Note that setting the default proc will clear the default value and vice
346
342
  # versa.
347
343
  #
344
+ # Be aware that a default proc that modifies the hash is not thread-safe in the
345
+ # sense that multiple threads can call into the default proc concurrently for
346
+ # the same key.
347
+ #
348
348
  # ### What's Here
349
349
  #
350
- # First, what's elsewhere. Class Hash:
350
+ # First, what's elsewhere. Class `Hash`:
351
351
  #
352
- # * Inherits from [class
353
- # Object](Object.html#class-Object-label-What-27s+Here).
354
- # * Includes [module
355
- # Enumerable](Enumerable.html#module-Enumerable-label-What-27s+Here), which
352
+ # * Inherits from [class Object](rdoc-ref:Object@What-27s+Here).
353
+ # * Includes [module Enumerable](rdoc-ref:Enumerable@What-27s+Here), which
356
354
  # provides dozens of additional methods.
357
355
  #
358
- #
359
- # Here, class Hash provides methods that are useful for:
360
- #
361
- # * [Creating a Hash](#class-Hash-label-Methods+for+Creating+a+Hash)
362
- # * [Setting Hash State](#class-Hash-label-Methods+for+Setting+Hash+State)
363
- # * [Querying](#class-Hash-label-Methods+for+Querying)
364
- # * [Comparing](#class-Hash-label-Methods+for+Comparing)
365
- # * [Fetching](#class-Hash-label-Methods+for+Fetching)
366
- # * [Assigning](#class-Hash-label-Methods+for+Assigning)
367
- # * [Deleting](#class-Hash-label-Methods+for+Deleting)
368
- # * [Iterating](#class-Hash-label-Methods+for+Iterating)
369
- # * [Converting](#class-Hash-label-Methods+for+Converting)
356
+ # Here, class `Hash` provides methods that are useful for:
357
+ #
358
+ # * [Creating a Hash](rdoc-ref:Hash@Methods+for+Creating+a+Hash)
359
+ # * [Setting Hash State](rdoc-ref:Hash@Methods+for+Setting+Hash+State)
360
+ # * [Querying](rdoc-ref:Hash@Methods+for+Querying)
361
+ # * [Comparing](rdoc-ref:Hash@Methods+for+Comparing)
362
+ # * [Fetching](rdoc-ref:Hash@Methods+for+Fetching)
363
+ # * [Assigning](rdoc-ref:Hash@Methods+for+Assigning)
364
+ # * [Deleting](rdoc-ref:Hash@Methods+for+Deleting)
365
+ # * [Iterating](rdoc-ref:Hash@Methods+for+Iterating)
366
+ # * [Converting](rdoc-ref:Hash@Methods+for+Converting)
370
367
  # * [Transforming Keys and
371
- # Values](#class-Hash-label-Methods+for+Transforming+Keys+and+Values)
372
- # * [And more....](#class-Hash-label-Other+Methods)
373
- #
374
- #
375
- # Class Hash also includes methods from module Enumerable.
368
+ # Values](rdoc-ref:Hash@Methods+for+Transforming+Keys+and+Values)
369
+ # * [And more....](rdoc-ref:Hash@Other+Methods)
376
370
  #
377
- # #### Methods for Creating a Hash
371
+ # Class `Hash` also includes methods from module Enumerable.
378
372
  #
379
- # ::[]
380
- # : Returns a new hash populated with given objects.
381
- # ::new
382
- # : Returns a new empty hash.
383
- # ::try_convert
384
- # : Returns a new hash created from a given object.
373
+ # #### Methods for Creating a `Hash`
385
374
  #
375
+ # * ::[]: Returns a new hash populated with given objects.
376
+ # * ::new: Returns a new empty hash.
377
+ # * ::try_convert: Returns a new hash created from a given object.
386
378
  #
387
- # #### Methods for Setting Hash State
388
- #
389
- # #compare_by_identity
390
- # : Sets `self` to consider only identity in comparing keys.
391
- # #default=
392
- # : Sets the default to a given value.
393
- # #default_proc=
394
- # : Sets the default proc to a given proc.
395
- # #rehash
396
- # : Rebuilds the hash table by recomputing the hash index for each key.
379
+ # #### Methods for Setting `Hash` State
397
380
  #
381
+ # * #compare_by_identity: Sets `self` to consider only identity in comparing
382
+ # keys.
383
+ # * #default=: Sets the default to a given value.
384
+ # * #default_proc=: Sets the default proc to a given proc.
385
+ # * #rehash: Rebuilds the hash table by recomputing the hash index for each
386
+ # key.
398
387
  #
399
388
  # #### Methods for Querying
400
389
  #
401
- # #any?
402
- # : Returns whether any element satisfies a given criterion.
403
- # #compare_by_identity?
404
- # : Returns whether the hash considers only identity when comparing keys.
405
- # #default
406
- # : Returns the default value, or the default value for a given key.
407
- # #default_proc
408
- # : Returns the default proc.
409
- # #empty?
410
- # : Returns whether there are no entries.
411
- # #eql?
412
- # : Returns whether a given object is equal to `self`.
413
- # #hash
414
- # : Returns the integer hash code.
415
- # #has_value?
416
- # : Returns whether a given object is a value in `self`.
417
- # #include?, #has_key?, #member?, #key?
418
- # : Returns whether a given object is a key in `self`.
419
- # #length, #size
420
- # : Returns the count of entries.
421
- # #value?
422
- # : Returns whether a given object is a value in `self`.
423
- #
390
+ # * #any?: Returns whether any element satisfies a given criterion.
391
+ # * #compare_by_identity?: Returns whether the hash considers only identity
392
+ # when comparing keys.
393
+ # * #default: Returns the default value, or the default value for a given key.
394
+ # * #default_proc: Returns the default proc.
395
+ # * #empty?: Returns whether there are no entries.
396
+ # * #eql?: Returns whether a given object is equal to `self`.
397
+ # * #hash: Returns the integer hash code.
398
+ # * #has_value? (aliased as #value?): Returns whether a given object is a
399
+ # value in `self`.
400
+ # * #include? (aliased as #has_key?, #member?, #key?): Returns whether a given
401
+ # object is a key in `self`.
402
+ # * #size (aliased as #length): Returns the count of entries.
424
403
  #
425
404
  # #### Methods for Comparing
426
405
  #
427
- # [#<](#method-i-3C)
428
- # : Returns whether `self` is a proper subset of a given object.
429
- # [#<=](#method-i-3C-3D)
430
- # : Returns whether `self` is a subset of a given object.
431
- # [#==](#method-i-3D-3D)
432
- # : Returns whether a given object is equal to `self`.
433
- # [#>](#method-i-3E)
434
- # : Returns whether `self` is a proper superset of a given object
435
- # [#>=](#method-i-3E-3D)
436
- # : Returns whether `self` is a proper superset of a given object.
437
- #
406
+ # * #<: Returns whether `self` is a proper subset of a given object.
407
+ # * #<=: Returns whether `self` is a subset of a given object.
408
+ # * #==: Returns whether a given object is equal to `self`.
409
+ # * #>: Returns whether `self` is a proper superset of a given object
410
+ # * #>=: Returns whether `self` is a superset of a given object.
438
411
  #
439
412
  # #### Methods for Fetching
440
413
  #
441
- # #[]
442
- # : Returns the value associated with a given key.
443
- # #assoc
444
- # : Returns a 2-element array containing a given key and its value.
445
- # #dig
446
- # : Returns the object in nested objects that is specified by a given key and
447
- # additional arguments.
448
- # #fetch
449
- # : Returns the value for a given key.
450
- # #fetch_values
451
- # : Returns array containing the values associated with given keys.
452
- # #key
453
- # : Returns the key for the first-found entry with a given value.
454
- # #keys
455
- # : Returns an array containing all keys in `self`.
456
- # #rassoc
457
- # : Returns a 2-element array consisting of the key and value of the
414
+ # * #[]: Returns the value associated with a given key.
415
+ # * #assoc: Returns a 2-element array containing a given key and its value.
416
+ # * #dig: Returns the object in nested objects that is specified by a given
417
+ # key and additional arguments.
418
+ # * #fetch: Returns the value for a given key.
419
+ # * #fetch_values: Returns array containing the values associated with given
420
+ # keys.
421
+ # * #key: Returns the key for the first-found entry with a given value.
422
+ # * #keys: Returns an array containing all keys in `self`.
423
+ # * #rassoc: Returns a 2-element array consisting of the key and value of the
458
424
  # first-found entry having a given value.
459
- # #values
460
- # : Returns an array containing all values in `self`/
461
- # #values_at
462
- # : Returns an array containing values for given keys.
463
- #
425
+ # * #values: Returns an array containing all values in `self`/
426
+ # * #values_at: Returns an array containing values for given keys.
464
427
  #
465
428
  # #### Methods for Assigning
466
429
  #
467
- # #[]=, #store
468
- # : Associates a given key with a given value.
469
- # #merge
470
- # : Returns the hash formed by merging each given hash into a copy of `self`.
471
- # #merge!, #update
472
- # : Merges each given hash into `self`.
473
- # #replace
474
- # : Replaces the entire contents of `self` with the contents of a givan hash.
475
- #
430
+ # * #[]= (aliased as #store): Associates a given key with a given value.
431
+ # * #merge: Returns the hash formed by merging each given hash into a copy of
432
+ # `self`.
433
+ # * #update (aliased as #merge!): Merges each given hash into `self`.
434
+ # * #replace (aliased as #initialize_copy): Replaces the entire contents of
435
+ # `self` with the contents of a given hash.
476
436
  #
477
437
  # #### Methods for Deleting
478
438
  #
479
439
  # These methods remove entries from `self`:
480
440
  #
481
- # #clear
482
- # : Removes all entries from `self`.
483
- # #compact!
484
- # : Removes all `nil`-valued entries from `self`.
485
- # #delete
486
- # : Removes the entry for a given key.
487
- # #delete_if
488
- # : Removes entries selected by a given block.
489
- # #filter!, #select!
490
- # : Keep only those entries selected by a given block.
491
- # #keep_if
492
- # : Keep only those entries selected by a given block.
493
- # #reject!
494
- # : Removes entries selected by a given block.
495
- # #shift
496
- # : Removes and returns the first entry.
497
- #
441
+ # * #clear: Removes all entries from `self`.
442
+ # * #compact!: Removes all `nil`-valued entries from `self`.
443
+ # * #delete: Removes the entry for a given key.
444
+ # * #delete_if: Removes entries selected by a given block.
445
+ # * #select! (aliased as #filter!): Keep only those entries selected by a
446
+ # given block.
447
+ # * #keep_if: Keep only those entries selected by a given block.
448
+ # * #reject!: Removes entries selected by a given block.
449
+ # * #shift: Removes and returns the first entry.
498
450
  #
499
451
  # These methods return a copy of `self` with some entries removed:
500
452
  #
501
- # #compact
502
- # : Returns a copy of `self` with all `nil`-valued entries removed.
503
- # #except
504
- # : Returns a copy of `self` with entries removed for specified keys.
505
- # #filter, #select
506
- # : Returns a copy of `self` with only those entries selected by a given
507
- # block.
508
- # #reject
509
- # : Returns a copy of `self` with entries removed as specified by a given
510
- # block.
511
- # #slice
512
- # : Returns a hash containing the entries for given keys.
513
- #
453
+ # * #compact: Returns a copy of `self` with all `nil`-valued entries removed.
454
+ # * #except: Returns a copy of `self` with entries removed for specified keys.
455
+ # * #select (aliased as #filter): Returns a copy of `self` with only those
456
+ # entries selected by a given block.
457
+ # * #reject: Returns a copy of `self` with entries removed as specified by a
458
+ # given block.
459
+ # * #slice: Returns a hash containing the entries for given keys.
514
460
  #
515
461
  # #### Methods for Iterating
516
- # #each, #each_pair
517
- # : Calls a given block with each key-value pair.
518
- # #each_key
519
- # : Calls a given block with each key.
520
- # #each_value
521
- # : Calls a given block with each value.
522
- #
462
+ # * #each_pair (aliased as #each): Calls a given block with each key-value
463
+ # pair.
464
+ # * #each_key: Calls a given block with each key.
465
+ # * #each_value: Calls a given block with each value.
523
466
  #
524
467
  # #### Methods for Converting
525
468
  #
526
- # #inspect, #to_s
527
- # : Returns a new String containing the hash entries.
528
- # #to_a
529
- # : Returns a new array of 2-element arrays; each nested array contains a
530
- # key-value pair from `self`.
531
- # #to_h
532
- # : Returns `self` if a Hash; if a subclass of Hash, returns a Hash containing
533
- # the entries from `self`.
534
- # #to_hash
535
- # : Returns `self`.
536
- # #to_proc
537
- # : Returns a proc that maps a given key to its value.
538
- #
469
+ # * #inspect (aliased as #to_s): Returns a new String containing the hash
470
+ # entries.
471
+ # * #to_a: Returns a new array of 2-element arrays; each nested array contains
472
+ # a key-value pair from `self`.
473
+ # * #to_h: Returns `self` if a `Hash`; if a subclass of `Hash`, returns a
474
+ # `Hash` containing the entries from `self`.
475
+ # * #to_hash: Returns `self`.
476
+ # * #to_proc: Returns a proc that maps a given key to its value.
539
477
  #
540
478
  # #### Methods for Transforming Keys and Values
541
479
  #
542
- # #transform_keys
543
- # : Returns a copy of `self` with modified keys.
544
- # #transform_keys!
545
- # : Modifies keys in `self`
546
- # #transform_values
547
- # : Returns a copy of `self` with modified values.
548
- # #transform_values!
549
- # : Modifies values in `self`.
550
- #
480
+ # * #transform_keys: Returns a copy of `self` with modified keys.
481
+ # * #transform_keys!: Modifies keys in `self`
482
+ # * #transform_values: Returns a copy of `self` with modified values.
483
+ # * #transform_values!: Modifies values in `self`.
551
484
  #
552
485
  # #### Other Methods
553
- # #flatten
554
- # : Returns an array that is a 1-dimensional flattening of `self`.
555
- # #invert
556
- # : Returns a hash with the each key-value pair inverted.
486
+ # * #flatten: Returns an array that is a 1-dimensional flattening of `self`.
487
+ # * #invert: Returns a hash with the each key-value pair inverted.
557
488
  #
558
489
  class Hash[unchecked out K, unchecked out V] < Object
559
490
  include Enumerable[[ K, V ]]
560
491
 
492
+ interface _Key
493
+ def hash: () -> Integer
494
+
495
+ def eql?: (untyped rhs) -> boolish
496
+ end
497
+
561
498
  # <!--
562
499
  # rdoc-file=hash.c
563
500
  # - Hash[] -> new_empty_hash
@@ -565,23 +502,23 @@ class Hash[unchecked out K, unchecked out V] < Object
565
502
  # - Hash[ [*2_element_arrays] ] -> new_hash
566
503
  # - Hash[*objects] -> new_hash
567
504
  # -->
568
- # Returns a new Hash object populated with the given objects, if any. See
505
+ # Returns a new `Hash` object populated with the given objects, if any. See
569
506
  # Hash::new.
570
507
  #
571
- # With no argument, returns a new empty Hash.
508
+ # With no argument, returns a new empty `Hash`.
572
509
  #
573
- # When the single given argument is a Hash, returns a new Hash populated with
574
- # the entries from the given Hash, excluding the default value or proc.
510
+ # When the single given argument is a `Hash`, returns a new `Hash` populated
511
+ # with the entries from the given `Hash`, excluding the default value or proc.
575
512
  #
576
513
  # h = {foo: 0, bar: 1, baz: 2}
577
514
  # Hash[h] # => {:foo=>0, :bar=>1, :baz=>2}
578
515
  #
579
516
  # When the single given argument is an Array of 2-element Arrays, returns a new
580
- # Hash object wherein each 2-element array forms a key-value entry:
517
+ # `Hash` object wherein each 2-element array forms a key-value entry:
581
518
  #
582
519
  # Hash[ [ [:foo, 0], [:bar, 1] ] ] # => {:foo=>0, :bar=>1}
583
520
  #
584
- # When the argument count is an even number; returns a new Hash object wherein
521
+ # When the argument count is an even number; returns a new `Hash` object wherein
585
522
  # each successive pair of arguments has become a key-value entry:
586
523
  #
587
524
  # Hash[:foo, 0, :bar, 1] # => {:foo=>0, :bar=>1}
@@ -596,20 +533,18 @@ class Hash[unchecked out K, unchecked out V] < Object
596
533
  # rdoc-file=hash.c
597
534
  # - Hash.try_convert(obj) -> obj, new_hash, or nil
598
535
  # -->
599
- # If `obj` is a Hash object, returns `obj`.
536
+ # If `obj` is a `Hash` object, returns `obj`.
600
537
  #
601
538
  # Otherwise if `obj` responds to `:to_hash`, calls `obj.to_hash` and returns the
602
539
  # result.
603
540
  #
604
541
  # Returns `nil` if `obj` does not respond to `:to_hash`
605
542
  #
606
- # Raises an exception unless `obj.to_hash` returns a Hash object.
543
+ # Raises an exception unless `obj.to_hash` returns a `Hash` object.
607
544
  #
608
545
  def self.try_convert: [U, V] (_ToHash[U, V]) -> ::Hash[U, V]
609
546
  | (untyped) -> (::Hash[untyped, untyped] | nil)
610
547
 
611
- public
612
-
613
548
  # <!--
614
549
  # rdoc-file=hash.c
615
550
  # - hash < other_hash -> true or false
@@ -642,11 +577,10 @@ class Hash[unchecked out K, unchecked out V] < Object
642
577
  # - hash == object -> true or false
643
578
  # -->
644
579
  # Returns `true` if all of the following are true:
645
- # * `object` is a Hash object.
580
+ # * `object` is a `Hash` object.
646
581
  # * `hash` and `object` have the same keys (regardless of order).
647
582
  # * For each key `key`, `hash[key] == object[key]`.
648
583
  #
649
- #
650
584
  # Otherwise, returns `false`.
651
585
  #
652
586
  # Equal:
@@ -694,30 +628,28 @@ class Hash[unchecked out K, unchecked out V] < Object
694
628
  # h[:foo] # => 0
695
629
  #
696
630
  # If `key` is not found, returns a default value (see [Default
697
- # Values](#class-Hash-label-Default+Values)):
631
+ # Values](rdoc-ref:Hash@Default+Values)):
698
632
  # h = {foo: 0, bar: 1, baz: 2}
699
633
  # h[:nosuch] # => nil
700
634
  #
701
- def []: (K arg0) -> V
635
+ def []: %a{implicitly-returns-nil} (K arg0) -> V
702
636
 
703
637
  # <!--
704
638
  # rdoc-file=hash.c
705
639
  # - hash[key] = value -> value
706
640
  # - hash.store(key, value)
707
641
  # -->
708
- # Hash#store is an alias for Hash#[]=.
709
- #
710
642
  # Associates the given `value` with the given `key`; returns `value`.
711
643
  #
712
644
  # If the given `key` exists, replaces its value with the given `value`; the
713
- # ordering is not affected (see [Entry Order](#class-Hash-label-Entry+Order)):
645
+ # ordering is not affected (see [Entry Order](rdoc-ref:Hash@Entry+Order)):
714
646
  # h = {foo: 0, bar: 1}
715
647
  # h[:foo] = 2 # => 2
716
648
  # h.store(:bar, 3) # => 3
717
649
  # h # => {:foo=>2, :bar=>3}
718
650
  #
719
651
  # If `key` does not exist, adds the `key` and `value`; the new entry is last in
720
- # the order (see [Entry Order](#class-Hash-label-Entry+Order)):
652
+ # the order (see [Entry Order](rdoc-ref:Hash@Entry+Order)):
721
653
  # h = {foo: 0, bar: 1}
722
654
  # h[:baz] = 2 # => 2
723
655
  # h.store(:bat, 3) # => 3
@@ -733,6 +665,8 @@ class Hash[unchecked out K, unchecked out V] < Object
733
665
  # -->
734
666
  # Returns `true` if any element satisfies a given criterion; `false` otherwise.
735
667
  #
668
+ # If `self` has no element, returns `false` and argument or block are not used.
669
+ #
736
670
  # With no argument and no block, returns `true` if `self` is non-empty; `false`
737
671
  # if empty.
738
672
  #
@@ -749,6 +683,8 @@ class Hash[unchecked out K, unchecked out V] < Object
749
683
  # h.any? {|key, value| value < 3 } # => true
750
684
  # h.any? {|key, value| value > 3 } # => false
751
685
  #
686
+ # Related: Enumerable#any?
687
+ #
752
688
  def any?: () -> bool
753
689
  | (untyped pattern) -> bool
754
690
  | () { (K, V) -> boolish } -> bool
@@ -847,7 +783,7 @@ class Hash[unchecked out K, unchecked out V] < Object
847
783
  # -->
848
784
  # Returns the default value for the given `key`. The returned value will be
849
785
  # determined either by the default proc or by the default value. See [Default
850
- # Values](#class-Hash-label-Default+Values).
786
+ # Values](rdoc-ref:Hash@Default+Values).
851
787
  #
852
788
  # With no argument, returns the current default value:
853
789
  # h = {}
@@ -871,7 +807,7 @@ class Hash[unchecked out K, unchecked out V] < Object
871
807
  # h.default = false # => false
872
808
  # h.default # => false
873
809
  #
874
- # See [Default Values](#class-Hash-label-Default+Values).
810
+ # See [Default Values](rdoc-ref:Hash@Default+Values).
875
811
  #
876
812
  def default=: (V arg0) -> V
877
813
 
@@ -880,7 +816,7 @@ class Hash[unchecked out K, unchecked out V] < Object
880
816
  # - hash.default_proc -> proc or nil
881
817
  # -->
882
818
  # Returns the default proc for `self` (see [Default
883
- # Values](#class-Hash-label-Default+Values)):
819
+ # Values](rdoc-ref:Hash@Default+Values)):
884
820
  # h = {}
885
821
  # h.default_proc # => nil
886
822
  # h.default_proc = proc {|hash, key| "Default value for #{key}" }
@@ -892,8 +828,8 @@ class Hash[unchecked out K, unchecked out V] < Object
892
828
  # rdoc-file=hash.c
893
829
  # - hash.default_proc = proc -> proc
894
830
  # -->
895
- # Sets the default proc for `self` to `proc`: (see [Default
896
- # Values](#class-Hash-label-Default+Values)):
831
+ # Sets the default proc for `self` to `proc` (see [Default
832
+ # Values](rdoc-ref:Hash@Default+Values)):
897
833
  # h = {}
898
834
  # h.default_proc # => nil
899
835
  # h.default_proc = proc { |hash, key| "Default value for #{key}" }
@@ -970,8 +906,8 @@ class Hash[unchecked out K, unchecked out V] < Object
970
906
  # h = {foo: {bar: [:a, :b, :c]}}
971
907
  # h.dig(:foo, :bar, 2) # => :c
972
908
  #
973
- # This method will use the [default values](#class-Hash-label-Default+Values)
974
- # for keys that are not present:
909
+ # This method will use the [default values](rdoc-ref:Hash@Default+Values) for
910
+ # keys that are not present:
975
911
  # h = {foo: {bar: [:a, :b, :c]}}
976
912
  # h.dig(:hello) # => nil
977
913
  # h.default_proc = -> (hash, _key) { hash }
@@ -981,8 +917,6 @@ class Hash[unchecked out K, unchecked out V] < Object
981
917
  def dig: (K, *untyped) -> untyped
982
918
 
983
919
  # <!-- rdoc-file=hash.c -->
984
- # Hash#each is an alias for Hash#each_pair.
985
- #
986
920
  # Calls the given block with each key-value pair; returns `self`:
987
921
  # h = {foo: 0, bar: 1, baz: 2}
988
922
  # h.each_pair {|key, value| puts "#{key}: #{value}"} # => {:foo=>0, :bar=>1, :baz=>2}
@@ -1041,8 +975,6 @@ class Hash[unchecked out K, unchecked out V] < Object
1041
975
  # - hash.each -> new_enumerator
1042
976
  # - hash.each_pair -> new_enumerator
1043
977
  # -->
1044
- # Hash#each is an alias for Hash#each_pair.
1045
- #
1046
978
  # Calls the given block with each key-value pair; returns `self`:
1047
979
  # h = {foo: 0, bar: 1, baz: 2}
1048
980
  # h.each_pair {|key, value| puts "#{key}: #{value}"} # => {:foo=>0, :bar=>1, :baz=>2}
@@ -1105,17 +1037,15 @@ class Hash[unchecked out K, unchecked out V] < Object
1105
1037
 
1106
1038
  # <!--
1107
1039
  # rdoc-file=hash.c
1108
- # - hash.eql? object -> true or false
1040
+ # - hash.eql?(object) -> true or false
1109
1041
  # -->
1110
1042
  # Returns `true` if all of the following are true:
1111
- # * `object` is a Hash object.
1043
+ # * `object` is a `Hash` object.
1112
1044
  # * `hash` and `object` have the same keys (regardless of order).
1113
- # * For each key `key`, `h[key] eql? object[key]`.
1114
- #
1045
+ # * For each key `key`, `h[key].eql?(object[key])`.
1115
1046
  #
1116
1047
  # Otherwise, returns `false`.
1117
1048
  #
1118
- # Equal:
1119
1049
  # h1 = {foo: 0, bar: 1, baz: 2}
1120
1050
  # h2 = {foo: 0, bar: 1, baz: 2}
1121
1051
  # h1.eql? h2 # => true
@@ -1128,7 +1058,7 @@ class Hash[unchecked out K, unchecked out V] < Object
1128
1058
  # rdoc-file=hash.c
1129
1059
  # - hsh.except(*keys) -> a_hash
1130
1060
  # -->
1131
- # Returns a new Hash excluding entries for the given `keys`:
1061
+ # Returns a new `Hash` excluding entries for the given `keys`:
1132
1062
  # h = { a: 100, b: 200, c: 300 }
1133
1063
  # h.except(:a) #=> {:b=>200, :c=>300}
1134
1064
  #
@@ -1186,10 +1116,8 @@ class Hash[unchecked out K, unchecked out V] < Object
1186
1116
  | [X] (*K) { (K) -> X } -> ::Array[V | X]
1187
1117
 
1188
1118
  # <!-- rdoc-file=hash.c -->
1189
- # Hash#filter is an alias for Hash#select.
1190
- #
1191
- # Returns a new Hash object whose entries are those for which the block returns
1192
- # a truthy value:
1119
+ # Returns a new `Hash` object whose entries are those for which the block
1120
+ # returns a truthy value:
1193
1121
  # h = {foo: 0, bar: 1, baz: 2}
1194
1122
  # h.select {|key, value| value < 2 } # => {:foo=>0, :bar=>1}
1195
1123
  #
@@ -1202,8 +1130,6 @@ class Hash[unchecked out K, unchecked out V] < Object
1202
1130
  | () -> ::Enumerator[[ K, V ], ::Hash[K, V]]
1203
1131
 
1204
1132
  # <!-- rdoc-file=hash.c -->
1205
- # Hash#filter! is an alias for Hash#select!.
1206
- #
1207
1133
  # Returns `self`, whose entries are those for which the block returns a truthy
1208
1134
  # value:
1209
1135
  # h = {foo: 0, bar: 1, baz: 2}
@@ -1254,8 +1180,6 @@ class Hash[unchecked out K, unchecked out V] < Object
1254
1180
  | (Integer level) -> Array[untyped]
1255
1181
 
1256
1182
  # <!-- rdoc-file=hash.c -->
1257
- # Methods #has_key?, #key?, and #member? are aliases for #include?.
1258
- #
1259
1183
  # Returns `true` if `key` is a key in `self`, otherwise `false`.
1260
1184
  #
1261
1185
  def has_key?: (K arg0) -> bool
@@ -1265,8 +1189,6 @@ class Hash[unchecked out K, unchecked out V] < Object
1265
1189
  # - hash.has_value?(value) -> true or false
1266
1190
  # - hash.value?(value) -> true or false
1267
1191
  # -->
1268
- # Method #value? is an alias for #has_value?.
1269
- #
1270
1192
  # Returns `true` if `value` is a value in `self`, otherwise `false`.
1271
1193
  #
1272
1194
  def has_value?: (V arg0) -> bool
@@ -1277,8 +1199,8 @@ class Hash[unchecked out K, unchecked out V] < Object
1277
1199
  # -->
1278
1200
  # Returns the Integer hash-code for the hash.
1279
1201
  #
1280
- # Two Hash objects have the same hash-code if their content is the same
1281
- # (regardless or order):
1202
+ # Two `Hash` objects have the same hash-code if their content is the same
1203
+ # (regardless of order):
1282
1204
  # h1 = {foo: 0, bar: 1, baz: 2}
1283
1205
  # h2 = {baz: 2, bar: 1, foo: 0}
1284
1206
  # h2.hash == h1.hash # => true
@@ -1293,8 +1215,6 @@ class Hash[unchecked out K, unchecked out V] < Object
1293
1215
  # - hash.key?(key) -> true or false
1294
1216
  # - hash.member?(key) -> true or false
1295
1217
  # -->
1296
- # Methods #has_key?, #key?, and #member? are aliases for #include?.
1297
- #
1298
1218
  # Returns `true` if `key` is a key in `self`, otherwise `false`.
1299
1219
  #
1300
1220
  alias include? has_key?
@@ -1304,10 +1224,9 @@ class Hash[unchecked out K, unchecked out V] < Object
1304
1224
  # - hash.inspect -> new_string
1305
1225
  # -->
1306
1226
  # Returns a new String containing the hash entries:
1307
- # h = {foo: 0, bar: 1, baz: 2}
1308
- # h.inspect # => "{:foo=>0, :bar=>1, :baz=>2}"
1309
1227
  #
1310
- # Hash#to_s is an alias for Hash#inspect.
1228
+ # h = {foo: 0, bar: 1, baz: 2}
1229
+ # h.inspect # => "{foo: 0, bar: 1, baz: 2}"
1311
1230
  #
1312
1231
  def inspect: () -> String
1313
1232
 
@@ -1315,13 +1234,13 @@ class Hash[unchecked out K, unchecked out V] < Object
1315
1234
  # rdoc-file=hash.c
1316
1235
  # - hash.invert -> new_hash
1317
1236
  # -->
1318
- # Returns a new Hash object with the each key-value pair inverted:
1237
+ # Returns a new `Hash` object with the each key-value pair inverted:
1319
1238
  # h = {foo: 0, bar: 1, baz: 2}
1320
1239
  # h1 = h.invert
1321
1240
  # h1 # => {0=>:foo, 1=>:bar, 2=>:baz}
1322
1241
  #
1323
1242
  # Overwrites any repeated new keys: (see [Entry
1324
- # Order](#class-Hash-label-Entry+Order)):
1243
+ # Order](rdoc-ref:Hash@Entry+Order)):
1325
1244
  # h = {foo: 0, bar: 0, baz: 0}
1326
1245
  # h.invert # => {0=>:baz}
1327
1246
  #
@@ -1350,18 +1269,16 @@ class Hash[unchecked out K, unchecked out V] < Object
1350
1269
  # - hash.key(value) -> key or nil
1351
1270
  # -->
1352
1271
  # Returns the key for the first-found entry with the given `value` (see [Entry
1353
- # Order](#class-Hash-label-Entry+Order)):
1272
+ # Order](rdoc-ref:Hash@Entry+Order)):
1354
1273
  # h = {foo: 0, bar: 2, baz: 2}
1355
1274
  # h.key(0) # => :foo
1356
1275
  # h.key(2) # => :bar
1357
1276
  #
1358
- # Returns `nil` if so such value is found.
1277
+ # Returns `nil` if no such value is found.
1359
1278
  #
1360
1279
  def key: (V) -> K?
1361
1280
 
1362
1281
  # <!-- rdoc-file=hash.c -->
1363
- # Methods #has_key?, #key?, and #member? are aliases for #include?.
1364
- #
1365
1282
  # Returns `true` if `key` is a key in `self`, otherwise `false`.
1366
1283
  #
1367
1284
  alias key? has_key?
@@ -1378,15 +1295,12 @@ class Hash[unchecked out K, unchecked out V] < Object
1378
1295
 
1379
1296
  # <!-- rdoc-file=hash.c -->
1380
1297
  # Returns the count of entries in `self`:
1381
- # {foo: 0, bar: 1, baz: 2}.length # => 3
1382
1298
  #
1383
- # Hash#length is an alias for Hash#size.
1299
+ # {foo: 0, bar: 1, baz: 2}.length # => 3
1384
1300
  #
1385
1301
  def length: () -> Integer
1386
1302
 
1387
1303
  # <!-- rdoc-file=hash.c -->
1388
- # Methods #has_key?, #key?, and #member? are aliases for #include?.
1389
- #
1390
1304
  # Returns `true` if `key` is a key in `self`, otherwise `false`.
1391
1305
  #
1392
1306
  alias member? has_key?
@@ -1397,20 +1311,19 @@ class Hash[unchecked out K, unchecked out V] < Object
1397
1311
  # - hash.merge(*other_hashes) -> new_hash
1398
1312
  # - hash.merge(*other_hashes) { |key, old_value, new_value| ... } -> new_hash
1399
1313
  # -->
1400
- # Returns the new Hash formed by merging each of `other_hashes` into a copy of
1314
+ # Returns the new `Hash` formed by merging each of `other_hashes` into a copy of
1401
1315
  # `self`.
1402
1316
  #
1403
- # Each argument in `other_hashes` must be a Hash.
1317
+ # Each argument in `other_hashes` must be a `Hash`.
1404
1318
  #
1405
1319
  # ---
1406
1320
  #
1407
1321
  # With arguments and no block:
1408
- # * Returns the new Hash object formed by merging each successive Hash in
1322
+ # * Returns the new `Hash` object formed by merging each successive `Hash` in
1409
1323
  # `other_hashes` into `self`.
1410
1324
  # * Each new-key entry is added at the end.
1411
1325
  # * Each duplicate-key entry's value overwrites the previous value.
1412
1326
  #
1413
- #
1414
1327
  # Example:
1415
1328
  # h = {foo: 0, bar: 1, baz: 2}
1416
1329
  # h1 = {bat: 3, bar: 4}
@@ -1418,15 +1331,14 @@ class Hash[unchecked out K, unchecked out V] < Object
1418
1331
  # h.merge(h1, h2) # => {:foo=>0, :bar=>4, :baz=>2, :bat=>6, :bam=>5}
1419
1332
  #
1420
1333
  # With arguments and a block:
1421
- # * Returns a new Hash object that is the merge of `self` and each given hash.
1334
+ # * Returns a new `Hash` object that is the merge of `self` and each given
1335
+ # hash.
1422
1336
  # * The given hashes are merged left to right.
1423
1337
  # * Each new-key entry is added at the end.
1424
1338
  # * For each duplicate key:
1425
1339
  # * Calls the block with the key and the old and new values.
1426
1340
  # * The block's return value becomes the new value for the entry.
1427
1341
  #
1428
- #
1429
- #
1430
1342
  # Example:
1431
1343
  # h = {foo: 0, bar: 1, baz: 2}
1432
1344
  # h1 = {bat: 3, bar: 4}
@@ -1438,7 +1350,6 @@ class Hash[unchecked out K, unchecked out V] < Object
1438
1350
  # * Returns a copy of `self`.
1439
1351
  # * The block, if given, is ignored.
1440
1352
  #
1441
- #
1442
1353
  # Example:
1443
1354
  # h = {foo: 0, bar: 1, baz: 2}
1444
1355
  # h.merge # => {:foo=>0, :bar=>1, :baz=>2}
@@ -1451,9 +1362,7 @@ class Hash[unchecked out K, unchecked out V] < Object
1451
1362
  # <!-- rdoc-file=hash.c -->
1452
1363
  # Merges each of `other_hashes` into `self`; returns `self`.
1453
1364
  #
1454
- # Each argument in `other_hashes` must be a Hash.
1455
- #
1456
- # Method #update is an alias for #merge!.
1365
+ # Each argument in `other_hashes` must be a `Hash`.
1457
1366
  #
1458
1367
  # With arguments and no block:
1459
1368
  # * Returns `self`, after the given hashes are merged into it.
@@ -1461,7 +1370,6 @@ class Hash[unchecked out K, unchecked out V] < Object
1461
1370
  # * Each new entry is added at the end.
1462
1371
  # * Each duplicate-key entry's value overwrites the previous value.
1463
1372
  #
1464
- #
1465
1373
  # Example:
1466
1374
  # h = {foo: 0, bar: 1, baz: 2}
1467
1375
  # h1 = {bat: 3, bar: 4}
@@ -1476,8 +1384,6 @@ class Hash[unchecked out K, unchecked out V] < Object
1476
1384
  # * Calls the block with the key and the old and new values.
1477
1385
  # * The block's return value becomes the new value for the entry.
1478
1386
  #
1479
- #
1480
- #
1481
1387
  # Example:
1482
1388
  # h = {foo: 0, bar: 1, baz: 2}
1483
1389
  # h1 = {bat: 3, bar: 4}
@@ -1489,7 +1395,6 @@ class Hash[unchecked out K, unchecked out V] < Object
1489
1395
  # * Returns `self`, unmodified.
1490
1396
  # * The block, if given, is ignored.
1491
1397
  #
1492
- #
1493
1398
  # Example:
1494
1399
  # h = {foo: 0, bar: 1, baz: 2}
1495
1400
  # h.merge # => {:foo=>0, :bar=>1, :baz=>2}
@@ -1505,7 +1410,7 @@ class Hash[unchecked out K, unchecked out V] < Object
1505
1410
  # -->
1506
1411
  # Returns a new 2-element Array consisting of the key and value of the
1507
1412
  # first-found entry whose value is `==` to value (see [Entry
1508
- # Order](#class-Hash-label-Entry+Order)):
1413
+ # Order](rdoc-ref:Hash@Entry+Order)):
1509
1414
  # h = {foo: 0, bar: 1, baz: 1}
1510
1415
  # h.rassoc(1) # => [:bar, 1]
1511
1416
  #
@@ -1522,7 +1427,7 @@ class Hash[unchecked out K, unchecked out V] < Object
1522
1427
  #
1523
1428
  # The hash table becomes invalid if the hash value of a key has changed after
1524
1429
  # the entry was created. See [Modifying an Active Hash
1525
- # Key](#class-Hash-label-Modifying+an+Active+Hash+Key).
1430
+ # Key](rdoc-ref:Hash@Modifying+an+Active+Hash+Key).
1526
1431
  #
1527
1432
  def rehash: () -> self
1528
1433
 
@@ -1531,7 +1436,7 @@ class Hash[unchecked out K, unchecked out V] < Object
1531
1436
  # - hash.reject {|key, value| ... } -> new_hash
1532
1437
  # - hash.reject -> new_enumerator
1533
1438
  # -->
1534
- # Returns a new Hash object whose entries are all those from `self` for which
1439
+ # Returns a new `Hash` object whose entries are all those from `self` for which
1535
1440
  # the block returns `false` or `nil`:
1536
1441
  # h = {foo: 0, bar: 1, baz: 2}
1537
1442
  # h1 = h.reject {|key, value| key.start_with?('b') }
@@ -1579,10 +1484,8 @@ class Hash[unchecked out K, unchecked out V] < Object
1579
1484
  # - hash.select {|key, value| ... } -> new_hash
1580
1485
  # - hash.select -> new_enumerator
1581
1486
  # -->
1582
- # Hash#filter is an alias for Hash#select.
1583
- #
1584
- # Returns a new Hash object whose entries are those for which the block returns
1585
- # a truthy value:
1487
+ # Returns a new `Hash` object whose entries are those for which the block
1488
+ # returns a truthy value:
1586
1489
  # h = {foo: 0, bar: 1, baz: 2}
1587
1490
  # h.select {|key, value| value < 2 } # => {:foo=>0, :bar=>1}
1588
1491
  #
@@ -1598,8 +1501,6 @@ class Hash[unchecked out K, unchecked out V] < Object
1598
1501
  # - hash.select! {|key, value| ... } -> self or nil
1599
1502
  # - hash.select! -> new_enumerator
1600
1503
  # -->
1601
- # Hash#filter! is an alias for Hash#select!.
1602
- #
1603
1504
  # Returns `self`, whose entries are those for which the block returns a truthy
1604
1505
  # value:
1605
1506
  # h = {foo: 0, bar: 1, baz: 2}
@@ -1616,17 +1517,15 @@ class Hash[unchecked out K, unchecked out V] < Object
1616
1517
 
1617
1518
  # <!--
1618
1519
  # rdoc-file=hash.c
1619
- # - hash.shift -> [key, value] or default_value
1520
+ # - hash.shift -> [key, value] or nil
1620
1521
  # -->
1621
- # Removes the first hash entry (see [Entry
1622
- # Order](#class-Hash-label-Entry+Order)); returns a 2-element Array containing
1623
- # the removed key and value:
1522
+ # Removes the first hash entry (see [Entry Order](rdoc-ref:Hash@Entry+Order));
1523
+ # returns a 2-element Array containing the removed key and value:
1624
1524
  # h = {foo: 0, bar: 1, baz: 2}
1625
1525
  # h.shift # => [:foo, 0]
1626
1526
  # h # => {:bar=>1, :baz=>2}
1627
1527
  #
1628
- # Returns the default value if the hash is empty (see [Default
1629
- # Values](#class-Hash-label-Default+Values)).
1528
+ # Returns nil if the hash is empty.
1630
1529
  #
1631
1530
  def shift: () -> [ K, V ]?
1632
1531
 
@@ -1636,9 +1535,8 @@ class Hash[unchecked out K, unchecked out V] < Object
1636
1535
  # - hash.size -> integer
1637
1536
  # -->
1638
1537
  # Returns the count of entries in `self`:
1639
- # {foo: 0, bar: 1, baz: 2}.length # => 3
1640
1538
  #
1641
- # Hash#length is an alias for Hash#size.
1539
+ # {foo: 0, bar: 1, baz: 2}.length # => 3
1642
1540
  #
1643
1541
  alias size length
1644
1542
 
@@ -1646,7 +1544,7 @@ class Hash[unchecked out K, unchecked out V] < Object
1646
1544
  # rdoc-file=hash.c
1647
1545
  # - hash.slice(*keys) -> new_hash
1648
1546
  # -->
1649
- # Returns a new Hash object containing the entries for the given `keys`:
1547
+ # Returns a new `Hash` object containing the entries for the given `keys`:
1650
1548
  # h = {foo: 0, bar: 1, baz: 2}
1651
1549
  # h.slice(:baz, :foo) # => {:baz=>2, :foo=>0}
1652
1550
  #
@@ -1655,19 +1553,17 @@ class Hash[unchecked out K, unchecked out V] < Object
1655
1553
  def slice: (*K) -> ::Hash[K, V]
1656
1554
 
1657
1555
  # <!-- rdoc-file=hash.c -->
1658
- # Hash#store is an alias for Hash#[]=.
1659
- #
1660
1556
  # Associates the given `value` with the given `key`; returns `value`.
1661
1557
  #
1662
1558
  # If the given `key` exists, replaces its value with the given `value`; the
1663
- # ordering is not affected (see [Entry Order](#class-Hash-label-Entry+Order)):
1559
+ # ordering is not affected (see [Entry Order](rdoc-ref:Hash@Entry+Order)):
1664
1560
  # h = {foo: 0, bar: 1}
1665
1561
  # h[:foo] = 2 # => 2
1666
1562
  # h.store(:bar, 3) # => 3
1667
1563
  # h # => {:foo=>2, :bar=>3}
1668
1564
  #
1669
1565
  # If `key` does not exist, adds the `key` and `value`; the new entry is last in
1670
- # the order (see [Entry Order](#class-Hash-label-Entry+Order)):
1566
+ # the order (see [Entry Order](rdoc-ref:Hash@Entry+Order)):
1671
1567
  # h = {foo: 0, bar: 1}
1672
1568
  # h[:baz] = 2 # => 2
1673
1569
  # h.store(:bat, 3) # => 3
@@ -1691,12 +1587,13 @@ class Hash[unchecked out K, unchecked out V] < Object
1691
1587
  # - hash.to_h -> self or new_hash
1692
1588
  # - hash.to_h {|key, value| ... } -> new_hash
1693
1589
  # -->
1694
- # For an instance of Hash, returns `self`.
1590
+ # For an instance of `Hash`, returns `self`.
1695
1591
  #
1696
- # For a subclass of Hash, returns a new Hash containing the content of `self`.
1592
+ # For a subclass of `Hash`, returns a new `Hash` containing the content of
1593
+ # `self`.
1697
1594
  #
1698
- # When a block is given, returns a new Hash object whose content is based on the
1699
- # block; the block should return a 2-element Array object specifying the
1595
+ # When a block is given, returns a new `Hash` object whose content is based on
1596
+ # the block; the block should return a 2-element Array object specifying the
1700
1597
  # key-value pair to be included in the returned Array:
1701
1598
  # h = {foo: 0, bar: 1, baz: 2}
1702
1599
  # h1 = h.to_h {|key, value| [value, key] }
@@ -1729,10 +1626,9 @@ class Hash[unchecked out K, unchecked out V] < Object
1729
1626
 
1730
1627
  # <!-- rdoc-file=hash.c -->
1731
1628
  # Returns a new String containing the hash entries:
1732
- # h = {foo: 0, bar: 1, baz: 2}
1733
- # h.inspect # => "{:foo=>0, :bar=>1, :baz=>2}"
1734
1629
  #
1735
- # Hash#to_s is an alias for Hash#inspect.
1630
+ # h = {foo: 0, bar: 1, baz: 2}
1631
+ # h.inspect # => "{foo: 0, bar: 1, baz: 2}"
1736
1632
  #
1737
1633
  alias to_s inspect
1738
1634
 
@@ -1743,11 +1639,10 @@ class Hash[unchecked out K, unchecked out V] < Object
1743
1639
  # - hash.transform_keys(hash2) {|other_key| ...} -> new_hash
1744
1640
  # - hash.transform_keys -> new_enumerator
1745
1641
  # -->
1746
- # Returns a new Hash object; each entry has:
1642
+ # Returns a new `Hash` object; each entry has:
1747
1643
  # * A key provided by the block.
1748
1644
  # * The value from `self`.
1749
1645
  #
1750
- #
1751
1646
  # An optional hash argument can be provided to map keys to new keys. Any key not
1752
1647
  # given will be mapped using the provided block, or remain the same if no block
1753
1648
  # is given.
@@ -1795,11 +1690,10 @@ class Hash[unchecked out K, unchecked out V] < Object
1795
1690
  # - hash.transform_values {|value| ... } -> new_hash
1796
1691
  # - hash.transform_values -> new_enumerator
1797
1692
  # -->
1798
- # Returns a new Hash object; each entry has:
1693
+ # Returns a new `Hash` object; each entry has:
1799
1694
  # * A key from `self`.
1800
1695
  # * A value provided by the block.
1801
1696
  #
1802
- #
1803
1697
  # Transform values:
1804
1698
  # h = {foo: 0, bar: 1, baz: 2}
1805
1699
  # h1 = h.transform_values {|value| value * 100}
@@ -1841,9 +1735,7 @@ class Hash[unchecked out K, unchecked out V] < Object
1841
1735
  # -->
1842
1736
  # Merges each of `other_hashes` into `self`; returns `self`.
1843
1737
  #
1844
- # Each argument in `other_hashes` must be a Hash.
1845
- #
1846
- # Method #update is an alias for #merge!.
1738
+ # Each argument in `other_hashes` must be a `Hash`.
1847
1739
  #
1848
1740
  # With arguments and no block:
1849
1741
  # * Returns `self`, after the given hashes are merged into it.
@@ -1851,7 +1743,6 @@ class Hash[unchecked out K, unchecked out V] < Object
1851
1743
  # * Each new entry is added at the end.
1852
1744
  # * Each duplicate-key entry's value overwrites the previous value.
1853
1745
  #
1854
- #
1855
1746
  # Example:
1856
1747
  # h = {foo: 0, bar: 1, baz: 2}
1857
1748
  # h1 = {bat: 3, bar: 4}
@@ -1866,8 +1757,6 @@ class Hash[unchecked out K, unchecked out V] < Object
1866
1757
  # * Calls the block with the key and the old and new values.
1867
1758
  # * The block's return value becomes the new value for the entry.
1868
1759
  #
1869
- #
1870
- #
1871
1760
  # Example:
1872
1761
  # h = {foo: 0, bar: 1, baz: 2}
1873
1762
  # h1 = {bat: 3, bar: 4}
@@ -1879,7 +1768,6 @@ class Hash[unchecked out K, unchecked out V] < Object
1879
1768
  # * Returns `self`, unmodified.
1880
1769
  # * The block, if given, is ignored.
1881
1770
  #
1882
- #
1883
1771
  # Example:
1884
1772
  # h = {foo: 0, bar: 1, baz: 2}
1885
1773
  # h.merge # => {:foo=>0, :bar=>1, :baz=>2}
@@ -1889,8 +1777,6 @@ class Hash[unchecked out K, unchecked out V] < Object
1889
1777
  alias update merge!
1890
1778
 
1891
1779
  # <!-- rdoc-file=hash.c -->
1892
- # Method #value? is an alias for #has_value?.
1893
- #
1894
1780
  # Returns `true` if `value` is a value in `self`, otherwise `false`.
1895
1781
  #
1896
1782
  alias value? has_value?
@@ -1913,8 +1799,8 @@ class Hash[unchecked out K, unchecked out V] < Object
1913
1799
  # h = {foo: 0, bar: 1, baz: 2}
1914
1800
  # h.values_at(:baz, :foo) # => [2, 0]
1915
1801
  #
1916
- # The [default values](#class-Hash-label-Default+Values) are returned for any
1917
- # keys that are not found:
1802
+ # The [default values](rdoc-ref:Hash@Default+Values) are returned for any keys
1803
+ # that are not found:
1918
1804
  # h.values_at(:hello, :foo) # => [nil, 0]
1919
1805
  #
1920
1806
  def values_at: (*K arg0) -> ::Array[V?]
@@ -1922,38 +1808,45 @@ class Hash[unchecked out K, unchecked out V] < Object
1922
1808
  private
1923
1809
 
1924
1810
  # <!--
1925
- # rdoc-file=hash.c
1811
+ # rdoc-file=hash.rb
1926
1812
  # - Hash.new(default_value = nil) -> new_hash
1813
+ # - Hash.new(default_value = nil, capacity: size) -> new_hash
1927
1814
  # - Hash.new {|hash, key| ... } -> new_hash
1815
+ # - Hash.new(capacity: size) {|hash, key| ... } -> new_hash
1928
1816
  # -->
1929
- # Returns a new empty Hash object.
1817
+ # Returns a new empty `Hash` object.
1930
1818
  #
1931
1819
  # The initial default value and initial default proc for the new hash depend on
1932
- # which form above was used. See [Default
1933
- # Values](#class-Hash-label-Default+Values).
1820
+ # which form above was used. See [Default Values](rdoc-ref:Hash@Default+Values).
1934
1821
  #
1935
- # If neither an argument nor a block given, initializes both the default value
1936
- # and the default proc to `nil`:
1822
+ # If neither an argument nor a block is given, initializes both the default
1823
+ # value and the default proc to `nil`:
1937
1824
  # h = Hash.new
1938
1825
  # h.default # => nil
1939
1826
  # h.default_proc # => nil
1940
1827
  #
1941
- # If argument `default_value` given but no block given, initializes the default
1942
- # value to the given `default_value` and the default proc to `nil`:
1828
+ # If argument `default_value` is given but no block is given, initializes the
1829
+ # default value to the given `default_value` and the default proc to `nil`:
1943
1830
  # h = Hash.new(false)
1944
1831
  # h.default # => false
1945
1832
  # h.default_proc # => nil
1946
1833
  #
1947
- # If a block given but no argument, stores the block as the default proc and
1948
- # sets the default value to `nil`:
1834
+ # If a block is given but no `default_value`, stores the block as the default
1835
+ # proc and sets the default value to `nil`:
1949
1836
  # h = Hash.new {|hash, key| "Default value for #{key}" }
1950
1837
  # h.default # => nil
1951
1838
  # h.default_proc.class # => Proc
1952
1839
  # h[:nosuch] # => "Default value for nosuch"
1953
1840
  #
1954
- def initialize: () -> void
1955
- | (untyped default) -> void
1956
- | [A, B] () { (Hash[A, B] hash, A key) -> B } -> void
1841
+ # If both a block and a `default_value` are given, raises an `ArgumentError`
1842
+ #
1843
+ # If the optional keyword argument `capacity` is given, the hash will be
1844
+ # allocated with enough capacity to accommodate this many keys without having to
1845
+ # be resized.
1846
+ #
1847
+ def initialize: (?capacity: int) -> void
1848
+ | [V] (V default, ?capacity: int) -> void
1849
+ | [A, B] (?capacity: int) { (Hash[A, B] hash, A key) -> B } -> void
1957
1850
 
1958
1851
  # <!--
1959
1852
  # rdoc-file=hash.c