rbs 4.0.0.dev.5 → 4.0.1.dev.1

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 (194) hide show
  1. checksums.yaml +4 -4
  2. data/.clang-format +1 -0
  3. data/.github/workflows/c-check.yml +8 -4
  4. data/.github/workflows/comments.yml +3 -1
  5. data/.github/workflows/dependabot.yml +1 -1
  6. data/.github/workflows/ruby.yml +10 -0
  7. data/.github/workflows/rust.yml +95 -0
  8. data/CHANGELOG.md +323 -0
  9. data/Rakefile +12 -29
  10. data/Steepfile +1 -0
  11. data/config.yml +393 -37
  12. data/core/array.rbs +218 -188
  13. data/core/basic_object.rbs +9 -8
  14. data/core/class.rbs +6 -5
  15. data/core/comparable.rbs +45 -31
  16. data/core/complex.rbs +52 -40
  17. data/core/dir.rbs +57 -45
  18. data/core/encoding.rbs +5 -5
  19. data/core/enumerable.rbs +96 -91
  20. data/core/enumerator.rbs +4 -3
  21. data/core/errno.rbs +3 -2
  22. data/core/errors.rbs +31 -29
  23. data/core/exception.rbs +12 -12
  24. data/core/fiber.rbs +36 -36
  25. data/core/file.rbs +186 -113
  26. data/core/file_test.rbs +2 -2
  27. data/core/float.rbs +41 -32
  28. data/core/gc.rbs +78 -70
  29. data/core/hash.rbs +70 -60
  30. data/core/integer.rbs +32 -28
  31. data/core/io/buffer.rbs +36 -36
  32. data/core/io/wait.rbs +7 -7
  33. data/core/io.rbs +120 -135
  34. data/core/kernel.rbs +189 -139
  35. data/core/marshal.rbs +3 -3
  36. data/core/match_data.rbs +14 -12
  37. data/core/math.rbs +69 -67
  38. data/core/method.rbs +6 -6
  39. data/core/module.rbs +146 -85
  40. data/core/nil_class.rbs +4 -3
  41. data/core/numeric.rbs +35 -32
  42. data/core/object.rbs +6 -8
  43. data/core/object_space.rbs +11 -10
  44. data/core/pathname.rbs +131 -81
  45. data/core/proc.rbs +65 -33
  46. data/core/process.rbs +219 -201
  47. data/core/ractor.rbs +15 -11
  48. data/core/random.rbs +4 -3
  49. data/core/range.rbs +52 -47
  50. data/core/rational.rbs +5 -5
  51. data/core/rbs/unnamed/argf.rbs +58 -51
  52. data/core/rbs/unnamed/env_class.rbs +18 -13
  53. data/core/rbs/unnamed/main_class.rbs +123 -0
  54. data/core/rbs/unnamed/random.rbs +7 -5
  55. data/core/regexp.rbs +236 -197
  56. data/core/ruby.rbs +1 -1
  57. data/core/ruby_vm.rbs +32 -30
  58. data/core/rubygems/config_file.rbs +5 -5
  59. data/core/rubygems/errors.rbs +1 -1
  60. data/core/rubygems/requirement.rbs +5 -5
  61. data/core/rubygems/rubygems.rbs +5 -3
  62. data/core/set.rbs +17 -16
  63. data/core/signal.rbs +2 -2
  64. data/core/string.rbs +311 -292
  65. data/core/struct.rbs +26 -25
  66. data/core/symbol.rbs +25 -24
  67. data/core/thread.rbs +40 -34
  68. data/core/time.rbs +47 -42
  69. data/core/trace_point.rbs +34 -31
  70. data/core/true_class.rbs +2 -2
  71. data/core/unbound_method.rbs +10 -10
  72. data/core/warning.rbs +7 -7
  73. data/docs/collection.md +1 -1
  74. data/docs/config.md +171 -0
  75. data/docs/inline.md +110 -4
  76. data/docs/syntax.md +13 -12
  77. data/ext/rbs_extension/ast_translation.c +489 -135
  78. data/ext/rbs_extension/class_constants.c +8 -0
  79. data/ext/rbs_extension/class_constants.h +4 -0
  80. data/ext/rbs_extension/legacy_location.c +28 -51
  81. data/ext/rbs_extension/legacy_location.h +37 -0
  82. data/ext/rbs_extension/main.c +12 -20
  83. data/include/rbs/ast.h +423 -195
  84. data/include/rbs/lexer.h +2 -2
  85. data/include/rbs/location.h +25 -44
  86. data/include/rbs/parser.h +2 -2
  87. data/include/rbs/util/rbs_constant_pool.h +0 -3
  88. data/include/rbs.h +8 -0
  89. data/lib/rbs/ast/ruby/annotations.rb +157 -4
  90. data/lib/rbs/ast/ruby/members.rb +374 -22
  91. data/lib/rbs/cli/validate.rb +5 -60
  92. data/lib/rbs/collection/config/lockfile_generator.rb +6 -2
  93. data/lib/rbs/definition_builder.rb +60 -27
  94. data/lib/rbs/errors.rb +0 -11
  95. data/lib/rbs/inline_parser.rb +1 -1
  96. data/lib/rbs/parser_aux.rb +20 -7
  97. data/lib/rbs/prototype/helpers.rb +57 -0
  98. data/lib/rbs/prototype/rb.rb +1 -26
  99. data/lib/rbs/prototype/rbi.rb +1 -20
  100. data/lib/rbs/test/type_check.rb +3 -0
  101. data/lib/rbs/types.rb +62 -52
  102. data/lib/rbs/unit_test/type_assertions.rb +35 -8
  103. data/lib/rbs/version.rb +1 -1
  104. data/lib/rbs.rb +0 -1
  105. data/rbs.gemspec +1 -1
  106. data/rust/.gitignore +1 -0
  107. data/rust/Cargo.lock +378 -0
  108. data/rust/Cargo.toml +7 -0
  109. data/rust/ruby-rbs/Cargo.toml +22 -0
  110. data/rust/ruby-rbs/build.rs +764 -0
  111. data/rust/ruby-rbs/examples/locations.rs +60 -0
  112. data/rust/ruby-rbs/src/lib.rs +1 -0
  113. data/rust/ruby-rbs/src/node/mod.rs +742 -0
  114. data/rust/ruby-rbs/tests/sanity.rs +47 -0
  115. data/rust/ruby-rbs/vendor/rbs/config.yml +1 -0
  116. data/rust/ruby-rbs-sys/Cargo.toml +23 -0
  117. data/rust/ruby-rbs-sys/build.rs +204 -0
  118. data/rust/ruby-rbs-sys/src/lib.rs +50 -0
  119. data/rust/ruby-rbs-sys/vendor/rbs/include +1 -0
  120. data/rust/ruby-rbs-sys/vendor/rbs/src +1 -0
  121. data/rust/ruby-rbs-sys/wrapper.h +1 -0
  122. data/sig/ast/ruby/annotations.rbs +191 -4
  123. data/sig/ast/ruby/members.rbs +21 -1
  124. data/sig/cli/validate.rbs +1 -6
  125. data/sig/definition_builder.rbs +2 -0
  126. data/sig/errors.rbs +0 -8
  127. data/sig/method_types.rbs +1 -1
  128. data/sig/parser.rbs +17 -13
  129. data/sig/prototype/helpers.rbs +2 -0
  130. data/sig/types.rbs +10 -11
  131. data/sig/unit_test/spy.rbs +0 -8
  132. data/sig/unit_test/type_assertions.rbs +11 -0
  133. data/src/ast.c +339 -161
  134. data/src/lexstate.c +1 -1
  135. data/src/location.c +7 -47
  136. data/src/parser.c +674 -480
  137. data/src/util/rbs_constant_pool.c +0 -4
  138. data/stdlib/bigdecimal/0/big_decimal.rbs +16 -16
  139. data/stdlib/cgi-escape/0/escape.rbs +4 -4
  140. data/stdlib/coverage/0/coverage.rbs +4 -3
  141. data/stdlib/date/0/date.rbs +33 -28
  142. data/stdlib/date/0/date_time.rbs +24 -23
  143. data/stdlib/did_you_mean/0/did_you_mean.rbs +17 -16
  144. data/stdlib/erb/0/erb.rbs +64 -53
  145. data/stdlib/etc/0/etc.rbs +55 -50
  146. data/stdlib/fileutils/0/fileutils.rbs +138 -125
  147. data/stdlib/forwardable/0/forwardable.rbs +10 -10
  148. data/stdlib/io-console/0/io-console.rbs +2 -2
  149. data/stdlib/json/0/json.rbs +135 -108
  150. data/stdlib/monitor/0/monitor.rbs +3 -3
  151. data/stdlib/net-http/0/net-http.rbs +159 -134
  152. data/stdlib/objspace/0/objspace.rbs +8 -7
  153. data/stdlib/open-uri/0/open-uri.rbs +8 -8
  154. data/stdlib/open3/0/open3.rbs +36 -35
  155. data/stdlib/openssl/0/openssl.rbs +144 -129
  156. data/stdlib/optparse/0/optparse.rbs +18 -14
  157. data/stdlib/pathname/0/pathname.rbs +2 -2
  158. data/stdlib/pp/0/pp.rbs +9 -8
  159. data/stdlib/prettyprint/0/prettyprint.rbs +7 -7
  160. data/stdlib/pstore/0/pstore.rbs +35 -30
  161. data/stdlib/psych/0/psych.rbs +61 -8
  162. data/stdlib/psych/0/store.rbs +2 -4
  163. data/stdlib/pty/0/pty.rbs +9 -6
  164. data/stdlib/random-formatter/0/random-formatter.rbs +2 -2
  165. data/stdlib/ripper/0/ripper.rbs +20 -17
  166. data/stdlib/securerandom/0/securerandom.rbs +1 -1
  167. data/stdlib/shellwords/0/shellwords.rbs +2 -2
  168. data/stdlib/socket/0/addrinfo.rbs +7 -7
  169. data/stdlib/socket/0/basic_socket.rbs +3 -3
  170. data/stdlib/socket/0/ip_socket.rbs +10 -8
  171. data/stdlib/socket/0/socket.rbs +10 -9
  172. data/stdlib/socket/0/tcp_server.rbs +1 -1
  173. data/stdlib/socket/0/tcp_socket.rbs +1 -1
  174. data/stdlib/socket/0/udp_socket.rbs +1 -1
  175. data/stdlib/socket/0/unix_server.rbs +1 -1
  176. data/stdlib/stringio/0/stringio.rbs +55 -54
  177. data/stdlib/strscan/0/string_scanner.rbs +46 -44
  178. data/stdlib/tempfile/0/tempfile.rbs +24 -20
  179. data/stdlib/time/0/time.rbs +7 -5
  180. data/stdlib/tsort/0/tsort.rbs +7 -6
  181. data/stdlib/uri/0/common.rbs +26 -18
  182. data/stdlib/uri/0/file.rbs +2 -2
  183. data/stdlib/uri/0/generic.rbs +2 -2
  184. data/stdlib/uri/0/http.rbs +2 -2
  185. data/stdlib/uri/0/ldap.rbs +2 -2
  186. data/stdlib/uri/0/mailto.rbs +3 -3
  187. data/stdlib/uri/0/rfc2396_parser.rbs +6 -5
  188. data/stdlib/zlib/0/deflate.rbs +4 -3
  189. data/stdlib/zlib/0/gzip_reader.rbs +4 -4
  190. data/stdlib/zlib/0/gzip_writer.rbs +14 -12
  191. data/stdlib/zlib/0/inflate.rbs +1 -1
  192. data/stdlib/zlib/0/need_dict.rbs +1 -1
  193. metadata +23 -5
  194. data/.github/workflows/valgrind.yml +0 -42
data/core/module.rbs CHANGED
@@ -6,7 +6,7 @@
6
6
  # methods may not. (See Module#module_function.)
7
7
  #
8
8
  # In the descriptions that follow, the parameter *sym* refers to a symbol, which
9
- # is either a quoted string or a Symbol (such as `:name`).
9
+ # is either a quoted string or a Symbol (such as <code>:name</code>).
10
10
  #
11
11
  # module Mod
12
12
  # include Math
@@ -79,7 +79,7 @@ class Module < Object
79
79
  # using B
80
80
  # p Module.used_modules
81
81
  #
82
- # *produces:*
82
+ # <em>produces:</em>
83
83
  #
84
84
  # [B, A]
85
85
  #
@@ -106,7 +106,7 @@ class Module < Object
106
106
  # using B
107
107
  # p Module.used_refinements
108
108
  #
109
- # *produces:*
109
+ # <em>produces:</em>
110
110
  #
111
111
  # [#<refinement:Object@B>, #<refinement:Object@A>]
112
112
  #
@@ -144,7 +144,8 @@ class Module < Object
144
144
  #
145
145
  # Returns:
146
146
  #
147
- # * `-1`, if `self` includes `other`, if or `self` is a subclass of `other`.
147
+ # * <code>-1</code>, if `self` includes `other`, if or `self` is a subclass of
148
+ # `other`.
148
149
  # * `0`, if `self` and `other` are the same.
149
150
  # * `1`, if `other` includes `self`, or if `other` is a subclass of `self`.
150
151
  # * `nil`, if none of the above is true.
@@ -175,8 +176,8 @@ class Module < Object
175
176
  # classes to provide class-specific meaning.
176
177
  #
177
178
  # Unlike #==, the #equal? method should never be overridden by subclasses as it
178
- # is used to determine object identity (that is, `a.equal?(b)` if and only if
179
- # `a` is the same object as `b`):
179
+ # is used to determine object identity (that is, <code>a.equal?(b)</code> if and
180
+ # only if `a` is the same object as `b`):
180
181
  #
181
182
  # obj = "a"
182
183
  # other = obj.dup
@@ -249,7 +250,7 @@ class Module < Object
249
250
  # include Mod
250
251
  # exit(99)
251
252
  #
252
- # *produces:*
253
+ # <em>produces:</em>
253
254
  #
254
255
  # Exiting with code 99
255
256
  #
@@ -284,7 +285,7 @@ class Module < Object
284
285
  # module to *mod* if this module has not already been added to *mod* or one of
285
286
  # its ancestors. See also Module#include.
286
287
  #
287
- def append_features: (Module arg0) -> self
288
+ private def append_features: (Module arg0) -> self
288
289
 
289
290
  # <!--
290
291
  # rdoc-file=object.c
@@ -292,10 +293,10 @@ class Module < Object
292
293
  # - attr_accessor(string, ...) -> array
293
294
  # -->
294
295
  # Defines a named attribute for this module, where the name is
295
- # *symbol.*`id2name`, creating an instance variable (`@name`) and a
296
- # corresponding access method to read it. Also creates a method called `name=`
297
- # to set the attribute. String arguments are converted to symbols. Returns an
298
- # array of defined method names as symbols.
296
+ # <em>symbol.</em>`id2name`, creating an instance variable (<code>@name</code>)
297
+ # and a corresponding access method to read it. Also creates a method called
298
+ # <code>name=</code> to set the attribute. String arguments are converted to
299
+ # symbols. Returns an array of defined method names as symbols.
299
300
  #
300
301
  # module Mod
301
302
  # attr_accessor(:one, :two) #=> [:one, :one=, :two, :two=]
@@ -312,8 +313,8 @@ class Module < Object
312
313
  # - attr(string, ...) -> array
313
314
  # -->
314
315
  # Creates instance variables and corresponding methods that return the value of
315
- # each instance variable. Equivalent to calling ```attr`*:name*'' on each name
316
- # in turn. String arguments are converted to symbols. Returns an array of
316
+ # each instance variable. Equivalent to calling ```attr`<em>:name</em>'' on each
317
+ # name in turn. String arguments are converted to symbols. Returns an array of
317
318
  # defined method names as symbols.
318
319
  #
319
320
  def attr_reader: (*interned arg0) -> Array[Symbol]
@@ -324,8 +325,8 @@ class Module < Object
324
325
  # - attr_writer(string, ...) -> array
325
326
  # -->
326
327
  # Creates an accessor method to allow assignment to the attribute
327
- # *symbol*`.id2name`. String arguments are converted to symbols. Returns an
328
- # array of defined method names as symbols.
328
+ # *symbol*<code>.id2name</code>. String arguments are converted to symbols.
329
+ # Returns an array of defined method names as symbols.
329
330
  #
330
331
  def attr_writer: (*interned arg0) -> Array[Symbol]
331
332
 
@@ -390,7 +391,7 @@ class Module < Object
390
391
  # puts Thing.new.hello()
391
392
  # Thing.module_eval("invalid code", "dummy", 123)
392
393
  #
393
- # *produces:*
394
+ # <em>produces:</em>
394
395
  #
395
396
  # Hello there!
396
397
  # dummy:123:in `module_eval': undefined local variable
@@ -412,7 +413,7 @@ class Module < Object
412
413
  # }
413
414
  # puts Thing.new.hello()
414
415
  #
415
- # *produces:*
416
+ # <em>produces:</em>
416
417
  #
417
418
  # Hello there!
418
419
  #
@@ -440,8 +441,8 @@ class Module < Object
440
441
  # - mod.class_variable_get(string) -> obj
441
442
  # -->
442
443
  # Returns the value of the given class variable (or throws a NameError
443
- # exception). The `@@` part of the variable name should be included for regular
444
- # class variables. String arguments are converted to symbols.
444
+ # exception). The <code>@@</code> part of the variable name should be included
445
+ # for regular class variables. String arguments are converted to symbols.
445
446
  #
446
447
  # class Fred
447
448
  # @@foo = 99
@@ -503,7 +504,7 @@ class Module < Object
503
504
  # FOO = 1
504
505
  # end
505
506
  #
506
- # *produces:*
507
+ # <em>produces:</em>
507
508
  #
508
509
  # Added :FOO
509
510
  #
@@ -527,12 +528,12 @@ class Module < Object
527
528
  # end
528
529
  # end
529
530
  #
530
- # *produces:*
531
+ # <em>produces:</em>
531
532
  #
532
533
  # :const_added
533
534
  # :inherited
534
535
  #
535
- def const_added: (Symbol) -> void
536
+ private def const_added: (Symbol) -> void
536
537
 
537
538
  # <!--
538
539
  # rdoc-file=object.c
@@ -635,10 +636,11 @@ class Module < Object
635
636
  #
636
637
  # In the next example, when a reference is made to an undefined constant,
637
638
  # `const_missing` attempts to load a file whose path is the lowercase version of
638
- # the constant name (thus class `Fred` is assumed to be in file `fred.rb`). If
639
- # defined as a side-effect of loading the file, the method returns the value
640
- # stored in the constant. This implements an autoload feature similar to
641
- # Kernel#autoload and Module#autoload, though it differs in important ways.
639
+ # the constant name (thus class `Fred` is assumed to be in file
640
+ # <code>fred.rb</code>). If defined as a side-effect of loading the file, the
641
+ # method returns the value stored in the constant. This implements an autoload
642
+ # feature similar to Kernel#autoload and Module#autoload, though it differs in
643
+ # important ways.
642
644
  #
643
645
  # def Object.const_missing(name)
644
646
  # @looked_for ||= {}
@@ -680,7 +682,8 @@ class Module < Object
680
682
  # If the constant is found, but its source location can not be extracted
681
683
  # (constant is defined in C code), empty array is returned.
682
684
  #
683
- # *inherit* specifies whether to lookup in `mod.ancestors` (`true` by default).
685
+ # *inherit* specifies whether to lookup in <code>mod.ancestors</code> (`true` by
686
+ # default).
684
687
  #
685
688
  # # test.rb:
686
689
  # class A # line 1
@@ -769,7 +772,7 @@ class Module < Object
769
772
  # a.create_method(:betty) { p self }
770
773
  # a.betty
771
774
  #
772
- # *produces:*
775
+ # <em>produces:</em>
773
776
  #
774
777
  # In Fred
775
778
  # Charge it!
@@ -821,12 +824,12 @@ class Module < Object
821
824
  # (s = Array.new).extend Picky # Call Object.extend
822
825
  # (s = "quick brown fox").extend Picky
823
826
  #
824
- # *produces:*
827
+ # <em>produces:</em>
825
828
  #
826
829
  # Picky added to Array
827
830
  # Can't add Picky to a String
828
831
  #
829
- def extend_object: (untyped arg0) -> untyped
832
+ private def extend_object: (untyped arg0) -> untyped
830
833
 
831
834
  # <!--
832
835
  # rdoc-file=object.c
@@ -844,7 +847,7 @@ class Module < Object
844
847
  # end
845
848
  # # => prints "A extended in Enumerable"
846
849
  #
847
- def extended: (Module othermod) -> untyped
850
+ private def extended: (Module othermod) -> untyped
848
851
 
849
852
  # <!--
850
853
  # rdoc-file=object.c
@@ -889,8 +892,8 @@ class Module < Object
889
892
  # - included(othermod)
890
893
  # -->
891
894
  # Callback invoked whenever the receiver is included in another module or class.
892
- # This should be used in preference to `Module.append_features` if your code
893
- # wants to perform some action when a module is included in another.
895
+ # This should be used in preference to <code>Module.append_features</code> if
896
+ # your code wants to perform some action when a module is included in another.
894
897
  #
895
898
  # module A
896
899
  # def A.included(mod)
@@ -902,7 +905,7 @@ class Module < Object
902
905
  # end
903
906
  # # => prints "A included in Enumerable"
904
907
  #
905
- def included: (Module othermod) -> untyped
908
+ private def included: (Module othermod) -> untyped
906
909
 
907
910
  # <!--
908
911
  # rdoc-file=object.c
@@ -980,7 +983,7 @@ class Module < Object
980
983
  # interpreter = Interpreter.new
981
984
  # interpreter.interpret('dave')
982
985
  #
983
- # *produces:*
986
+ # <em>produces:</em>
984
987
  #
985
988
  # Hello there, Dave!
986
989
  #
@@ -1037,11 +1040,11 @@ class Module < Object
1037
1040
  # def some_instance_method() end
1038
1041
  # end
1039
1042
  #
1040
- # *produces:*
1043
+ # <em>produces:</em>
1041
1044
  #
1042
1045
  # Adding :some_instance_method
1043
1046
  #
1044
- def method_added: (Symbol meth) -> untyped
1047
+ private def method_added: (Symbol meth) -> untyped
1045
1048
 
1046
1049
  # <!--
1047
1050
  # rdoc-file=vm_method.c
@@ -1098,11 +1101,36 @@ class Module < Object
1098
1101
  # remove_method :some_instance_method
1099
1102
  # end
1100
1103
  #
1101
- # *produces:*
1104
+ # <em>produces:</em>
1102
1105
  #
1103
1106
  # Removing :some_instance_method
1104
1107
  #
1105
- def method_removed: (Symbol method_name) -> untyped
1108
+ private def method_removed: (Symbol method_name) -> untyped
1109
+
1110
+ # <!--
1111
+ # rdoc-file=object.c
1112
+ # - method_undefined(method_name)
1113
+ # -->
1114
+ # Invoked as a callback whenever an instance method is undefined from the
1115
+ # receiver.
1116
+ #
1117
+ # module Chatty
1118
+ # def self.method_undefined(method_name)
1119
+ # puts "Undefining #{method_name.inspect}"
1120
+ # end
1121
+ # def self.some_class_method() end
1122
+ # def some_instance_method() end
1123
+ # class << self
1124
+ # undef_method :some_class_method
1125
+ # end
1126
+ # undef_method :some_instance_method
1127
+ # end
1128
+ #
1129
+ # <em>produces:</em>
1130
+ #
1131
+ # Undefining :some_instance_method
1132
+ #
1133
+ private def method_undefined: (Symbol method_name) -> untyped
1106
1134
 
1107
1135
  # <!--
1108
1136
  # rdoc-file=vm_eval.c
@@ -1124,7 +1152,7 @@ class Module < Object
1124
1152
  # puts Thing.new.hello()
1125
1153
  # Thing.module_eval("invalid code", "dummy", 123)
1126
1154
  #
1127
- # *produces:*
1155
+ # <em>produces:</em>
1128
1156
  #
1129
1157
  # Hello there!
1130
1158
  # dummy:123:in `module_eval': undefined local variable
@@ -1150,7 +1178,7 @@ class Module < Object
1150
1178
  # }
1151
1179
  # puts Thing.new.hello()
1152
1180
  #
1153
- # *produces:*
1181
+ # <em>produces:</em>
1154
1182
  #
1155
1183
  # Hello there!
1156
1184
  #
@@ -1195,11 +1223,11 @@ class Module < Object
1195
1223
  # Mod.one #=> "This is one"
1196
1224
  # c.call_one #=> "This is the new one"
1197
1225
  #
1198
- def module_function: () -> nil
1199
- | (Symbol method_name) -> Symbol
1200
- | (Symbol, Symbol, *Symbol method_name) -> Array[Symbol]
1201
- | (string method_name) -> string
1202
- | (interned, interned, *interned method_name) -> Array[interned]
1226
+ private def module_function: () -> nil
1227
+ | (Symbol method_name) -> Symbol
1228
+ | (Symbol, Symbol, *Symbol method_name) -> Array[Symbol]
1229
+ | (string method_name) -> string
1230
+ | (interned, interned, *interned method_name) -> Array[interned]
1203
1231
 
1204
1232
  # <!--
1205
1233
  # rdoc-file=object.c
@@ -1227,7 +1255,7 @@ class Module < Object
1227
1255
  # this module to *mod* if this module has not already been added to *mod* or one
1228
1256
  # of its ancestors. See also Module#prepend.
1229
1257
  #
1230
- def prepend_features: (Module arg0) -> self
1258
+ private def prepend_features: (Module arg0) -> self
1231
1259
 
1232
1260
  # <!--
1233
1261
  # rdoc-file=object.c
@@ -1245,7 +1273,7 @@ class Module < Object
1245
1273
  # end
1246
1274
  # # => prints "A prepended to Enumerable"
1247
1275
  #
1248
- def prepended: (Module othermod) -> untyped
1276
+ private def prepended: (Module othermod) -> untyped
1249
1277
 
1250
1278
  # <!--
1251
1279
  # rdoc-file=vm_method.c
@@ -1270,14 +1298,14 @@ class Module < Object
1270
1298
  # end
1271
1299
  # Mod.private_instance_methods #=> [:a, :c]
1272
1300
  #
1273
- # Note that to show a private method on RDoc, use `:doc:`.
1301
+ # Note that to show a private method on RDoc, use <code>:doc:</code>.
1274
1302
  #
1275
- def private: () -> nil
1276
- | (Symbol method_name) -> Symbol
1277
- | (Symbol, Symbol, *Symbol method_name) -> Array[Symbol]
1278
- | (string method_name) -> string
1279
- | (interned, interned, *interned method_name) -> Array[interned]
1280
- | (Array[interned]) -> Array[interned]
1303
+ private def private: () -> nil
1304
+ | (Symbol method_name) -> Symbol
1305
+ | (Symbol, Symbol, *Symbol method_name) -> Array[Symbol]
1306
+ | (string method_name) -> string
1307
+ | (interned, interned, *interned method_name) -> Array[interned]
1308
+ | (Array[interned]) -> Array[interned]
1281
1309
 
1282
1310
  # <!--
1283
1311
  # rdoc-file=vm_method.c
@@ -1378,9 +1406,9 @@ class Module < Object
1378
1406
  # Marking a method as protected allows **different objects of the same class**
1379
1407
  # to call it.
1380
1408
  #
1381
- # One use case is for comparison methods, such as `==`, if we want to expose a
1382
- # method for comparison between objects of the same class without making the
1383
- # method public to objects of other classes.
1409
+ # One use case is for comparison methods, such as <code>==</code>, if we want to
1410
+ # expose a method for comparison between objects of the same class without
1411
+ # making the method public to objects of other classes.
1384
1412
  #
1385
1413
  # ## Performance considerations
1386
1414
  #
@@ -1411,14 +1439,14 @@ class Module < Object
1411
1439
  # account1 > account2 # => true (works)
1412
1440
  # account1.balance # => NoMethodError (fails because balance is not public)
1413
1441
  #
1414
- # To show a private method on RDoc, use `:doc:` instead of this.
1442
+ # To show a private method on RDoc, use <code>:doc:</code> instead of this.
1415
1443
  #
1416
- def protected: () -> nil
1417
- | (Symbol method_name) -> Symbol
1418
- | (Symbol, Symbol, *Symbol method_name) -> Array[Symbol]
1419
- | (string method_name) -> string
1420
- | (interned, interned, *interned method_name) -> Array[interned]
1421
- | (Array[interned]) -> Array[interned]
1444
+ private def protected: () -> nil
1445
+ | (Symbol method_name) -> Symbol
1446
+ | (Symbol, Symbol, *Symbol method_name) -> Array[Symbol]
1447
+ | (string method_name) -> string
1448
+ | (interned, interned, *interned method_name) -> Array[interned]
1449
+ | (Array[interned]) -> Array[interned]
1422
1450
 
1423
1451
  # <!--
1424
1452
  # rdoc-file=object.c
@@ -1473,12 +1501,12 @@ class Module < Object
1473
1501
  # returned. If no argument is passed, nil is returned. If multiple arguments are
1474
1502
  # passed, the arguments are returned as an array.
1475
1503
  #
1476
- def public: () -> nil
1477
- | (Symbol method_name) -> Symbol
1478
- | (Symbol, Symbol, *Symbol method_name) -> Array[Symbol]
1479
- | (string method_name) -> string
1480
- | (interned, interned, *interned method_name) -> Array[interned]
1481
- | (Array[interned]) -> Array[interned]
1504
+ private def public: () -> nil
1505
+ | (Symbol method_name) -> Symbol
1506
+ | (Symbol, Symbol, *Symbol method_name) -> Array[Symbol]
1507
+ | (string method_name) -> string
1508
+ | (interned, interned, *interned method_name) -> Array[interned]
1509
+ | (Array[interned]) -> Array[interned]
1482
1510
 
1483
1511
  # <!--
1484
1512
  # rdoc-file=vm_method.c
@@ -1557,7 +1585,7 @@ class Module < Object
1557
1585
  #
1558
1586
  # Returns a module, where refined methods are defined.
1559
1587
  #
1560
- def refine: (Module mod) { () [self: Refinement] -> void } -> Refinement
1588
+ private def refine: (Module mod) { () [self: Refinement] -> void } -> Refinement
1561
1589
 
1562
1590
  # <!--
1563
1591
  # rdoc-file=eval.c
@@ -1575,7 +1603,7 @@ class Module < Object
1575
1603
  #
1576
1604
  # p A.refinements
1577
1605
  #
1578
- # *produces:*
1606
+ # <em>produces:</em>
1579
1607
  #
1580
1608
  # [#<refinement:Integer@A>, #<refinement:String@A>]
1581
1609
  #
@@ -1594,7 +1622,7 @@ class Module < Object
1594
1622
  # p(defined? @@var)
1595
1623
  # end
1596
1624
  #
1597
- # *produces:*
1625
+ # <em>produces:</em>
1598
1626
  #
1599
1627
  # 99
1600
1628
  # nil
@@ -1609,7 +1637,7 @@ class Module < Object
1609
1637
  # previous value. If that constant referred to a module, this will not change
1610
1638
  # that module's name and can lead to confusion.
1611
1639
  #
1612
- def remove_const: (interned arg0) -> untyped
1640
+ private def remove_const: (interned arg0) -> untyped
1613
1641
 
1614
1642
  # <!--
1615
1643
  # rdoc-file=vm_method.c
@@ -1621,6 +1649,43 @@ class Module < Object
1621
1649
  #
1622
1650
  def remove_method: (*interned arg0) -> self
1623
1651
 
1652
+ # <!--
1653
+ # rdoc-file=vm_method.c
1654
+ # - ruby2_keywords(method_name, ...) -> nil
1655
+ # -->
1656
+ # For the given method names, marks the method as passing keywords through a
1657
+ # normal argument splat. This should only be called on methods that accept an
1658
+ # argument splat (<code>*args</code>) but not explicit keywords or a keyword
1659
+ # splat. It marks the method such that if the method is called with keyword
1660
+ # arguments, the final hash argument is marked with a special flag such that if
1661
+ # it is the final element of a normal argument splat to another method call, and
1662
+ # that method call does not include explicit keywords or a keyword splat, the
1663
+ # final element is interpreted as keywords. In other words, keywords will be
1664
+ # passed through the method to other methods.
1665
+ #
1666
+ # This should only be used for methods that delegate keywords to another method,
1667
+ # and only for backwards compatibility with Ruby versions before 3.0. See
1668
+ # https://www.ruby-lang.org/en/news/2019/12/12/separation-of-positional-and-keyw
1669
+ # ord-arguments-in-ruby-3-0/ for details on why `ruby2_keywords` exists and when
1670
+ # and how to use it.
1671
+ #
1672
+ # This method will probably be removed at some point, as it exists only for
1673
+ # backwards compatibility. As it does not exist in Ruby versions before 2.7,
1674
+ # check that the module responds to this method before calling it:
1675
+ #
1676
+ # module Mod
1677
+ # def foo(meth, *args, &block)
1678
+ # send(:"do_#{meth}", *args, &block)
1679
+ # end
1680
+ # ruby2_keywords(:foo) if respond_to?(:ruby2_keywords, true)
1681
+ # end
1682
+ #
1683
+ # However, be aware that if the `ruby2_keywords` method is removed, the behavior
1684
+ # of the `foo` method using the above approach will change so that the method
1685
+ # does not pass through keywords.
1686
+ #
1687
+ private def ruby2_keywords: (*interned method_name) -> nil
1688
+
1624
1689
  # <!--
1625
1690
  # rdoc-file=object.c
1626
1691
  # - mod.set_temporary_name(string) -> self
@@ -1728,7 +1793,7 @@ class Module < Object
1728
1793
  # end
1729
1794
  # c.hello
1730
1795
  #
1731
- # *produces:*
1796
+ # <em>produces:</em>
1732
1797
  #
1733
1798
  # In child
1734
1799
  # In parent
@@ -1752,7 +1817,7 @@ class Module < Object
1752
1817
  # Import class refinements from *module* into the current class or module
1753
1818
  # definition.
1754
1819
  #
1755
- def using: (Module arg0) -> self
1820
+ private def using: (Module arg0) -> self
1756
1821
 
1757
1822
  # <!-- rdoc-file=object.c -->
1758
1823
  # Returns a string representing this module or class. For basic classes and
@@ -1768,14 +1833,10 @@ class Module < Object
1768
1833
  # - attr(name, false) -> array
1769
1834
  # -->
1770
1835
  # The first form is equivalent to #attr_reader. The second form is equivalent to
1771
- # `attr_accessor(name)` but deprecated. The last form is equivalent to
1772
- # `attr_reader(name)` but deprecated. Returns an array of defined method names
1773
- # as symbols.
1836
+ # <code>attr_accessor(name)</code> but deprecated. The last form is equivalent
1837
+ # to <code>attr_reader(name)</code> but deprecated. Returns an array of defined
1838
+ # method names as symbols.
1774
1839
  #
1775
1840
  def attr: %a{deprecated} (interned, bool) -> Array[Symbol]
1776
1841
  | (*interned arg0) -> Array[Symbol]
1777
-
1778
- # A previous incarnation of `interned` for backward-compatibility (see #1499)
1779
- %a{deprecated: Use `interned`}
1780
- type id = interned
1781
1842
  end
data/core/nil_class.rbs CHANGED
@@ -19,7 +19,7 @@
19
19
  # * #to_s
20
20
  #
21
21
  # While `nil` doesn't have an explicitly defined #to_hash method, it can be used
22
- # in `**` unpacking, not adding any keyword arguments.
22
+ # in <code>**</code> unpacking, not adding any keyword arguments.
23
23
  #
24
24
  # Another method provides inspection:
25
25
  #
@@ -97,7 +97,7 @@ class NilClass
97
97
  # rdoc-file=object.c
98
98
  # - inspect -> 'nil'
99
99
  # -->
100
- # Returns string `'nil'`:
100
+ # Returns string <code>'nil'</code>:
101
101
  #
102
102
  # nil.inspect # => "nil"
103
103
  #
@@ -107,7 +107,8 @@ class NilClass
107
107
  # rdoc-file=object.c
108
108
  # - nil.nil? -> true
109
109
  # -->
110
- # Returns `true`. For all other objects, method `nil?` returns `false`.
110
+ # Returns `true`. For all other objects, method <code>nil?</code> returns
111
+ # `false`.
111
112
  #
112
113
  def nil?: () -> true
113
114