rbs 4.0.3 → 4.1.0.pre.2

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 (125) hide show
  1. checksums.yaml +4 -4
  2. data/.github/workflows/c-check.yml +3 -0
  3. data/.github/workflows/dependabot.yml +1 -1
  4. data/.github/workflows/jruby.yml +67 -0
  5. data/.github/workflows/milestone.yml +4 -1
  6. data/.github/workflows/ruby.yml +40 -0
  7. data/.github/workflows/rust.yml +3 -2
  8. data/.github/workflows/truffleruby.yml +54 -0
  9. data/.github/workflows/typecheck.yml +3 -0
  10. data/.github/workflows/wasm.yml +53 -0
  11. data/.github/workflows/windows.yml +3 -0
  12. data/.gitignore +7 -0
  13. data/CHANGELOG.md +0 -8
  14. data/README.md +3 -3
  15. data/Rakefile +118 -3
  16. data/Steepfile +7 -0
  17. data/config.yml +24 -0
  18. data/core/array.rbs +144 -144
  19. data/core/builtin.rbs +7 -6
  20. data/core/class.rbs +5 -3
  21. data/core/enumerable.rbs +109 -109
  22. data/core/enumerator/product.rbs +5 -5
  23. data/core/enumerator.rbs +28 -28
  24. data/core/file.rbs +24 -1018
  25. data/core/file_constants.rbs +463 -0
  26. data/core/file_stat.rbs +534 -0
  27. data/core/hash.rbs +117 -101
  28. data/core/integer.rbs +21 -58
  29. data/core/io.rbs +25 -7
  30. data/core/kernel.rbs +26 -11
  31. data/core/module.rbs +88 -74
  32. data/core/numeric.rbs +3 -0
  33. data/core/object_space/weak_key_map.rbs +7 -7
  34. data/core/range.rbs +23 -23
  35. data/core/rbs/ops.rbs +154 -0
  36. data/core/rbs/unnamed/argf.rbs +3 -3
  37. data/core/ruby_vm.rbs +40 -0
  38. data/core/set.rbs +3 -3
  39. data/core/struct.rbs +16 -16
  40. data/core/thread.rbs +6 -6
  41. data/docs/CONTRIBUTING.md +2 -1
  42. data/docs/inline.md +65 -7
  43. data/docs/rbs_by_example.md +20 -20
  44. data/docs/syntax.md +2 -2
  45. data/docs/wasm_serialization.md +80 -0
  46. data/ext/rbs_extension/ast_translation.c +1298 -956
  47. data/ext/rbs_extension/ast_translation.h +4 -0
  48. data/ext/rbs_extension/class_constants.c +2 -0
  49. data/ext/rbs_extension/class_constants.h +1 -0
  50. data/ext/rbs_extension/extconf.rb +1 -0
  51. data/ext/rbs_extension/main.c +139 -4
  52. data/include/rbs/ast.h +323 -298
  53. data/include/rbs/defines.h +13 -0
  54. data/include/rbs/lexer.h +1 -0
  55. data/include/rbs/serialize.h +39 -0
  56. data/lib/rbs/annotate/rdoc_annotator.rb +27 -31
  57. data/lib/rbs/ast/ruby/annotations.rb +42 -0
  58. data/lib/rbs/ast/ruby/comment_block.rb +6 -4
  59. data/lib/rbs/ast/ruby/declarations.rb +11 -1
  60. data/lib/rbs/ast/ruby/helpers/location_helper.rb +1 -1
  61. data/lib/rbs/ast/ruby/members.rb +40 -1
  62. data/lib/rbs/buffer.rb +48 -11
  63. data/lib/rbs/cli.rb +3 -5
  64. data/lib/rbs/collection/config/lockfile_generator.rb +14 -1
  65. data/lib/rbs/collection/sources/git.rb +6 -0
  66. data/lib/rbs/definition_builder/method_builder.rb +12 -6
  67. data/lib/rbs/environment.rb +10 -3
  68. data/lib/rbs/inline_parser.rb +54 -28
  69. data/lib/rbs/namespace.rb +47 -11
  70. data/lib/rbs/prototype/runtime.rb +2 -0
  71. data/lib/rbs/resolver/type_name_resolver.rb +12 -14
  72. data/lib/rbs/rewriter.rb +70 -0
  73. data/lib/rbs/test/type_check.rb +6 -1
  74. data/lib/rbs/type_name.rb +33 -13
  75. data/lib/rbs/unit_test/type_assertions.rb +9 -0
  76. data/lib/rbs/version.rb +1 -1
  77. data/lib/rbs/wasm/deserializer.rb +213 -0
  78. data/lib/rbs/wasm/location.rb +61 -0
  79. data/lib/rbs/wasm/parser.rb +137 -0
  80. data/lib/rbs/wasm/runtime.rb +217 -0
  81. data/lib/rbs/wasm/serialization_schema.rb +110 -0
  82. data/lib/rbs.rb +14 -2
  83. data/rbs.gemspec +19 -2
  84. data/sig/annotate/rdoc_annotater.rbs +12 -9
  85. data/sig/ast/ruby/annotations.rbs +49 -0
  86. data/sig/ast/ruby/members.rbs +21 -1
  87. data/sig/buffer.rbs +19 -1
  88. data/sig/collection/config/lockfile_generator.rbs +2 -0
  89. data/sig/inline_parser.rbs +2 -0
  90. data/sig/manifest.yaml +0 -1
  91. data/sig/namespace.rbs +20 -0
  92. data/sig/parser.rbs +10 -0
  93. data/sig/resolver/type_name_resolver.rbs +2 -4
  94. data/sig/rewriter.rbs +45 -0
  95. data/sig/typename.rbs +15 -0
  96. data/sig/unit_test/type_assertions.rbs +4 -0
  97. data/sig/wasm/deserializer.rbs +66 -0
  98. data/sig/wasm/serialization_schema.rbs +13 -0
  99. data/src/ast.c +186 -162
  100. data/src/lexer.c +137 -114
  101. data/src/lexer.re +1 -0
  102. data/src/lexstate.c +6 -1
  103. data/src/parser.c +55 -5
  104. data/src/serialize.c +958 -0
  105. data/src/util/rbs_allocator.c +1 -4
  106. data/stdlib/abbrev/0/array.rbs +1 -1
  107. data/stdlib/csv/0/csv.rbs +5 -5
  108. data/stdlib/digest/0/digest.rbs +1 -1
  109. data/stdlib/etc/0/etc.rbs +18 -4
  110. data/stdlib/fileutils/0/fileutils.rbs +21 -21
  111. data/stdlib/json/0/json.rbs +6 -6
  112. data/stdlib/openssl/0/openssl.rbs +7 -7
  113. data/stdlib/resolv/0/resolv.rbs +1 -1
  114. data/stdlib/shellwords/0/shellwords.rbs +1 -1
  115. data/stdlib/stringio/0/stringio.rbs +32 -10
  116. data/stdlib/strscan/0/string_scanner.rbs +74 -55
  117. data/stdlib/tsort/0/cyclic.rbs +1 -1
  118. data/stdlib/tsort/0/interfaces.rbs +8 -8
  119. data/stdlib/tsort/0/tsort.rbs +9 -9
  120. data/stdlib/zlib/0/gzip_reader.rbs +2 -2
  121. data/wasm/README.md +59 -0
  122. data/wasm/rbs_wasm.c +411 -0
  123. metadata +23 -5
  124. data/.vscode/extensions.json +0 -5
  125. data/.vscode/settings.json +0 -19
@@ -25,10 +25,7 @@
25
25
  #ifdef _WIN32
26
26
  #include <windows.h>
27
27
  #else
28
- #include <unistd.h>
29
- #include <sys/types.h>
30
- #include <sys/mman.h>
31
- #include <fcntl.h>
28
+ #include <unistd.h> // for sysconf()
32
29
  #endif
33
30
 
34
31
  typedef struct rbs_allocator_page {
@@ -1,5 +1,5 @@
1
1
  %a{annotate:rdoc:skip}
2
- class Array[unchecked out Elem]
2
+ class Array[unchecked out E]
3
3
  # <!--
4
4
  # rdoc-file=lib/abbrev.rb
5
5
  # - abbrev(pattern = nil)
data/stdlib/csv/0/csv.rbs CHANGED
@@ -2964,8 +2964,8 @@ end
2964
2964
  # table['Name'] = ['Foo', 'Bar', 'Baz']
2965
2965
  # table['Name'] # => ["Foo", "Bar", "Baz"]
2966
2966
  #
2967
- class CSV::Table[out Elem] < Object
2968
- include Enumerable[Elem]
2967
+ class CSV::Table[out E] < Object
2968
+ include Enumerable[E]
2969
2969
  extend Forwardable
2970
2970
 
2971
2971
  # <!--
@@ -3587,8 +3587,8 @@ class CSV::Table[out Elem] < Object
3587
3587
  # Returns a new Enumerator if no block is given:
3588
3588
  # table.each # => #<Enumerator: #<CSV::Table mode:col row_count:4>:each>
3589
3589
  #
3590
- def each: () -> Enumerator[Elem, self]
3591
- | () { (Elem) -> void } -> self
3590
+ def each: () -> Enumerator[E, self]
3591
+ | () { (E) -> void } -> self
3592
3592
  | () { (*untyped) -> void } -> self
3593
3593
 
3594
3594
  def empty?: (*untyped args) { (*untyped) -> untyped } -> untyped
@@ -3758,7 +3758,7 @@ class CSV::Table[out Elem] < Object
3758
3758
  end
3759
3759
 
3760
3760
  %a{annotate:rdoc:skip}
3761
- class Array[unchecked out Elem] < Object
3761
+ class Array[unchecked out E] < Object
3762
3762
  # Equivalent to CSV::generate_line(self, options)
3763
3763
  #
3764
3764
  # ["CSV", "data"].to_csv
@@ -303,7 +303,7 @@ module Digest::Instance
303
303
  # uninitialized. Do not call this method from outside. Use #digest!() instead,
304
304
  # which ensures that internal data be reset for security reasons.
305
305
  #
306
- def finish: () -> self
306
+ def finish: () -> String
307
307
  end
308
308
 
309
309
  # <!-- rdoc-file=ext/digest/digest.c -->
data/stdlib/etc/0/etc.rbs CHANGED
@@ -295,7 +295,7 @@ module Etc
295
295
  # Etc.sysconf(Etc::SC_ARG_MAX) #=> 2097152
296
296
  # Etc.sysconf(Etc::SC_LOGIN_NAME_MAX) #=> 256
297
297
  #
298
- def self?.sysconf: (::Integer p1) -> ::Integer
298
+ def self?.sysconf: (::Integer p1) -> ::Integer?
299
299
 
300
300
  # <!--
301
301
  # rdoc-file=ext/etc/etc.c
@@ -318,7 +318,7 @@ module Etc
318
318
  # -->
319
319
  # Returns system temporary directory; typically "/tmp".
320
320
  #
321
- def self?.systmpdir: () -> ::String
321
+ def self?.systmpdir: () -> ::String?
322
322
 
323
323
  # <!--
324
324
  # rdoc-file=ext/etc/etc.c
@@ -709,7 +709,8 @@ module Etc
709
709
  # Etc::Group.collect {|g| g.name}
710
710
  # Etc::Group.select {|g| !g.mem.empty?}
711
711
  #
712
- def self.each: () -> untyped
712
+ def self.each: () { (::Etc::Group) -> void } -> singleton(::Etc::Group)
713
+ | () -> ::Enumerator[::Etc::Group]
713
714
 
714
715
  def self.inspect: () -> untyped
715
716
 
@@ -817,7 +818,8 @@ module Etc
817
818
  # Etc::Passwd.collect {|u| u.gecos}
818
819
  # Etc::Passwd.collect {|u| u.gecos}
819
820
  #
820
- def self.each: () -> untyped
821
+ def self.each: () { (::Etc::Passwd) -> void } -> singleton(::Etc::Passwd)
822
+ | () -> ::Enumerator[::Etc::Passwd]
821
823
 
822
824
  def self.inspect: () -> untyped
823
825
 
@@ -827,10 +829,18 @@ module Etc
827
829
 
828
830
  def self.new: (*untyped) -> untyped
829
831
 
832
+ def age: () -> Integer
833
+
834
+ def age=: (Integer new_age) -> void
835
+
830
836
  def change: () -> Integer
831
837
 
832
838
  def change=: (Integer new_change) -> void
833
839
 
840
+ def comment: () -> String
841
+
842
+ def comment=: (String new_comment) -> void
843
+
834
844
  def dir: () -> String
835
845
 
836
846
  def dir=: (String new_dir) -> void
@@ -855,6 +865,10 @@ module Etc
855
865
 
856
866
  def passwd=: (String new_passwd) -> void
857
867
 
868
+ def quota: () -> Integer
869
+
870
+ def quota=: (Integer new_quota) -> void
871
+
858
872
  def shell: () -> String
859
873
 
860
874
  def shell=: (String new_shell) -> void
@@ -189,7 +189,7 @@ module FileUtils
189
189
  %a{deprecated: Use top-level `path` instead}
190
190
  type path = ::path
191
191
 
192
- type pathlist = path | Array[path]
192
+ type pathlist = ::path | Array[::path]
193
193
 
194
194
  # <!--
195
195
  # rdoc-file=lib/fileutils.rb
@@ -228,8 +228,8 @@ module FileUtils
228
228
  #
229
229
  # Related: FileUtils.pwd.
230
230
  #
231
- def self?.cd: (path dir, ?verbose: boolish) -> void
232
- | [X] (path dir, ?verbose: boolish) { (String) -> X } -> X
231
+ def self?.cd: (::path dir, ?verbose: boolish) -> void
232
+ | [X] (::path dir, ?verbose: boolish) { (String) -> X } -> X
233
233
 
234
234
  # <!--
235
235
  # rdoc-file=lib/fileutils.rb
@@ -444,7 +444,7 @@ module FileUtils
444
444
  #
445
445
  # Related: FileUtils.compare_stream.
446
446
  #
447
- def self?.compare_file: (path a, path b) -> bool
447
+ def self?.compare_file: (::path a, ::path b) -> bool
448
448
 
449
449
  # <!--
450
450
  # rdoc-file=lib/fileutils.rb
@@ -538,7 +538,7 @@ module FileUtils
538
538
  #
539
539
  # Related: [methods for copying](rdoc-ref:FileUtils@Copying).
540
540
  #
541
- def self?.copy_entry: (path src, path dest, ?boolish preserve, ?boolish dereference_root, ?boolish remove_destination) -> void
541
+ def self?.copy_entry: (::path src, ::path dest, ?boolish preserve, ?boolish dereference_root, ?boolish remove_destination) -> void
542
542
 
543
543
  # <!--
544
544
  # rdoc-file=lib/fileutils.rb
@@ -565,7 +565,7 @@ module FileUtils
565
565
  #
566
566
  # Related: [methods for copying](rdoc-ref:FileUtils@Copying).
567
567
  #
568
- def self?.copy_file: (path src, path dest, ?boolish preserve, ?boolish dereference) -> void
568
+ def self?.copy_file: (::path src, ::path dest, ?boolish preserve, ?boolish dereference) -> void
569
569
 
570
570
  # <!--
571
571
  # rdoc-file=lib/fileutils.rb
@@ -633,7 +633,7 @@ module FileUtils
633
633
  #
634
634
  # Related: [methods for copying](rdoc-ref:FileUtils@Copying).
635
635
  #
636
- def self?.cp: (pathlist src, path dest, ?preserve: boolish, ?noop: boolish, ?verbose: boolish) -> void
636
+ def self?.cp: (pathlist src, ::path dest, ?preserve: boolish, ?noop: boolish, ?verbose: boolish) -> void
637
637
 
638
638
  # <!--
639
639
  # rdoc-file=lib/fileutils.rb
@@ -750,7 +750,7 @@ module FileUtils
750
750
  #
751
751
  # Related: [methods for copying](rdoc-ref:FileUtils@Copying).
752
752
  #
753
- def self?.cp_lr: (pathlist src, path dest, ?noop: boolish, ?verbose: boolish, ?dereference_root: boolish, ?remove_destination: boolish) -> void
753
+ def self?.cp_lr: (pathlist src, ::path dest, ?noop: boolish, ?verbose: boolish, ?dereference_root: boolish, ?remove_destination: boolish) -> void
754
754
 
755
755
  # <!--
756
756
  # rdoc-file=lib/fileutils.rb
@@ -856,7 +856,7 @@ module FileUtils
856
856
  #
857
857
  # Related: [methods for copying](rdoc-ref:FileUtils@Copying).
858
858
  #
859
- def self?.cp_r: (pathlist src, path dest, ?preserve: boolish, ?noop: boolish, ?verbose: boolish, ?dereference_root: boolish, ?remove_destination: boolish) -> void
859
+ def self?.cp_r: (pathlist src, ::path dest, ?preserve: boolish, ?noop: boolish, ?verbose: boolish, ?dereference_root: boolish, ?remove_destination: boolish) -> void
860
860
 
861
861
  # <!--
862
862
  # rdoc-file=lib/fileutils.rb
@@ -937,7 +937,7 @@ module FileUtils
937
937
  #
938
938
  # Related: [methods for copying](rdoc-ref:FileUtils@Copying).
939
939
  #
940
- def self?.install: (path src, path dest, ?mode: mode?, ?owner: String?, ?group: String?, ?preserve: boolish, ?noop: boolish, ?verbose: boolish) -> void
940
+ def self?.install: (::path src, ::path dest, ?mode: mode?, ?owner: String?, ?group: String?, ?preserve: boolish, ?noop: boolish, ?verbose: boolish) -> void
941
941
 
942
942
  # <!--
943
943
  # rdoc-file=lib/fileutils.rb
@@ -986,7 +986,7 @@ module FileUtils
986
986
  #
987
987
  # Related: FileUtils.ln (has different options).
988
988
  #
989
- def self?.link_entry: (path src, path dest, ?boolish dereference_root, ?boolish remove_destination) -> void
989
+ def self?.link_entry: (::path src, ::path dest, ?boolish dereference_root, ?boolish remove_destination) -> void
990
990
 
991
991
  # <!--
992
992
  # rdoc-file=lib/fileutils.rb
@@ -1044,7 +1044,7 @@ module FileUtils
1044
1044
  #
1045
1045
  # Related: FileUtils.link_entry (has different options).
1046
1046
  #
1047
- def self?.ln: (pathlist src, path dest, ?force: boolish, ?noop: boolish, ?verbose: boolish) -> void
1047
+ def self?.ln: (pathlist src, ::path dest, ?force: boolish, ?noop: boolish, ?verbose: boolish) -> void
1048
1048
 
1049
1049
  # <!--
1050
1050
  # rdoc-file=lib/fileutils.rb
@@ -1131,7 +1131,7 @@ module FileUtils
1131
1131
  #
1132
1132
  # Related: FileUtils.ln_sf.
1133
1133
  #
1134
- def self?.ln_s: (pathlist src, path dest, ?force: boolish, ?relative: boolish, ?target_directory: boolish, ?noop: boolish, ?verbose: boolish) -> void
1134
+ def self?.ln_s: (pathlist src, ::path dest, ?force: boolish, ?relative: boolish, ?target_directory: boolish, ?noop: boolish, ?verbose: boolish) -> void
1135
1135
 
1136
1136
  # <!--
1137
1137
  # rdoc-file=lib/fileutils.rb
@@ -1154,7 +1154,7 @@ module FileUtils
1154
1154
  # Like FileUtils.ln_s, but always with keyword argument <code>force: true</code>
1155
1155
  # given.
1156
1156
  #
1157
- def self?.ln_sf: (pathlist src, path dest, ?noop: boolish, ?verbose: boolish) -> void
1157
+ def self?.ln_sf: (pathlist src, ::path dest, ?noop: boolish, ?verbose: boolish) -> void
1158
1158
 
1159
1159
  # <!--
1160
1160
  # rdoc-file=lib/fileutils.rb
@@ -1162,7 +1162,7 @@ module FileUtils
1162
1162
  # -->
1163
1163
  # Like FileUtils.ln_s, but create links relative to `dest`.
1164
1164
  #
1165
- def self?.ln_sr: (pathlist src, path dest, ?target_directory: boolish, ?noop: boolish, ?verbose: boolish) -> void
1165
+ def self?.ln_sr: (pathlist src, ::path dest, ?target_directory: boolish, ?noop: boolish, ?verbose: boolish) -> void
1166
1166
 
1167
1167
  # <!--
1168
1168
  # rdoc-file=lib/fileutils.rb
@@ -1339,7 +1339,7 @@ module FileUtils
1339
1339
  # mv src0 dest0
1340
1340
  # mv src1.txt src1 dest1
1341
1341
  #
1342
- def self?.mv: (pathlist src, path dest, ?force: boolish, ?noop: boolish, ?verbose: boolish, ?secure: boolish) -> void
1342
+ def self?.mv: (pathlist src, ::path dest, ?force: boolish, ?noop: boolish, ?verbose: boolish, ?secure: boolish) -> void
1343
1343
 
1344
1344
  # <!--
1345
1345
  # rdoc-file=lib/fileutils.rb
@@ -1418,7 +1418,7 @@ module FileUtils
1418
1418
  #
1419
1419
  # Related: [methods for deleting](rdoc-ref:FileUtils@Deleting).
1420
1420
  #
1421
- def self?.remove_dir: (path path, ?boolish force) -> void
1421
+ def self?.remove_dir: (::path path, ?boolish force) -> void
1422
1422
 
1423
1423
  # <!--
1424
1424
  # rdoc-file=lib/fileutils.rb
@@ -1435,7 +1435,7 @@ module FileUtils
1435
1435
  #
1436
1436
  # Related: FileUtils.remove_entry_secure.
1437
1437
  #
1438
- def self?.remove_entry: (path path, ?boolish force) -> void
1438
+ def self?.remove_entry: (::path path, ?boolish force) -> void
1439
1439
 
1440
1440
  # <!--
1441
1441
  # rdoc-file=lib/fileutils.rb
@@ -1456,7 +1456,7 @@ module FileUtils
1456
1456
  #
1457
1457
  # Related: [methods for deleting](rdoc-ref:FileUtils@Deleting).
1458
1458
  #
1459
- def self?.remove_entry_secure: (path path, ?boolish force) -> void
1459
+ def self?.remove_entry_secure: (::path path, ?boolish force) -> void
1460
1460
 
1461
1461
  # <!--
1462
1462
  # rdoc-file=lib/fileutils.rb
@@ -1473,7 +1473,7 @@ module FileUtils
1473
1473
  #
1474
1474
  # Related: [methods for deleting](rdoc-ref:FileUtils@Deleting).
1475
1475
  #
1476
- def self?.remove_file: (path path, ?boolish force) -> void
1476
+ def self?.remove_file: (::path path, ?boolish force) -> void
1477
1477
 
1478
1478
  # <!--
1479
1479
  # rdoc-file=lib/fileutils.rb
@@ -1749,5 +1749,5 @@ module FileUtils
1749
1749
  #
1750
1750
  # Related: FileUtils.touch.
1751
1751
  #
1752
- def self?.uptodate?: (path new, _Each[path] old_list) -> bool
1752
+ def self?.uptodate?: (::path new, _Each[::path] old_list) -> bool
1753
1753
  end
@@ -1307,7 +1307,7 @@ class Hash[unchecked out K, unchecked out V]
1307
1307
  end
1308
1308
 
1309
1309
  %a{annotate:rdoc:skip}
1310
- class Array[unchecked out Elem]
1310
+ class Array[unchecked out E]
1311
1311
  # Returns a JSON string containing a JSON array, that is generated from
1312
1312
  # this Array instance.
1313
1313
  # _state_ is a JSON::State object, that can also be used to configure the
@@ -1616,7 +1616,7 @@ class OpenStruct
1616
1616
  end
1617
1617
 
1618
1618
  %a{annotate:rdoc:skip}
1619
- class Range[out Elem]
1619
+ class Range[out E]
1620
1620
  # <!--
1621
1621
  # rdoc-file=ext/json/lib/json/add/range.rb
1622
1622
  # - json_create(object)
@@ -1648,7 +1648,7 @@ class Range[out Elem]
1648
1648
  # Range.json_create(y) # => 1...4
1649
1649
  # Range.json_create(z) # => "a".."d"
1650
1650
  #
1651
- def as_json: (*untyped) -> Hash[String, String | [ Elem, Elem, bool ]]
1651
+ def as_json: (*untyped) -> Hash[String, String | [ E, E, bool ]]
1652
1652
 
1653
1653
  # <!--
1654
1654
  # rdoc-file=ext/json/lib/json/add/range.rb
@@ -1815,14 +1815,14 @@ class Set[unchecked out A]
1815
1815
  end
1816
1816
 
1817
1817
  %a{annotate:rdoc:skip}
1818
- class Struct[Elem]
1818
+ class Struct[E]
1819
1819
  # <!--
1820
1820
  # rdoc-file=ext/json/lib/json/add/struct.rb
1821
1821
  # - json_create(object)
1822
1822
  # -->
1823
1823
  # See #as_json.
1824
1824
  #
1825
- def self.json_create: [Elem] (Hash[String, String | Array[Elem]] object) -> Struct[Elem]
1825
+ def self.json_create: [E] (Hash[String, String | Array[E]] object) -> Struct[E]
1826
1826
 
1827
1827
  # <!--
1828
1828
  # rdoc-file=ext/json/lib/json/add/struct.rb
@@ -1846,7 +1846,7 @@ class Struct[Elem]
1846
1846
  # Struct::Customer.json_create(x)
1847
1847
  # # => #<struct Struct::Customer name=nil, address=nil, zip=nil>
1848
1848
  #
1849
- def as_json: (*untyped) -> Hash[String, String | Array[Elem]]
1849
+ def as_json: (*untyped) -> Hash[String, String | Array[E]]
1850
1850
 
1851
1851
  # <!--
1852
1852
  # rdoc-file=ext/json/lib/json/add/struct.rb
@@ -2100,7 +2100,7 @@ module OpenSSL
2100
2100
  #
2101
2101
  # See IO#read for full details.
2102
2102
  #
2103
- def read: (?Integer? size, ?String buf) -> String?
2103
+ def read: (?Integer? size, ?String? buf) -> String?
2104
2104
 
2105
2105
  # <!--
2106
2106
  # rdoc-file=ext/openssl/lib/openssl/buffering.rb
@@ -2139,8 +2139,8 @@ module OpenSSL
2139
2139
  # symbol <code>:wait_writable</code> or <code>:wait_readable</code> instead. At
2140
2140
  # EOF, it will return `nil` instead of raising EOFError.
2141
2141
  #
2142
- def read_nonblock: (Integer maxlen, ?String buf, ?exception: true) -> String
2143
- | (Integer maxlen, ?String buf, exception: false) -> (String | :wait_writable | :wait_readable | nil)
2142
+ def read_nonblock: (Integer maxlen, ?String? buf, ?exception: true) -> String
2143
+ | (Integer maxlen, ?String? buf, exception: false) -> (String | :wait_writable | :wait_readable | nil)
2144
2144
 
2145
2145
  # <!--
2146
2146
  # rdoc-file=ext/openssl/lib/openssl/buffering.rb
@@ -2180,7 +2180,7 @@ module OpenSSL
2180
2180
  #
2181
2181
  # See IO#readpartial for full details.
2182
2182
  #
2183
- def readpartial: (Integer maxlen, ?String buf) -> String
2183
+ def readpartial: (Integer maxlen, ?String? buf) -> String
2184
2184
 
2185
2185
  # <!-- rdoc-file=ext/openssl/lib/openssl/buffering.rb -->
2186
2186
  # The "sync mode" of the SSLSocket.
@@ -8570,7 +8570,7 @@ module OpenSSL
8570
8570
  # The callback is invoked with an SSLSocket. If `false` is returned the session
8571
8571
  # will be removed from the internal cache.
8572
8572
  #
8573
- def session_new_cb: () -> (^(SSLSocket) -> untyped | nil)
8573
+ def session_new_cb: () -> (^(SSLSocket, Session) -> untyped | nil)
8574
8574
 
8575
8575
  # <!-- rdoc-file=ext/openssl/ossl_ssl.c -->
8576
8576
  # A callback invoked when a new session was negotiated.
@@ -8578,7 +8578,7 @@ module OpenSSL
8578
8578
  # The callback is invoked with an SSLSocket. If `false` is returned the session
8579
8579
  # will be removed from the internal cache.
8580
8580
  #
8581
- def session_new_cb=: (^(SSLSocket) -> untyped) -> ^(SSLSocket) -> untyped
8581
+ def session_new_cb=: (^(SSLSocket, Session) -> untyped) -> ^(SSLSocket, Session) -> untyped
8582
8582
 
8583
8583
  # <!--
8584
8584
  # rdoc-file=ext/openssl/ossl_ssl.c
@@ -9235,7 +9235,7 @@ module OpenSSL
9235
9235
  # Reads *length* bytes from the SSL connection. If a pre-allocated *buffer* is
9236
9236
  # provided the data will be written into it.
9237
9237
  #
9238
- def sysread: (Integer length, ?String buffer) -> String
9238
+ def sysread: (Integer length, ?String? buffer) -> String
9239
9239
 
9240
9240
  # <!--
9241
9241
  # rdoc-file=ext/openssl/ossl_ssl.c
@@ -134,7 +134,7 @@ class Resolv
134
134
  # DNS resolver. If `resolvers` is a hash, uses the hash as configuration for
135
135
  # the DNS resolver.
136
136
  #
137
- def initialize: (?Resolv::Hosts | Resolv::DNS resolvers) -> untyped
137
+ def initialize: (?(Array[Resolv::Hosts | Resolv::DNS] | Hash[Symbol, untyped])? resolvers, ?use_ipv6: bool?) -> untyped
138
138
  end
139
139
 
140
140
  # <!-- rdoc-file=lib/resolv.rb -->
@@ -191,7 +191,7 @@ module Shellwords
191
191
  end
192
192
 
193
193
  %a{annotate:rdoc:skip}
194
- class Array[unchecked out Elem]
194
+ class Array[unchecked out E]
195
195
  # <!--
196
196
  # rdoc-file=lib/shellwords.rb
197
197
  # - array.shelljoin => string
@@ -560,7 +560,8 @@ class StringIO
560
560
  #
561
561
  # Related: StringIO.new.
562
562
  #
563
- def self.open: [U] (?String string, ?String? mode) { (StringIO arg) -> U } -> U
563
+ def self.open: (?String string, ?String? mode) -> StringIO
564
+ | [U] (?String string, ?String? mode) { (StringIO arg) -> U } -> U
564
565
 
565
566
  def <<: (untyped arg0) -> self
566
567
 
@@ -970,7 +971,7 @@ class StringIO
970
971
  # -->
971
972
  # Raises NotImplementedError.
972
973
  #
973
- def fcntl: (Integer integer_cmd, String | Integer arg) -> Integer
974
+ def fcntl: (*untyped) -> bot
974
975
 
975
976
  # <!--
976
977
  # rdoc-file=ext/stringio/stringio.c
@@ -994,7 +995,7 @@ class StringIO
994
995
  # -->
995
996
  # Returns 0; for compatibility with IO.
996
997
  #
997
- def fsync: () -> Integer?
998
+ def fsync: () -> Integer
998
999
 
999
1000
  # <!--
1000
1001
  # rdoc-file=ext/stringio/stringio.c
@@ -1190,7 +1191,7 @@ class StringIO
1190
1191
  # -->
1191
1192
  # Returns `nil`; for compatibility with IO.
1192
1193
  #
1193
- def internal_encoding: () -> Encoding
1194
+ def internal_encoding: () -> nil
1194
1195
 
1195
1196
  # <!--
1196
1197
  # rdoc-file=ext/stringio/stringio.c
@@ -1207,7 +1208,7 @@ class StringIO
1207
1208
  # strio = StringIO.new(nil, 'w+')
1208
1209
  # strio.external_encoding # => nil
1209
1210
  #
1210
- def external_encoding: () -> Encoding
1211
+ def external_encoding: () -> Encoding?
1211
1212
 
1212
1213
  # <!--
1213
1214
  # rdoc-file=ext/stringio/stringio.c
@@ -1281,9 +1282,18 @@ class StringIO
1281
1282
  # -->
1282
1283
  # See IO#read.
1283
1284
  #
1284
- def read: (?int? length, ?string outbuf) -> String?
1285
+ def read: (?int? length, ?string? outbuf) -> String?
1285
1286
 
1286
- def read_nonblock: (int len, ?string buf) -> String
1287
+ # <!--
1288
+ # rdoc-file=ext/stringio/stringio.c
1289
+ # - pread(maxlen, offset) -> string
1290
+ # - pread(maxlen, offset, out_string) -> string
1291
+ # -->
1292
+ # See IO#pread.
1293
+ #
1294
+ def pread: (Integer maxlen, Integer offset, ?String? outbuf) -> String
1295
+
1296
+ def read_nonblock: (int len, ?string? buf, ?exception: bool) -> String?
1287
1297
 
1288
1298
  def readbyte: () -> Integer
1289
1299
 
@@ -1301,7 +1311,7 @@ class StringIO
1301
1311
  #
1302
1312
  def readlines: (?String sep, ?Integer limit, ?chomp: boolish) -> ::Array[String]
1303
1313
 
1304
- def readpartial: (int maxlen, ?string outbuf) -> String
1314
+ def readpartial: (int maxlen, ?string? outbuf) -> String
1305
1315
 
1306
1316
  # <!--
1307
1317
  # rdoc-file=ext/stringio/stringio.c
@@ -1358,6 +1368,16 @@ class StringIO
1358
1368
  def set_encoding: (?String | Encoding ext_or_ext_int_enc) -> self
1359
1369
  | (?String | Encoding ext_or_ext_int_enc, ?String | Encoding int_enc) -> self
1360
1370
 
1371
+ # <!--
1372
+ # rdoc-file=ext/stringio/stringio.c
1373
+ # - strio.set_encoding_by_bom => strio or nil
1374
+ # -->
1375
+ # Sets the encoding according to the BOM (Byte Order Mark) in the string.
1376
+ #
1377
+ # Returns `self` if the BOM is found, otherwise +nil.
1378
+ #
1379
+ def set_encoding_by_bom: () -> Encoding?
1380
+
1361
1381
  # <!--
1362
1382
  # rdoc-file=ext/stringio/stringio.c
1363
1383
  # - string -> string
@@ -1429,7 +1449,7 @@ class StringIO
1429
1449
  #
1430
1450
  def sync=: (boolish) -> bool
1431
1451
 
1432
- def sysread: (Integer maxlen, String outbuf) -> String
1452
+ def sysread: (Integer maxlen, ?String? outbuf) -> String
1433
1453
 
1434
1454
  def syswrite: (String arg0) -> Integer
1435
1455
 
@@ -1472,7 +1492,7 @@ class StringIO
1472
1492
  # Pushes back ("unshifts") a character or integer onto the stream; see
1473
1493
  # [Character IO](rdoc-ref:IO@Character+IO).
1474
1494
  #
1475
- def ungetc: (String arg0) -> nil
1495
+ def ungetc: (String | Integer arg0) -> nil
1476
1496
 
1477
1497
  # <!--
1478
1498
  # rdoc-file=ext/stringio/stringio.c
@@ -1485,6 +1505,8 @@ class StringIO
1485
1505
  #
1486
1506
  def write: (*_ToS) -> Integer
1487
1507
 
1508
+ def write_nonblock: (_ToS s, ?exception: bool) -> Integer
1509
+
1488
1510
  # This is a deprecated alias for #each_byte.
1489
1511
  #
1490
1512
  def bytes: () { (Integer arg0) -> untyped } -> self