rbs 4.1.0.pre.1 → 4.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (130) hide show
  1. checksums.yaml +4 -4
  2. data/.dockerignore +37 -0
  3. data/.github/workflows/bundle-update.yml +1 -1
  4. data/.github/workflows/c-check.yml +14 -6
  5. data/.github/workflows/comments.yml +2 -2
  6. data/.github/workflows/dependabot.yml +2 -2
  7. data/.github/workflows/jruby.yml +79 -0
  8. data/.github/workflows/milestone.yml +13 -2
  9. data/.github/workflows/ruby.yml +16 -4
  10. data/.github/workflows/rust.yml +13 -8
  11. data/.github/workflows/truffleruby.yml +54 -0
  12. data/.github/workflows/typecheck.yml +5 -2
  13. data/.github/workflows/wasm.yml +55 -0
  14. data/.github/workflows/windows.yml +8 -2
  15. data/.gitignore +8 -0
  16. data/CHANGELOG.md +88 -0
  17. data/Dockerfile.jruby +53 -0
  18. data/README.md +3 -3
  19. data/Rakefile +103 -1
  20. data/Steepfile +9 -0
  21. data/core/array.rbs +243 -180
  22. data/core/builtin.rbs +6 -6
  23. data/core/enumerable.rbs +109 -109
  24. data/core/enumerator/product.rbs +5 -5
  25. data/core/enumerator.rbs +28 -28
  26. data/core/file.rbs +24 -1018
  27. data/core/file_constants.rbs +463 -0
  28. data/core/file_stat.rbs +534 -0
  29. data/core/float.rbs +0 -24
  30. data/core/hash.rbs +117 -101
  31. data/core/integer.rbs +21 -58
  32. data/core/io.rbs +25 -7
  33. data/core/match_data.rbs +1 -1
  34. data/core/module.rbs +88 -74
  35. data/core/numeric.rbs +3 -0
  36. data/core/object_space/weak_key_map.rbs +7 -7
  37. data/core/pathname.rbs +0 -10
  38. data/core/ractor.rbs +0 -10
  39. data/core/range.rbs +23 -23
  40. data/core/rbs/ops.rbs +154 -0
  41. data/core/rbs/unnamed/argf.rbs +3 -3
  42. data/core/rubygems/errors.rbs +4 -1
  43. data/core/rubygems/requirement.rbs +0 -10
  44. data/core/rubygems/rubygems.rbs +4 -1
  45. data/core/rubygems/specification.rbs +8 -0
  46. data/core/rubygems/version.rbs +0 -160
  47. data/core/set.rbs +3 -3
  48. data/core/struct.rbs +16 -16
  49. data/core/thread.rbs +9 -14
  50. data/docs/CONTRIBUTING.md +2 -1
  51. data/docs/inline.md +36 -6
  52. data/docs/rbs_by_example.md +20 -20
  53. data/docs/release.md +69 -0
  54. data/docs/syntax.md +2 -2
  55. data/docs/wasm_serialization.md +80 -0
  56. data/ext/rbs_extension/ast_translation.c +1294 -973
  57. data/ext/rbs_extension/ast_translation.h +4 -0
  58. data/ext/rbs_extension/legacy_location.c +11 -6
  59. data/ext/rbs_extension/main.c +139 -4
  60. data/include/rbs/ast.h +9 -1
  61. data/include/rbs/serialize.h +39 -0
  62. data/lib/rbs/ast/ruby/comment_block.rb +6 -4
  63. data/lib/rbs/ast/ruby/helpers/location_helper.rb +1 -1
  64. data/lib/rbs/ast/ruby/members.rb +12 -1
  65. data/lib/rbs/buffer.rb +48 -11
  66. data/lib/rbs/collection/sources/git.rb +6 -0
  67. data/lib/rbs/definition_builder/method_builder.rb +12 -6
  68. data/lib/rbs/environment.rb +4 -3
  69. data/lib/rbs/inline_parser.rb +5 -3
  70. data/lib/rbs/namespace.rb +47 -11
  71. data/lib/rbs/parser_aux.rb +4 -2
  72. data/lib/rbs/prototype/rbi.rb +193 -25
  73. data/lib/rbs/prototype/runtime.rb +2 -0
  74. data/lib/rbs/resolver/type_name_resolver.rb +12 -14
  75. data/lib/rbs/type_name.rb +33 -13
  76. data/lib/rbs/unit_test/type_assertions.rb +9 -0
  77. data/lib/rbs/version.rb +1 -1
  78. data/lib/rbs/wasm/deserializer.rb +213 -0
  79. data/lib/rbs/wasm/location.rb +61 -0
  80. data/lib/rbs/wasm/parser.rb +137 -0
  81. data/lib/rbs/wasm/runtime.rb +196 -0
  82. data/lib/rbs/wasm/serialization_schema.rb +110 -0
  83. data/lib/rbs.rb +13 -2
  84. data/lib/rbs_jars.rb +39 -0
  85. data/lib/rdoc_plugin/parser.rb +5 -0
  86. data/rbs.gemspec +32 -2
  87. data/sig/ast/ruby/members.rbs +6 -1
  88. data/sig/buffer.rbs +19 -1
  89. data/sig/namespace.rbs +20 -0
  90. data/sig/parser.rbs +10 -0
  91. data/sig/prototype/rbi.rbs +33 -4
  92. data/sig/resolver/type_name_resolver.rbs +2 -4
  93. data/sig/typename.rbs +15 -0
  94. data/sig/unit_test/type_assertions.rbs +4 -0
  95. data/sig/wasm/deserializer.rbs +66 -0
  96. data/sig/wasm/serialization_schema.rbs +13 -0
  97. data/src/ast.c +78 -78
  98. data/src/lexer.c +97 -93
  99. data/src/lexer.re +1 -1
  100. data/src/lexstate.c +9 -1
  101. data/src/serialize.c +958 -0
  102. data/src/util/rbs_allocator.c +14 -8
  103. data/stdlib/abbrev/0/array.rbs +1 -1
  104. data/stdlib/csv/0/csv.rbs +5 -5
  105. data/stdlib/delegate/0/delegator.rbs +2 -1
  106. data/stdlib/digest/0/digest.rbs +11 -5
  107. data/stdlib/erb/0/erb.rbs +1 -1
  108. data/stdlib/etc/0/etc.rbs +18 -4
  109. data/stdlib/fileutils/0/fileutils.rbs +21 -21
  110. data/stdlib/ipaddr/0/ipaddr.rbs +0 -5
  111. data/stdlib/json/0/json.rbs +6 -6
  112. data/stdlib/monitor/0/monitor.rbs +2 -2
  113. data/stdlib/openssl/0/openssl.rbs +44 -38
  114. data/stdlib/resolv/0/resolv.rbs +1 -1
  115. data/stdlib/shellwords/0/shellwords.rbs +1 -1
  116. data/stdlib/stringio/0/stringio.rbs +32 -10
  117. data/stdlib/strscan/0/string_scanner.rbs +74 -55
  118. data/stdlib/tempfile/0/manifest.yaml +3 -0
  119. data/stdlib/timeout/0/timeout.rbs +0 -5
  120. data/stdlib/tsort/0/cyclic.rbs +1 -1
  121. data/stdlib/tsort/0/interfaces.rbs +8 -8
  122. data/stdlib/tsort/0/tsort.rbs +9 -9
  123. data/stdlib/uri/0/generic.rbs +0 -5
  124. data/stdlib/zlib/0/gzip_reader.rbs +2 -2
  125. data/stdlib/zlib/0/zstream.rbs +0 -1
  126. data/wasm/README.md +60 -0
  127. data/wasm/rbs_wasm.c +423 -0
  128. metadata +26 -5
  129. data/.vscode/extensions.json +0 -5
  130. data/.vscode/settings.json +0 -19
data/core/array.rbs CHANGED
@@ -546,8 +546,14 @@
546
546
  # given block.
547
547
  #
548
548
  %a{annotate:rdoc:source:from=array.c}
549
- class Array[unchecked out Elem] < Object
550
- include Enumerable[Elem]
549
+ class Array[unchecked out E]
550
+ include Enumerable[E]
551
+
552
+ # Interface for random number generations; used with `Array#shuffle`, `Array#shuffle!`, and `Array#sample`.
553
+ interface _Rand
554
+ # Generate a random number up to, but excluding, `max`
555
+ def rand: (Integer max) -> int
556
+ end
551
557
 
552
558
  # <!--
553
559
  # rdoc-file=array.c
@@ -604,9 +610,9 @@ class Array[unchecked out Elem] < Object
604
610
  # Array](rdoc-ref:Array@Methods+for+Creating+an+Array).
605
611
  #
606
612
  def initialize: () -> void
607
- | (::Array[Elem] ary) -> void
608
- | (int size, ?Elem val) -> void
609
- | (int size) { (::Integer index) -> Elem } -> void
613
+ | (array[E] array) -> void
614
+ | (int size, ?E default_value) -> void
615
+ | (int size) { (Integer index) -> E } -> void
610
616
 
611
617
  # <!--
612
618
  # rdoc-file=array.c
@@ -621,7 +627,7 @@ class Array[unchecked out Elem] < Object
621
627
  # Related: see [Methods for Creating an
622
628
  # Array](rdoc-ref:Array@Methods+for+Creating+an+Array).
623
629
  #
624
- def self.[]: [U] (*U) -> ::Array[U]
630
+ def self.[]: [U] (*U) -> Array[U] # this technically returns a subclass, but `instance(self)` isn't a thing
625
631
 
626
632
  # <!--
627
633
  # rdoc-file=array.c
@@ -640,7 +646,9 @@ class Array[unchecked out Elem] < Object
640
646
  # Related: see [Methods for Creating an
641
647
  # Array](rdoc-ref:Array@Methods+for+Creating+an+Array).
642
648
  #
643
- def self.try_convert: [U] (untyped) -> ::Array[U]?
649
+ def self.try_convert: [A < Array[U], U] (A array) -> A
650
+ | [U] (array[U] ary) -> Array[U]?
651
+ | (untyped) -> Array[untyped]?
644
652
 
645
653
  # <!--
646
654
  # rdoc-file=array.c
@@ -664,7 +672,7 @@ class Array[unchecked out Elem] < Object
664
672
  #
665
673
  # Related: see [Methods for Combining](rdoc-ref:Array@Methods+for+Combining).
666
674
  #
667
- def &: (::Array[untyped] | _ToAry[untyped]) -> ::Array[Elem]
675
+ def &: (array[untyped] other_array) -> Array[E] # where E: _Eql?[T]
668
676
 
669
677
  # <!--
670
678
  # rdoc-file=array.c
@@ -682,8 +690,8 @@ class Array[unchecked out Elem] < Object
682
690
  #
683
691
  # [0, [0, 1], {foo: 0}] * ', ' # => "0, 0, 1, {foo: 0}"
684
692
  #
685
- def *: (string str) -> ::String
686
- | (int int) -> ::Array[Elem]
693
+ def *: (string string_separator) -> String # where E: _ToS
694
+ | (int n) -> Array[E] # where E: _ToS
687
695
 
688
696
  # <!--
689
697
  # rdoc-file=array.c
@@ -697,7 +705,7 @@ class Array[unchecked out Elem] < Object
697
705
  #
698
706
  # Related: see [Methods for Combining](rdoc-ref:Array@Methods+for+Combining).
699
707
  #
700
- def +: [U] (_ToAry[U]) -> ::Array[Elem | U]
708
+ def +: [U] (array[U] other_array) -> Array[E | U]
701
709
 
702
710
  # <!--
703
711
  # rdoc-file=array.c
@@ -715,7 +723,7 @@ class Array[unchecked out Elem] < Object
715
723
  #
716
724
  # Related: see [Methods for Combining](rdoc-ref:Array@Methods+for+Combining).
717
725
  #
718
- def -: (_ToAry[untyped]) -> ::Array[Elem]
726
+ def -: (array[untyped] other_array) -> Array[E] # where E: _Eql?[T]
719
727
 
720
728
  # <!--
721
729
  # rdoc-file=array.c
@@ -731,7 +739,7 @@ class Array[unchecked out Elem] < Object
731
739
  #
732
740
  # Related: see [Methods for Assigning](rdoc-ref:Array@Methods+for+Assigning).
733
741
  #
734
- def <<: (Elem) -> self
742
+ def <<: (E object) -> self
735
743
 
736
744
  # <!--
737
745
  # rdoc-file=array.c
@@ -770,7 +778,7 @@ class Array[unchecked out Elem] < Object
770
778
  #
771
779
  # Related: see [Methods for Comparing](rdoc-ref:Array@Methods+for+Comparing).
772
780
  #
773
- def <=>: (untyped) -> ::Integer?
781
+ def <=>: (untyped) -> Integer? # Until we can do `where E: RBS::Ops::_Compare`, this is always going to return `Integer?`
774
782
 
775
783
  # <!--
776
784
  # rdoc-file=array.c
@@ -918,9 +926,9 @@ class Array[unchecked out Elem] < Object
918
926
  #
919
927
  # Related: see [Methods for Fetching](rdoc-ref:Array@Methods+for+Fetching).
920
928
  #
921
- def []: %a{implicitly-returns-nil} (int index) -> Elem
922
- | (int start, int length) -> ::Array[Elem]?
923
- | (::Range[::Integer?] range) -> ::Array[Elem]?
929
+ def []: %a{implicitly-returns-nil} (int index) -> E
930
+ | (int start, int length) -> Array[E]?
931
+ | (range[int] range) -> Array[E]?
924
932
 
925
933
  # <!--
926
934
  # rdoc-file=array.c
@@ -1068,13 +1076,11 @@ class Array[unchecked out Elem] < Object
1068
1076
  #
1069
1077
  # Related: see [Methods for Assigning](rdoc-ref:Array@Methods+for+Assigning).
1070
1078
  #
1071
- def []=: (int index, Elem obj) -> Elem
1072
- | (int start, int length, Elem obj) -> Elem
1073
- | (int start, int length, ::Array[Elem]) -> ::Array[Elem]
1074
- | (int start, int length, nil) -> nil
1075
- | (::Range[::Integer?], Elem obj) -> Elem
1076
- | (::Range[::Integer?], ::Array[Elem]) -> ::Array[Elem]
1077
- | (::Range[::Integer?], nil) -> nil
1079
+ def []=: (int index, E object) -> E
1080
+ | [T < _ToAry[E]] (range[int?] range, T array) -> T
1081
+ | (range[int?] range, E object) -> E
1082
+ | [T < _ToAry[E]] (int start, int length, T array) -> T
1083
+ | (int start, int length, E object) -> E
1078
1084
 
1079
1085
  # <!--
1080
1086
  # rdoc-file=array.c
@@ -1114,8 +1120,8 @@ class Array[unchecked out Elem] < Object
1114
1120
  # Related: see [Methods for Querying](rdoc-ref:Array@Methods+for+Querying).
1115
1121
  #
1116
1122
  def all?: () -> bool
1117
- | (_Pattern[Elem] pattern) -> bool
1118
- | () { (Elem obj) -> boolish } -> bool
1123
+ | (RBS::Ops::_CaseEqual[E, boolish] pattern) -> bool
1124
+ | () { (E element) -> boolish } -> bool
1119
1125
 
1120
1126
  # <!--
1121
1127
  # rdoc-file=array.c
@@ -1155,7 +1161,9 @@ class Array[unchecked out Elem] < Object
1155
1161
  #
1156
1162
  # Related: see [Methods for Querying](rdoc-ref:Array@Methods+for+Querying).
1157
1163
  #
1158
- alias any? all?
1164
+ def any?: () -> bool
1165
+ | (RBS::Ops::_CaseEqual[E, boolish] pattern) -> bool
1166
+ | () { (E element) -> boolish } -> bool
1159
1167
 
1160
1168
  # <!-- rdoc-file=array.c -->
1161
1169
  # Appends each argument in `objects` to `self`; returns `self`:
@@ -1187,7 +1195,7 @@ class Array[unchecked out Elem] < Object
1187
1195
  # Related: Array#rassoc; see also [Methods for
1188
1196
  # Fetching](rdoc-ref:Array@Methods+for+Fetching).
1189
1197
  #
1190
- def assoc: (untyped) -> ::Array[untyped]?
1198
+ def assoc: (untyped object) -> Array[untyped]? # where E: _ToAry[X], object: _Equal
1191
1199
 
1192
1200
  # <!--
1193
1201
  # rdoc-file=array.c
@@ -1211,7 +1219,7 @@ class Array[unchecked out Elem] < Object
1211
1219
  # Related: Array#[]; see also [Methods for
1212
1220
  # Fetching](rdoc-ref:Array@Methods+for+Fetching).
1213
1221
  #
1214
- def at: %a{implicitly-returns-nil} (int index) -> Elem
1222
+ def at: %a{implicitly-returns-nil} (int index) -> E
1215
1223
 
1216
1224
  # <!--
1217
1225
  # rdoc-file=array.c
@@ -1225,9 +1233,9 @@ class Array[unchecked out Elem] < Object
1225
1233
  #
1226
1234
  # Related: see [Methods for Fetching](rdoc-ref:Array@Methods+for+Fetching).
1227
1235
  #
1228
- def bsearch: () -> ::Enumerator[Elem, Elem?]
1229
- | () { (Elem) -> (true | false) } -> Elem?
1230
- | () { (Elem) -> ::Integer } -> Elem?
1236
+ def bsearch: () { (E element) -> bool? } -> E?
1237
+ | () { (E element) -> Numeric? } -> E?
1238
+ | () -> Enumerator[E, E?]
1231
1239
 
1232
1240
  # <!--
1233
1241
  # rdoc-file=array.c
@@ -1241,8 +1249,9 @@ class Array[unchecked out Elem] < Object
1241
1249
  #
1242
1250
  # Related: see [Methods for Fetching](rdoc-ref:Array@Methods+for+Fetching).
1243
1251
  #
1244
- def bsearch_index: () { (Elem) -> (true | false) } -> ::Integer?
1245
- | () { (Elem) -> ::Integer } -> ::Integer?
1252
+ def bsearch_index: () { (E element) -> bool? } -> Integer?
1253
+ | () { (E element) -> Numeric? } -> Integer?
1254
+ | () -> Enumerator[E, Integer?]
1246
1255
 
1247
1256
  # <!--
1248
1257
  # rdoc-file=array.c
@@ -1276,8 +1285,8 @@ class Array[unchecked out Elem] < Object
1276
1285
  # Related: #collect!; see also [Methods for
1277
1286
  # Converting](rdoc-ref:Array@Methods+for+Converting).
1278
1287
  #
1279
- def collect: [U] () { (Elem item) -> U } -> ::Array[U]
1280
- | () -> ::Enumerator[Elem, ::Array[untyped]]
1288
+ def collect: [T] () { (E item) -> T } -> Array[T]
1289
+ | () -> Enumerator[E, Array[untyped]]
1281
1290
 
1282
1291
  # <!--
1283
1292
  # rdoc-file=array.c
@@ -1297,8 +1306,8 @@ class Array[unchecked out Elem] < Object
1297
1306
  # Related: #collect; see also [Methods for
1298
1307
  # Converting](rdoc-ref:Array@Methods+for+Converting).
1299
1308
  #
1300
- def collect!: () { (Elem item) -> Elem } -> self
1301
- | () -> ::Enumerator[Elem, self]
1309
+ def collect!: () { (E element) -> E } -> self
1310
+ | () -> Enumerator[E, self]
1302
1311
 
1303
1312
  # <!--
1304
1313
  # rdoc-file=array.c
@@ -1342,8 +1351,8 @@ class Array[unchecked out Elem] < Object
1342
1351
  # Related: Array#permutation; see also [Methods for
1343
1352
  # Iterating](rdoc-ref:Array@Methods+for+Iterating).
1344
1353
  #
1345
- def combination: (int n) { (::Array[Elem]) -> void } -> self
1346
- | (int n) -> ::Enumerator[::Array[Elem], self]
1354
+ def combination: (int count) { (Array[E] combination) -> void } -> self
1355
+ | (int count) -> Enumerator[Array[E], self]
1347
1356
 
1348
1357
  # <!--
1349
1358
  # rdoc-file=array.c
@@ -1358,7 +1367,7 @@ class Array[unchecked out Elem] < Object
1358
1367
  # Related: Array#compact!; see also [Methods for
1359
1368
  # Deleting](rdoc-ref:Array@Methods+for+Deleting).
1360
1369
  #
1361
- def compact: () -> ::Array[Elem]
1370
+ def compact: () -> Array[E] # it'd be nice if there was a way to do `Array[E - nil]`
1362
1371
 
1363
1372
  # <!--
1364
1373
  # rdoc-file=array.c
@@ -1389,7 +1398,7 @@ class Array[unchecked out Elem] < Object
1389
1398
  #
1390
1399
  # Related: see [Methods for Assigning](rdoc-ref:Array@Methods+for+Assigning).
1391
1400
  #
1392
- def concat: (*::Array[Elem] arrays) -> self
1401
+ def concat: (*array[E] other_arrays) -> self
1393
1402
 
1394
1403
  # <!--
1395
1404
  # rdoc-file=array.c
@@ -1418,9 +1427,8 @@ class Array[unchecked out Elem] < Object
1418
1427
  #
1419
1428
  # Related: see [Methods for Querying](rdoc-ref:Array@Methods+for+Querying).
1420
1429
  #
1421
- def count: () -> ::Integer
1422
- | (Elem obj) -> ::Integer
1423
- | () { (Elem) -> boolish } -> ::Integer
1430
+ def count: () ?{ (E element) -> boolish } -> Integer
1431
+ | (untyped object) -> Integer # where E: RBS::Ops::_Equal
1424
1432
 
1425
1433
  # <!--
1426
1434
  # rdoc-file=array.c
@@ -1454,8 +1462,8 @@ class Array[unchecked out Elem] < Object
1454
1462
  #
1455
1463
  # Related: see [Methods for Iterating](rdoc-ref:Array@Methods+for+Iterating).
1456
1464
  #
1457
- def cycle: (?int? n) { (Elem) -> void } -> nil
1458
- | (?int? n) -> ::Enumerator[Elem, nil]
1465
+ def cycle: (?int? n) { (E element) -> void } -> nil
1466
+ | (?int? n) -> Enumerator[E, nil]
1459
1467
 
1460
1468
  # <!--
1461
1469
  # rdoc-file=array.c
@@ -1499,8 +1507,8 @@ class Array[unchecked out Elem] < Object
1499
1507
  #
1500
1508
  # Related: see [Methods for Deleting](rdoc-ref:Array@Methods+for+Deleting).
1501
1509
  #
1502
- def delete: (Elem obj) -> Elem?
1503
- | [S, T] (S obj) { (S) -> T } -> (Elem | T)
1510
+ def delete: (untyped object) -> E? # where E: _Comparable
1511
+ | [S, T] (S object) { (S object) -> T } -> (E | T)
1504
1512
 
1505
1513
  # <!--
1506
1514
  # rdoc-file=array.c
@@ -1530,7 +1538,7 @@ class Array[unchecked out Elem] < Object
1530
1538
  #
1531
1539
  # Related: see [Methods for Deleting](rdoc-ref:Array@Methods+for+Deleting).
1532
1540
  #
1533
- def delete_at: %a{implicitly-returns-nil} (int index) -> Elem
1541
+ def delete_at: %a{implicitly-returns-nil} (int index) -> E
1534
1542
 
1535
1543
  # <!--
1536
1544
  # rdoc-file=array.c
@@ -1547,8 +1555,25 @@ class Array[unchecked out Elem] < Object
1547
1555
  #
1548
1556
  # Related: see [Methods for Deleting](rdoc-ref:Array@Methods+for+Deleting).
1549
1557
  #
1550
- def delete_if: () { (Elem item) -> boolish } -> self
1551
- | () -> ::Enumerator[Elem, self]
1558
+ def delete_if: () { (E item) -> boolish } -> self
1559
+ | () -> Enumerator[E, self]
1560
+
1561
+ # <!-- rdoc-file=array.c -->
1562
+ # Returns the first element for which the block returns a truthy value.
1563
+ #
1564
+ # With a block given, calls the block with successive elements of the array;
1565
+ # returns the first element for which the block returns a truthy value:
1566
+ #
1567
+ # [1, 3, 5].find {|element| element > 2} # => 3
1568
+ #
1569
+ # If no such element is found, calls `if_none_proc` and returns its return
1570
+ # value.
1571
+ #
1572
+ # [1, 3, 5].find(proc {-1}) {|element| element > 12} # => -1
1573
+ #
1574
+ # With no block given, returns an Enumerator.
1575
+ #
1576
+ alias detect find
1552
1577
 
1553
1578
  # <!--
1554
1579
  # rdoc-file=array.c
@@ -1568,7 +1593,7 @@ class Array[unchecked out Elem] < Object
1568
1593
  # Related: Array#-; see also [Methods for
1569
1594
  # Combining](rdoc-ref:Array@Methods+for+Combining).
1570
1595
  #
1571
- def difference: (*::Array[untyped] arrays) -> ::Array[Elem]
1596
+ def difference: (*array[untyped] other_arrays) -> Array[E]
1572
1597
 
1573
1598
  # <!--
1574
1599
  # rdoc-file=array.c
@@ -1588,8 +1613,8 @@ class Array[unchecked out Elem] < Object
1588
1613
  #
1589
1614
  # Related: see [Methods for Fetching](rdoc-ref:Array@Methods+for+Fetching).
1590
1615
  #
1591
- def dig: (int idx) -> Elem?
1592
- | (int idx, untyped, *untyped) -> untyped
1616
+ def dig: (int index) -> E?
1617
+ | (int index, untyped, *untyped) -> untyped
1593
1618
 
1594
1619
  # <!--
1595
1620
  # rdoc-file=array.c
@@ -1608,7 +1633,7 @@ class Array[unchecked out Elem] < Object
1608
1633
  #
1609
1634
  # Related: see [Methods for Fetching](rdoc-ref:Array@Methods+for+Fetching).
1610
1635
  #
1611
- def drop: (int n) -> ::Array[Elem]
1636
+ def drop: (int count) -> Array[E]
1612
1637
 
1613
1638
  # <!--
1614
1639
  # rdoc-file=array.c
@@ -1627,8 +1652,8 @@ class Array[unchecked out Elem] < Object
1627
1652
  #
1628
1653
  # Related: see [Methods for Fetching](rdoc-ref:Array@Methods+for+Fetching).
1629
1654
  #
1630
- def drop_while: () { (Elem obj) -> boolish } -> ::Array[Elem]
1631
- | () -> ::Enumerator[Elem, ::Array[Elem]]
1655
+ def drop_while: () { (E element) -> boolish } -> Array[E]
1656
+ | () -> Enumerator[E, Array[E]]
1632
1657
 
1633
1658
  # <!--
1634
1659
  # rdoc-file=array.c
@@ -1661,8 +1686,8 @@ class Array[unchecked out Elem] < Object
1661
1686
  #
1662
1687
  # Related: see [Methods for Iterating](rdoc-ref:Array@Methods+for+Iterating).
1663
1688
  #
1664
- def each: () -> ::Enumerator[Elem, self]
1665
- | () { (Elem item) -> void } -> self
1689
+ def each: () { (E element) -> void } -> self
1690
+ | () -> Enumerator[E, self]
1666
1691
 
1667
1692
  # <!--
1668
1693
  # rdoc-file=array.c
@@ -1696,8 +1721,8 @@ class Array[unchecked out Elem] < Object
1696
1721
  #
1697
1722
  # Related: see [Methods for Iterating](rdoc-ref:Array@Methods+for+Iterating).
1698
1723
  #
1699
- def each_index: () { (::Integer index) -> void } -> self
1700
- | () -> ::Enumerator[::Integer, self]
1724
+ def each_index: () { (Integer index) -> void } -> self
1725
+ | () -> Enumerator[Integer, self]
1701
1726
 
1702
1727
  # <!--
1703
1728
  # rdoc-file=array.c
@@ -1769,9 +1794,9 @@ class Array[unchecked out Elem] < Object
1769
1794
  #
1770
1795
  # Related: see [Methods for Fetching](rdoc-ref:Array@Methods+for+Fetching).
1771
1796
  #
1772
- def fetch: (int index) -> Elem
1773
- | [T] (int index, T default) -> (Elem | T)
1774
- | [T] (int index) { (int index) -> T } -> (Elem | T)
1797
+ def fetch: (int index) -> E
1798
+ | [T] (int index, T default) -> (E | T)
1799
+ | [I < _ToInt, T] (I index) { (I index) -> T } -> (E | T)
1775
1800
 
1776
1801
  # <!--
1777
1802
  # rdoc-file=array.rb
@@ -1808,7 +1833,8 @@ class Array[unchecked out Elem] < Object
1808
1833
  #
1809
1834
  # Related: see [Methods for Fetching](rdoc-ref:Array@Methods+for+Fetching).
1810
1835
  #
1811
- def fetch_values: (*int indexes) -> self
1836
+ def fetch_values: (*int indexes) -> Array[E]
1837
+ | [I < _ToInt, T] (*I indexes) { (I index) -> T } -> Array[E | T]
1812
1838
 
1813
1839
  # <!--
1814
1840
  # rdoc-file=array.c
@@ -1988,11 +2014,10 @@ class Array[unchecked out Elem] < Object
1988
2014
  #
1989
2015
  # Related: see [Methods for Assigning](rdoc-ref:Array@Methods+for+Assigning).
1990
2016
  #
1991
- def fill: (Elem obj) -> self
1992
- | (Elem obj, int? start, ?int? length) -> self
1993
- | (Elem obj, ::Range[::Integer] range) -> self
1994
- | (?int? start, ?int? length) { (::Integer index) -> Elem } -> self
1995
- | (::Range[::Integer] range) { (::Integer index) -> Elem } -> self
2017
+ def fill: (E object, ?int? start, ?int? length) -> self
2018
+ | (E object, range[int?] range) -> self
2019
+ | (?int? start, ?int? length) { (Integer index) -> E } -> self
2020
+ | (range[int?] range) { (Integer index) -> E } -> self
1996
2021
 
1997
2022
  # <!-- rdoc-file=array.c -->
1998
2023
  # With a block given, calls the block with each element of `self`; returns a new
@@ -2007,8 +2032,7 @@ class Array[unchecked out Elem] < Object
2007
2032
  #
2008
2033
  # Related: see [Methods for Fetching](rdoc-ref:Array@Methods+for+Fetching).
2009
2034
  #
2010
- def filter: () { (Elem item) -> boolish } -> ::Array[Elem]
2011
- | () -> ::Enumerator[Elem, ::Array[Elem]]
2035
+ alias filter select
2012
2036
 
2013
2037
  # <!-- rdoc-file=array.c -->
2014
2038
  # With a block given, calls the block with each element of `self`; removes from
@@ -2025,8 +2049,7 @@ class Array[unchecked out Elem] < Object
2025
2049
  #
2026
2050
  # Related: see [Methods for Deleting](rdoc-ref:Array@Methods+for+Deleting).
2027
2051
  #
2028
- def filter!: () { (Elem item) -> boolish } -> self?
2029
- | () -> ::Enumerator[Elem, self?]
2052
+ alias filter! select!
2030
2053
 
2031
2054
  # <!--
2032
2055
  # rdoc-file=array.c
@@ -2047,10 +2070,10 @@ class Array[unchecked out Elem] < Object
2047
2070
  #
2048
2071
  # With no block given, returns an Enumerator.
2049
2072
  #
2050
- def find: () { (Elem) -> boolish } -> Elem?
2051
- | () -> ::Enumerator[Elem, Elem?]
2052
- | [T] (Enumerable::_NotFound[T] ifnone) { (Elem) -> boolish } -> (Elem | T)
2053
- | [T] (Enumerable::_NotFound[T] ifnone) -> ::Enumerator[Elem, Elem | T]
2073
+ def find: () { (E) -> boolish } -> E?
2074
+ | () -> Enumerator[E, E?]
2075
+ | [T] (Enumerable::_NotFound[T]? ifnone) { (E) -> boolish } -> (E | T)
2076
+ | [T] (Enumerable::_NotFound[T]? ifnone) -> Enumerator[E, E | T]
2054
2077
 
2055
2078
  # <!--
2056
2079
  # rdoc-file=array.c
@@ -2083,9 +2106,9 @@ class Array[unchecked out Elem] < Object
2083
2106
  #
2084
2107
  # Related: see [Methods for Querying](rdoc-ref:Array@Methods+for+Querying).
2085
2108
  #
2086
- def find_index: (untyped obj) -> ::Integer?
2087
- | () { (Elem item) -> boolish } -> ::Integer?
2088
- | () -> ::Enumerator[Elem, ::Integer?]
2109
+ def find_index: (untyped object) -> Integer? # where E: RBS::Ops::_Equal
2110
+ | () { (E element) -> boolish } -> Integer?
2111
+ | () -> Enumerator[E, Integer?]
2089
2112
 
2090
2113
  # <!--
2091
2114
  # rdoc-file=array.rb
@@ -2113,8 +2136,8 @@ class Array[unchecked out Elem] < Object
2113
2136
  #
2114
2137
  # Related: see [Methods for Querying](rdoc-ref:Array@Methods+for+Querying).
2115
2138
  #
2116
- def first: %a{implicitly-returns-nil} () -> Elem
2117
- | (int n) -> ::Array[Elem]
2139
+ def first: %a{implicitly-returns-nil} () -> E
2140
+ | (int count) -> Array[E]
2118
2141
 
2119
2142
  # <!--
2120
2143
  # rdoc-file=array.c
@@ -2149,7 +2172,7 @@ class Array[unchecked out Elem] < Object
2149
2172
  # Related: Array#flatten!; see also [Methods for
2150
2173
  # Converting](rdoc-ref:Array@Methods+for+Converting).
2151
2174
  #
2152
- def flatten: (?int level) -> ::Array[untyped]
2175
+ def flatten: (?int? level) -> Array[untyped]
2153
2176
 
2154
2177
  # <!--
2155
2178
  # rdoc-file=array.c
@@ -2185,7 +2208,25 @@ class Array[unchecked out Elem] < Object
2185
2208
  # Related: Array#flatten; see also [Methods for
2186
2209
  # Assigning](rdoc-ref:Array@Methods+for+Assigning).
2187
2210
  #
2188
- def flatten!: (?int level) -> self?
2211
+ def flatten!: (?int? level) -> self?
2212
+
2213
+ # <!--
2214
+ # rdoc-file=array.c
2215
+ # - freeze -> self
2216
+ # -->
2217
+ # Freezes `self` (if not already frozen); returns `self`:
2218
+ #
2219
+ # a = []
2220
+ # a.frozen? # => false
2221
+ # a.freeze
2222
+ # a.frozen? # => true
2223
+ #
2224
+ # No further changes may be made to `self`; raises FrozenError if a change is
2225
+ # attempted.
2226
+ #
2227
+ # Related: Kernel#frozen?.
2228
+ #
2229
+ def freeze: () -> self
2189
2230
 
2190
2231
  # <!--
2191
2232
  # rdoc-file=array.c
@@ -2200,7 +2241,7 @@ class Array[unchecked out Elem] < Object
2200
2241
  # ['a', 'b'].hash == ['a', 'c'].hash # => false
2201
2242
  # ['a', 'b'].hash == ['a'].hash # => false
2202
2243
  #
2203
- def hash: () -> ::Integer
2244
+ def hash: () -> Integer # where E: _Hash
2204
2245
 
2205
2246
  # <!--
2206
2247
  # rdoc-file=array.c
@@ -2215,7 +2256,7 @@ class Array[unchecked out Elem] < Object
2215
2256
  #
2216
2257
  # Related: see [Methods for Querying](rdoc-ref:Array@Methods+for+Querying).
2217
2258
  #
2218
- def include?: (top object) -> bool
2259
+ def include?: (untyped object) -> bool # where E: RBS::Ops::_Equals
2219
2260
 
2220
2261
  # <!-- rdoc-file=array.c -->
2221
2262
  # Returns the zero-based integer index of a specified element, or `nil`.
@@ -2278,7 +2319,7 @@ class Array[unchecked out Elem] < Object
2278
2319
  #
2279
2320
  # Related: see [Methods for Assigning](rdoc-ref:Array@Methods+for+Assigning).
2280
2321
  #
2281
- def insert: (int index, *Elem obj) -> self
2322
+ def insert: (int index, *E objects) -> self
2282
2323
 
2283
2324
  # <!--
2284
2325
  # rdoc-file=array.c
@@ -2293,7 +2334,7 @@ class Array[unchecked out Elem] < Object
2293
2334
  #
2294
2335
  # Related: see [Methods for Converting](rdoc-ref:Array@Methods+for+Converting).
2295
2336
  #
2296
- def inspect: () -> String
2337
+ def inspect: () -> String # where E: _Inspect
2297
2338
 
2298
2339
  # <!--
2299
2340
  # rdoc-file=array.c
@@ -2309,7 +2350,7 @@ class Array[unchecked out Elem] < Object
2309
2350
  #
2310
2351
  # Related: see [Methods for Querying](rdoc-ref:Array@Methods+for+Querying).
2311
2352
  #
2312
- def intersect?: (_ToAry[untyped]) -> bool
2353
+ def intersect?: (array[untyped] other_array) -> bool # where E: _Eql?
2313
2354
 
2314
2355
  # <!--
2315
2356
  # rdoc-file=array.c
@@ -2331,7 +2372,7 @@ class Array[unchecked out Elem] < Object
2331
2372
  #
2332
2373
  # Related: see [Methods for Combining](rdoc-ref:Array@Methods+for+Combining).
2333
2374
  #
2334
- def intersection: (*::Array[untyped] | _ToAry[untyped] other_ary) -> ::Array[Elem]
2375
+ def intersection: (*array[untyped] other_arrays) -> Array[E] # where E: _Eql?
2335
2376
 
2336
2377
  # <!--
2337
2378
  # rdoc-file=array.c
@@ -2363,7 +2404,7 @@ class Array[unchecked out Elem] < Object
2363
2404
  #
2364
2405
  # Related: see [Methods for Converting](rdoc-ref:Array@Methods+for+Converting).
2365
2406
  #
2366
- def join: (?string separator) -> String
2407
+ def join: (?string? separator) -> String # where E: _ToS
2367
2408
 
2368
2409
  # <!--
2369
2410
  # rdoc-file=array.c
@@ -2380,8 +2421,8 @@ class Array[unchecked out Elem] < Object
2380
2421
  #
2381
2422
  # Related: see [Methods for Deleting](rdoc-ref:Array@Methods+for+Deleting).
2382
2423
  #
2383
- def keep_if: () { (Elem item) -> boolish } -> self
2384
- | () -> ::Enumerator[Elem, self]
2424
+ def keep_if: () { (E element) -> boolish } -> self
2425
+ | () -> Enumerator[E, self]
2385
2426
 
2386
2427
  # <!--
2387
2428
  # rdoc-file=array.rb
@@ -2408,8 +2449,8 @@ class Array[unchecked out Elem] < Object
2408
2449
  #
2409
2450
  # Related: see [Methods for Fetching](rdoc-ref:Array@Methods+for+Fetching).
2410
2451
  #
2411
- def last: %a{implicitly-returns-nil} () -> Elem
2412
- | (int n) -> ::Array[Elem]
2452
+ def last: %a{implicitly-returns-nil} () -> E
2453
+ | (int count) -> Array[E]
2413
2454
 
2414
2455
  # <!--
2415
2456
  # rdoc-file=array.c
@@ -2423,7 +2464,7 @@ class Array[unchecked out Elem] < Object
2423
2464
  #
2424
2465
  # Related: see [Methods for Querying](rdoc-ref:Array@Methods+for+Querying).
2425
2466
  #
2426
- def length: () -> ::Integer
2467
+ def length: () -> Integer
2427
2468
 
2428
2469
  # <!-- rdoc-file=array.c -->
2429
2470
  # With a block given, calls the block with each element of `self`; returns a new
@@ -2502,10 +2543,12 @@ class Array[unchecked out Elem] < Object
2502
2543
  #
2503
2544
  # Related: see [Methods for Fetching](rdoc-ref:Array@Methods+for+Fetching).
2504
2545
  #
2505
- def max: %a{implicitly-returns-nil} () -> Elem
2506
- | %a{implicitly-returns-nil} () { (Elem a, Elem b) -> ::Integer? } -> Elem
2507
- | (int n) -> ::Array[Elem]
2508
- | (int n) { (Elem a, Elem b) -> ::Integer? } -> ::Array[Elem]
2546
+ def max: %a{implicitly-returns-nil} () -> E # where E: Comparable::_WithSpaceshipOperator
2547
+ | %a{implicitly-returns-nil} () { (E a, E b) -> Comparable::_CompareToZero } -> E
2548
+ | %a{implicitly-returns-nil} %a{warning: returning `nil` will always raise at runtime} () { (E a, E b) -> Comparable::_CompareToZero? } -> E
2549
+ | (int count) -> Array[E] # where E: Comparable::_WithSpaceshipOperator
2550
+ | (int count) { (E a, E b) -> Comparable::_CompareToZero } -> Array[E]
2551
+ | %a{warning: returning `nil` will always raise at runtime} (int count) { (E a, E b) -> Comparable::_CompareToZero? } -> Array[E]
2509
2552
 
2510
2553
  # <!--
2511
2554
  # rdoc-file=array.c
@@ -2555,7 +2598,12 @@ class Array[unchecked out Elem] < Object
2555
2598
  #
2556
2599
  # Related: see [Methods for Fetching](rdoc-ref:Array@Methods+for+Fetching).
2557
2600
  #
2558
- alias min max
2601
+ def min: %a{implicitly-returns-nil} () -> E # where E: Comparable::_WithSpaceshipOperator
2602
+ | %a{implicitly-returns-nil} () { (E a, E b) -> Comparable::_CompareToZero } -> E
2603
+ | %a{implicitly-returns-nil} %a{warning: returning `nil` will always raise at runtime} () { (E a, E b) -> Comparable::_CompareToZero? } -> E
2604
+ | (int count) -> Array[E] # where E: Comparable::_WithSpaceshipOperator
2605
+ | (int count) { (E a, E b) -> Comparable::_CompareToZero } -> Array[E]
2606
+ | %a{warning: returning `nil` will always raise at runtime} (int count) { (E a, E b) -> Comparable::_CompareToZero? } -> Array[E]
2559
2607
 
2560
2608
  # <!--
2561
2609
  # rdoc-file=array.c
@@ -2579,8 +2627,9 @@ class Array[unchecked out Elem] < Object
2579
2627
  #
2580
2628
  # Related: see [Methods for Fetching](rdoc-ref:Array@Methods+for+Fetching).
2581
2629
  #
2582
- def minmax: () -> [ Elem?, Elem? ]
2583
- | () { (Elem a, Elem b) -> ::Integer? } -> [ Elem?, Elem? ]
2630
+ def minmax: () -> [ E?, E? ] # where E: Comparable::_WithSpaceshipOperator
2631
+ | () { (E a, E b) -> Comparable::_CompareToZero } -> [ E?, E? ]
2632
+ | %a{warning: returning `nil` will always raise at runtime} () { (E a, E b) -> Comparable::_CompareToZero? } -> [ E?, E? ]
2584
2633
 
2585
2634
  # <!--
2586
2635
  # rdoc-file=array.c
@@ -2615,7 +2664,9 @@ class Array[unchecked out Elem] < Object
2615
2664
  #
2616
2665
  # Related: see [Methods for Querying](rdoc-ref:Array@Methods+for+Querying).
2617
2666
  #
2618
- alias none? all?
2667
+ def none?: () -> bool
2668
+ | (RBS::Ops::_CaseEqual[E, boolish] pattern) -> bool
2669
+ | () { (E element) -> boolish } -> bool
2619
2670
 
2620
2671
  # <!--
2621
2672
  # rdoc-file=array.c
@@ -2652,7 +2703,9 @@ class Array[unchecked out Elem] < Object
2652
2703
  #
2653
2704
  # Related: see [Methods for Querying](rdoc-ref:Array@Methods+for+Querying).
2654
2705
  #
2655
- alias one? none?
2706
+ def one?: () -> bool
2707
+ | (RBS::Ops::_CaseEqual[E, boolish] pattern) -> bool
2708
+ | () { (E element) -> boolish } -> bool
2656
2709
 
2657
2710
  # <!--
2658
2711
  # rdoc-file=pack.rb
@@ -2704,8 +2757,8 @@ class Array[unchecked out Elem] < Object
2704
2757
  #
2705
2758
  # Related: [Methods for Iterating](rdoc-ref:Array@Methods+for+Iterating).
2706
2759
  #
2707
- def permutation: (?int n) -> ::Enumerator[::Array[Elem], ::Array[Elem]]
2708
- | (?int n) { (::Array[Elem] p) -> void } -> ::Array[Elem]
2760
+ def permutation: (?int? count) { (Array[E] permutation) -> void } -> self
2761
+ | (?int? count) -> Enumerator[Array[E], self]
2709
2762
 
2710
2763
  # <!--
2711
2764
  # rdoc-file=array.c
@@ -2736,8 +2789,8 @@ class Array[unchecked out Elem] < Object
2736
2789
  # Related: Array#push; see also [Methods for
2737
2790
  # Deleting](rdoc-ref:Array@Methods+for+Deleting).
2738
2791
  #
2739
- def pop: () -> Elem?
2740
- | (int n) -> ::Array[Elem]
2792
+ def pop: () -> E?
2793
+ | (int count) -> Array[E]
2741
2794
 
2742
2795
  # <!-- rdoc-file=array.c -->
2743
2796
  # Prepends the given `objects` to `self`:
@@ -2803,10 +2856,14 @@ class Array[unchecked out Elem] < Object
2803
2856
  #
2804
2857
  # Related: see [Methods for Combining](rdoc-ref:Array@Methods+for+Combining).
2805
2858
  #
2806
- def product: () -> ::Array[[ Elem ]]
2807
- | [X] (::Array[X] other_ary) -> ::Array[[ Elem, X ]]
2808
- | [X, Y] (::Array[X] other_ary1, ::Array[Y] other_ary2) -> ::Array[[ Elem, X, Y ]]
2809
- | [U] (*::Array[U] other_arys) -> ::Array[::Array[Elem | U]]
2859
+ def product: () -> Array[[ E ]]
2860
+ | () { ([E] combination) -> void } -> self
2861
+ | [X] (array[X] other_ary) -> Array[[ E, X ]]
2862
+ | [X] (array[X] other_ary) { ([E, X] combination) -> void } -> self
2863
+ | [X, Y] (array[X] other_ary1, array[Y] other_ary2) -> Array[[ E, X, Y ]]
2864
+ | [X, Y] (array[X] other_ary1, array[Y] other_ary2) { ([E, X, Y] combination) -> void } -> self
2865
+ | [U] (*array[U] other_arys) -> Array[Array[E | U]]
2866
+ | [U] (*array[U] other_arys) { (Array[E | U] combination) -> void } -> self
2810
2867
 
2811
2868
  # <!--
2812
2869
  # rdoc-file=array.c
@@ -2825,7 +2882,7 @@ class Array[unchecked out Elem] < Object
2825
2882
  #
2826
2883
  # Related: see [Methods for Assigning](rdoc-ref:Array@Methods+for+Assigning).
2827
2884
  #
2828
- def push: (*Elem obj) -> self
2885
+ def push: (*E objects) -> self
2829
2886
 
2830
2887
  # <!--
2831
2888
  # rdoc-file=array.c
@@ -2843,7 +2900,7 @@ class Array[unchecked out Elem] < Object
2843
2900
  # Related: Array#assoc; see also [Methods for
2844
2901
  # Fetching](rdoc-ref:Array@Methods+for+Fetching).
2845
2902
  #
2846
- alias rassoc assoc
2903
+ def rassoc: (untyped object) -> Array[untyped]? # where E: _ToAry, object: _Equal
2847
2904
 
2848
2905
  # <!--
2849
2906
  # rdoc-file=array.c
@@ -2882,8 +2939,8 @@ class Array[unchecked out Elem] < Object
2882
2939
  #
2883
2940
  # Related: see [Methods for Deleting](rdoc-ref:Array@Methods+for+Deleting).
2884
2941
  #
2885
- def reject!: () { (Elem item) -> boolish } -> self?
2886
- | () -> ::Enumerator[Elem, self?]
2942
+ def reject!: () { (E item) -> boolish } -> self?
2943
+ | () -> Enumerator[E, self?]
2887
2944
 
2888
2945
  # <!--
2889
2946
  # rdoc-file=array.c
@@ -2922,8 +2979,8 @@ class Array[unchecked out Elem] < Object
2922
2979
  #
2923
2980
  # Related: see [Methods for Combining](rdoc-ref:Array@Methods+for+Combining).
2924
2981
  #
2925
- def repeated_combination: (int n) { (::Array[Elem] c) -> void } -> self
2926
- | (int n) -> ::Enumerator[::Array[Elem], self]
2982
+ def repeated_combination: (int size) { (Array[E] combination) -> void } -> self
2983
+ | (int size) -> Enumerator[Array[E], self]
2927
2984
 
2928
2985
  # <!--
2929
2986
  # rdoc-file=array.c
@@ -2962,8 +3019,8 @@ class Array[unchecked out Elem] < Object
2962
3019
  #
2963
3020
  # Related: see [Methods for Combining](rdoc-ref:Array@Methods+for+Combining).
2964
3021
  #
2965
- def repeated_permutation: (int n) { (::Array[Elem] p) -> void } -> self
2966
- | (int n) -> ::Enumerator[::Array[Elem], self]
3022
+ def repeated_permutation: (int size) { (Array[E] permutation) -> void } -> self
3023
+ | (int size) -> Enumerator[Array[E], self]
2967
3024
 
2968
3025
  # <!-- rdoc-file=array.c -->
2969
3026
  # Replaces the elements of `self` with the elements of `other_array`, which must
@@ -2976,7 +3033,7 @@ class Array[unchecked out Elem] < Object
2976
3033
  #
2977
3034
  # Related: see [Methods for Assigning](rdoc-ref:Array@Methods+for+Assigning).
2978
3035
  #
2979
- def replace: (::Array[Elem]) -> self
3036
+ def replace: (array[E] other_array) -> self
2980
3037
 
2981
3038
  # <!--
2982
3039
  # rdoc-file=array.c
@@ -2988,7 +3045,7 @@ class Array[unchecked out Elem] < Object
2988
3045
  #
2989
3046
  # Related: see [Methods for Combining](rdoc-ref:Array@Methods+for+Combining).
2990
3047
  #
2991
- def reverse: () -> ::Array[Elem]
3048
+ def reverse: () -> Array[E]
2992
3049
 
2993
3050
  # <!--
2994
3051
  # rdoc-file=array.c
@@ -3002,7 +3059,7 @@ class Array[unchecked out Elem] < Object
3002
3059
  #
3003
3060
  # Related: see [Methods for Assigning](rdoc-ref:Array@Methods+for+Assigning).
3004
3061
  #
3005
- def reverse!: () -> ::Array[Elem]
3062
+ def reverse!: () -> self
3006
3063
 
3007
3064
  # <!--
3008
3065
  # rdoc-file=array.c
@@ -3026,8 +3083,8 @@ class Array[unchecked out Elem] < Object
3026
3083
  #
3027
3084
  # Related: see [Methods for Iterating](rdoc-ref:Array@Methods+for+Iterating).
3028
3085
  #
3029
- def reverse_each: () { (Elem item) -> void } -> self
3030
- | () -> ::Enumerator[Elem, self]
3086
+ def reverse_each: () { (E element) -> void } -> self
3087
+ | () -> Enumerator[E, self]
3031
3088
 
3032
3089
  # <!--
3033
3090
  # rdoc-file=array.c
@@ -3049,10 +3106,10 @@ class Array[unchecked out Elem] < Object
3049
3106
  #
3050
3107
  # With no block given, returns an Enumerator.
3051
3108
  #
3052
- def rfind: () { (Elem) -> boolish } -> Elem?
3053
- | () -> ::Enumerator[Elem, Elem?]
3054
- | [T] (Enumerable::_NotFound[T] ifnone) { (Elem) -> boolish } -> (Elem | T)
3055
- | [T] (Enumerable::_NotFound[T] ifnone) -> ::Enumerator[Elem, Elem | T]
3109
+ def rfind: () { (E) -> boolish } -> E?
3110
+ | () -> Enumerator[E, E?]
3111
+ | [T] (Enumerable::_NotFound[T]? ifnone) { (E) -> boolish } -> (E | T)
3112
+ | [T] (Enumerable::_NotFound[T]? ifnone) -> Enumerator[E, E | T]
3056
3113
 
3057
3114
  # <!--
3058
3115
  # rdoc-file=array.c
@@ -3083,9 +3140,9 @@ class Array[unchecked out Elem] < Object
3083
3140
  #
3084
3141
  # Related: see [Methods for Querying](rdoc-ref:Array@Methods+for+Querying).
3085
3142
  #
3086
- def rindex: (untyped obj) -> ::Integer?
3087
- | () { (Elem item) -> boolish } -> ::Integer?
3088
- | () -> ::Enumerator[Elem, ::Integer?]
3143
+ def rindex: (untyped object) -> Integer? # where E: _Equal
3144
+ | () { (E element) -> boolish } -> Integer?
3145
+ | () -> Enumerator[E, Integer?]
3089
3146
 
3090
3147
  # <!--
3091
3148
  # rdoc-file=array.c
@@ -3120,7 +3177,7 @@ class Array[unchecked out Elem] < Object
3120
3177
  #
3121
3178
  # Related: see [Methods for Fetching](rdoc-ref:Array@Methods+for+Fetching).
3122
3179
  #
3123
- def rotate: (?int count) -> ::Array[Elem]
3180
+ def rotate: (?int count) -> Array[E]
3124
3181
 
3125
3182
  # <!--
3126
3183
  # rdoc-file=array.c
@@ -3206,8 +3263,8 @@ class Array[unchecked out Elem] < Object
3206
3263
  #
3207
3264
  # Related: see [Methods for Fetching](rdoc-ref:Array@Methods+for+Fetching).
3208
3265
  #
3209
- def sample: %a{implicitly-returns-nil} (?random: _Rand rng) -> Elem
3210
- | (int n, ?random: _Rand rng) -> ::Array[Elem]
3266
+ def sample: %a{implicitly-returns-nil} (?random: _Rand) -> E
3267
+ | (int count, ?random: _Rand) -> Array[E]
3211
3268
 
3212
3269
  # <!--
3213
3270
  # rdoc-file=array.c
@@ -3228,8 +3285,8 @@ class Array[unchecked out Elem] < Object
3228
3285
  #
3229
3286
  # Related: see [Methods for Fetching](rdoc-ref:Array@Methods+for+Fetching).
3230
3287
  #
3231
- def select: () { (Elem item) -> boolish } -> ::Array[Elem]
3232
- | () -> ::Enumerator[Elem, ::Array[Elem]]
3288
+ def select: () { (E element) -> boolish } -> Array[E]
3289
+ | () -> Enumerator[E, Array[E]]
3233
3290
 
3234
3291
  # <!--
3235
3292
  # rdoc-file=array.c
@@ -3252,8 +3309,8 @@ class Array[unchecked out Elem] < Object
3252
3309
  #
3253
3310
  # Related: see [Methods for Deleting](rdoc-ref:Array@Methods+for+Deleting).
3254
3311
  #
3255
- def select!: () { (Elem item) -> boolish } -> self?
3256
- | () -> ::Enumerator[Elem, self?]
3312
+ def select!: () { (E element) -> boolish } -> self?
3313
+ | () -> Enumerator[E, self?]
3257
3314
 
3258
3315
  # <!--
3259
3316
  # rdoc-file=array.c
@@ -3291,8 +3348,8 @@ class Array[unchecked out Elem] < Object
3291
3348
  #
3292
3349
  # Related: see [Methods for Deleting](rdoc-ref:Array@Methods+for+Deleting).
3293
3350
  #
3294
- def shift: %a{implicitly-returns-nil} () -> Elem
3295
- | (int n) -> ::Array[Elem]
3351
+ def shift: %a{implicitly-returns-nil} () -> E
3352
+ | (int count) -> Array[E]
3296
3353
 
3297
3354
  # <!--
3298
3355
  # rdoc-file=array.rb
@@ -3316,7 +3373,7 @@ class Array[unchecked out Elem] < Object
3316
3373
  #
3317
3374
  # Related: see [Methods for Fetching](rdoc-ref:Array@Methods+for+Fetching).
3318
3375
  #
3319
- def shuffle: (?random: _Rand rng) -> ::Array[Elem]
3376
+ def shuffle: (?random: _Rand) -> Array[E]
3320
3377
 
3321
3378
  # <!--
3322
3379
  # rdoc-file=array.rb
@@ -3340,7 +3397,7 @@ class Array[unchecked out Elem] < Object
3340
3397
  #
3341
3398
  # Related: see [Methods for Assigning](rdoc-ref:Array@Methods+for+Assigning).
3342
3399
  #
3343
- def shuffle!: (?random: _Rand rng) -> self
3400
+ def shuffle!: (?random: _Rand) -> self
3344
3401
 
3345
3402
  # <!-- rdoc-file=array.c -->
3346
3403
  # Returns the count of elements in `self`:
@@ -3464,9 +3521,7 @@ class Array[unchecked out Elem] < Object
3464
3521
  #
3465
3522
  # Related: see [Methods for Fetching](rdoc-ref:Array@Methods+for+Fetching).
3466
3523
  #
3467
- def slice: %a{implicitly-returns-nil} (int index) -> Elem
3468
- | (int start, int length) -> ::Array[Elem]?
3469
- | (::Range[::Integer] range) -> ::Array[Elem]?
3524
+ alias slice []
3470
3525
 
3471
3526
  # <!--
3472
3527
  # rdoc-file=array.c
@@ -3558,9 +3613,9 @@ class Array[unchecked out Elem] < Object
3558
3613
  #
3559
3614
  # Related: see [Methods for Deleting](rdoc-ref:Array@Methods+for+Deleting).
3560
3615
  #
3561
- def slice!: %a{implicitly-returns-nil} (int index) -> Elem
3562
- | (int start, int length) -> ::Array[Elem]?
3563
- | (::Range[::Integer] range) -> ::Array[Elem]?
3616
+ def slice!: %a{implicitly-returns-nil} (int index) -> E
3617
+ | (int start, int length) -> Array[E]?
3618
+ | (range[int?] range) -> Array[E]?
3564
3619
 
3565
3620
  # <!--
3566
3621
  # rdoc-file=array.c
@@ -3595,8 +3650,9 @@ class Array[unchecked out Elem] < Object
3595
3650
  #
3596
3651
  # Related: see [Methods for Fetching](rdoc-ref:Array@Methods+for+Fetching).
3597
3652
  #
3598
- def sort: () -> ::Array[Elem]
3599
- | () { (Elem a, Elem b) -> ::Integer } -> ::Array[Elem]
3653
+ def sort: () -> Array[E] # where E: Comparable::_WithSpaceshipOperator
3654
+ | () { (E a, E b) -> Comparable::_CompareToZero } -> Array[E]
3655
+ | %a{warning: returning `nil` will always raise at runtime} () { (E a, E b) -> Comparable::_CompareToZero? } -> Array[E]
3600
3656
 
3601
3657
  # <!--
3602
3658
  # rdoc-file=array.c
@@ -3607,8 +3663,9 @@ class Array[unchecked out Elem] < Object
3607
3663
  #
3608
3664
  # Related: see [Methods for Assigning](rdoc-ref:Array@Methods+for+Assigning).
3609
3665
  #
3610
- def sort!: () -> self
3611
- | () { (Elem a, Elem b) -> ::Integer } -> self
3666
+ def sort!: () -> self # where E: Comparable::_WithSpaceshipOperator
3667
+ | () { (E a, E b) -> Comparable::_CompareToZero } -> self
3668
+ | %a{warning: returning `nil` will always raise at runtime} () { (E a, E b) -> Comparable::_CompareToZero? } -> self
3612
3669
 
3613
3670
  # <!--
3614
3671
  # rdoc-file=array.c
@@ -3631,8 +3688,9 @@ class Array[unchecked out Elem] < Object
3631
3688
  #
3632
3689
  # Related: see [Methods for Assigning](rdoc-ref:Array@Methods+for+Assigning).
3633
3690
  #
3634
- def sort_by!: [U] () { (Elem obj) -> U } -> ::Array[Elem]
3635
- | () -> ::Enumerator[Elem, ::Array[Elem]]
3691
+ def sort_by!: () { (E element) -> Comparable::_WithSpaceshipOperator } -> self
3692
+ | %a{warning: returning `nil` will always raise at runtime} () { (E element) -> Comparable::_WithSpaceshipOperator? } -> self
3693
+ | () -> Enumerator[E, self]
3636
3694
 
3637
3695
  # <!--
3638
3696
  # rdoc-file=array.c
@@ -3676,8 +3734,7 @@ class Array[unchecked out Elem] < Object
3676
3734
  # * Array#sum method may not respect method redefinition of "+" methods such
3677
3735
  # as Integer#+.
3678
3736
  #
3679
- def sum: (?untyped init) -> untyped
3680
- | (?untyped init) { (Elem e) -> untyped } -> untyped
3737
+ def sum: (?untyped init) ?{ (E e) -> untyped } -> untyped # This would be usable if we had `where E < Complex`, etc
3681
3738
 
3682
3739
  # <!--
3683
3740
  # rdoc-file=array.c
@@ -3694,7 +3751,7 @@ class Array[unchecked out Elem] < Object
3694
3751
  #
3695
3752
  # Related: see [Methods for Fetching](rdoc-ref:Array@Methods+for+Fetching).
3696
3753
  #
3697
- def take: (int n) -> ::Array[Elem]
3754
+ def take: (int count) -> Array[E]
3698
3755
 
3699
3756
  # <!--
3700
3757
  # rdoc-file=array.c
@@ -3716,8 +3773,8 @@ class Array[unchecked out Elem] < Object
3716
3773
  #
3717
3774
  # Related: see [Methods for Fetching](rdoc-ref:Array@Methods+for+Fetching).
3718
3775
  #
3719
- def take_while: () { (Elem obj) -> boolish } -> ::Array[Elem]
3720
- | () -> ::Enumerator[Elem, ::Array[Elem]]
3776
+ def take_while: () { (E element) -> boolish } -> Array[E]
3777
+ | () -> Enumerator[E, Array[E]]
3721
3778
 
3722
3779
  # <!--
3723
3780
  # rdoc-file=array.c
@@ -3735,7 +3792,7 @@ class Array[unchecked out Elem] < Object
3735
3792
  #
3736
3793
  # Related: see [Methods for Converting](rdoc-ref:Array@Methods+for+Converting).
3737
3794
  #
3738
- def to_a: () -> ::Array[Elem]
3795
+ def to_a: () -> Array[E]
3739
3796
 
3740
3797
  # <!--
3741
3798
  # rdoc-file=array.c
@@ -3770,7 +3827,7 @@ class Array[unchecked out Elem] < Object
3770
3827
  # Related: see [Methods for Converting](rdoc-ref:Array@Methods+for+Converting).
3771
3828
  #
3772
3829
  def to_h: () -> Hash[untyped, untyped]
3773
- | [T, S] () { (Elem) -> [ T, S ] } -> Hash[T, S]
3830
+ | [K, V] () { (E element) -> Hash::_Pair[K, V] } -> Hash[K, V]
3774
3831
 
3775
3832
  # <!-- rdoc-file=array.c -->
3776
3833
  # Returns the new string formed by calling method <code>#inspect</code> on each
@@ -3797,7 +3854,7 @@ class Array[unchecked out Elem] < Object
3797
3854
  #
3798
3855
  # Related: see [Methods for Converting](rdoc-ref:Array@Methods+for+Converting).
3799
3856
  #
3800
- def transpose: () -> ::Array[::Array[untyped]]
3857
+ def transpose: () -> Array[Array[untyped]]
3801
3858
 
3802
3859
  # <!--
3803
3860
  # rdoc-file=array.c
@@ -3820,7 +3877,7 @@ class Array[unchecked out Elem] < Object
3820
3877
  #
3821
3878
  # Related: see [Methods for Combining](rdoc-ref:Array@Methods+for+Combining).
3822
3879
  #
3823
- def union: [T] (*::Array[T] other_arys) -> ::Array[T | Elem]
3880
+ def union: [T] (*array[T] other_arrays) -> Array[T | E] # where E: _Eql?[T]
3824
3881
 
3825
3882
  # <!--
3826
3883
  # rdoc-file=array.c
@@ -3846,8 +3903,8 @@ class Array[unchecked out Elem] < Object
3846
3903
  #
3847
3904
  # Related: [Methods for Fetching](rdoc-ref:Array@Methods+for+Fetching).
3848
3905
  #
3849
- def uniq: () -> ::Array[Elem]
3850
- | () { (Elem item) -> untyped } -> ::Array[Elem]
3906
+ def uniq: () -> Array[E] # where E: Hash::_Key
3907
+ | () { (E element) -> Hash::_Key } -> Array[E]
3851
3908
 
3852
3909
  # <!--
3853
3910
  # rdoc-file=array.c
@@ -3875,8 +3932,8 @@ class Array[unchecked out Elem] < Object
3875
3932
  #
3876
3933
  # Related: see [Methods for Deleting](rdoc-ref:Array@Methods+for+Deleting).
3877
3934
  #
3878
- def uniq!: () -> self?
3879
- | () { (Elem) -> untyped } -> self?
3935
+ def uniq!: () -> self? # where E: Hash::_Key
3936
+ | () { (E element) -> Hash::_Key } -> self?
3880
3937
 
3881
3938
  # <!--
3882
3939
  # rdoc-file=array.c
@@ -3891,7 +3948,7 @@ class Array[unchecked out Elem] < Object
3891
3948
  # Related: Array#shift; see also [Methods for
3892
3949
  # Assigning](rdoc-ref:Array@Methods+for+Assigning).
3893
3950
  #
3894
- def unshift: (*Elem obj) -> self
3951
+ def unshift: (*E objects) -> self
3895
3952
 
3896
3953
  # <!--
3897
3954
  # rdoc-file=array.c
@@ -3999,7 +4056,7 @@ class Array[unchecked out Elem] < Object
3999
4056
  #
4000
4057
  # Related: see [Methods for Fetching](rdoc-ref:Array@Methods+for+Fetching).
4001
4058
  #
4002
- def values_at: (*int | ::Range[::Integer] selector) -> ::Array[Elem?]
4059
+ def values_at: (*int | range[int?] selector) -> Array[E?]
4003
4060
 
4004
4061
  # <!--
4005
4062
  # rdoc-file=array.c
@@ -4093,10 +4150,14 @@ class Array[unchecked out Elem] < Object
4093
4150
  #
4094
4151
  # Related: see [Methods for Converting](rdoc-ref:Array@Methods+for+Converting).
4095
4152
  #
4096
- def zip: [U] (_Each[U] arg) -> Array[[ Elem, U? ]]
4097
- | (_Each[untyped] arg, *_Each[untyped] args) -> Array[Array[untyped]]
4098
- | [U] (_Each[U] arg) { ([ Elem, U? ]) -> void } -> nil
4099
- | (_Each[untyped] arg, *_Each[untyped] args) { (Array[untyped]) -> void } -> nil
4153
+ def zip: () -> Array[[ E ]]
4154
+ | [X] (_Each[X] iterable) -> Array[[ E, X? ]]
4155
+ | [X, Y] (_Each[X] iterable1, _Each[Y] iterable2) -> Array[[ E, X?, Y? ]]
4156
+ | [U] (*_Each[U] iterables) -> Array[Array[E | U?]]
4157
+ | () { ([ E ]) -> void } -> nil
4158
+ | [X] (_Each[X] iterable) { ([ E, X? ]) -> void } -> nil
4159
+ | [X, Y] (_Each[X] iterable1, _Each[Y] iterable2) { ([ E, X?, Y? ]) -> void } -> nil
4160
+ | [U] (*_Each[U] iterables) { (Array[E | U?]) -> void } -> nil
4100
4161
 
4101
4162
  # <!--
4102
4163
  # rdoc-file=array.c
@@ -4111,7 +4172,7 @@ class Array[unchecked out Elem] < Object
4111
4172
  #
4112
4173
  # Related: see [Methods for Combining](rdoc-ref:Array@Methods+for+Combining).
4113
4174
  #
4114
- def |: [T] (::Array[T] other_ary) -> ::Array[Elem | T]
4175
+ def |: [T] (array[T] other_array) -> Array[E | T] # where E: _Eql?[T]
4115
4176
 
4116
4177
  private
4117
4178
 
@@ -4130,13 +4191,15 @@ class Array[unchecked out Elem] < Object
4130
4191
  #
4131
4192
  # Related: see [Methods for Assigning](rdoc-ref:Array@Methods+for+Assigning).
4132
4193
  #
4133
- def initialize_copy: (self other_ary) -> void
4194
+ alias initialize_copy replace
4134
4195
  end
4135
4196
 
4197
+ %a{deprecated: Use Array::_Rand, or make your own}
4136
4198
  interface _Rand
4137
- def rand: (::Integer max) -> ::Integer
4199
+ def rand: (Integer max) -> Integer
4138
4200
  end
4139
4201
 
4202
+ %a{deprecated: Use RBS::Ops::_CaseEqual[E, boolish]}
4140
4203
  interface Array::_Pattern[T]
4141
4204
  def ===: (T) -> bool
4142
4205
  end