rbs 3.10.4 → 4.0.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.
- checksums.yaml +4 -4
- data/.github/dependabot.yml +14 -14
- data/.github/workflows/bundle-update.yml +60 -0
- data/.github/workflows/c-check.yml +7 -5
- data/.github/workflows/comments.yml +2 -2
- data/.github/workflows/dependabot.yml +2 -2
- data/.github/workflows/ruby.yml +16 -26
- data/.github/workflows/rust.yml +95 -0
- data/.github/workflows/typecheck.yml +1 -1
- data/.github/workflows/windows.yml +2 -2
- data/.rubocop.yml +2 -2
- data/.vscode/extensions.json +5 -0
- data/.vscode/settings.json +19 -0
- data/CHANGELOG.md +202 -2
- data/Rakefile +9 -23
- data/Steepfile +2 -0
- data/config.yml +457 -13
- data/core/array.rbs +218 -188
- data/core/basic_object.rbs +9 -8
- data/core/binding.rbs +0 -2
- data/core/builtin.rbs +2 -2
- data/core/class.rbs +6 -5
- data/core/comparable.rbs +45 -31
- data/core/complex.rbs +66 -55
- data/core/dir.rbs +57 -45
- data/core/encoding.rbs +6 -6
- data/core/enumerable.rbs +105 -91
- data/core/enumerator/arithmetic_sequence.rbs +70 -0
- data/core/enumerator.rbs +24 -3
- data/core/errno.rbs +3 -2
- data/core/errors.rbs +31 -29
- data/core/exception.rbs +12 -12
- data/core/fiber.rbs +47 -36
- data/core/file.rbs +242 -169
- data/core/file_test.rbs +2 -2
- data/core/float.rbs +42 -68
- data/core/gc.rbs +78 -70
- data/core/hash.rbs +70 -60
- data/core/integer.rbs +32 -75
- data/core/io/buffer.rbs +36 -36
- data/core/io/wait.rbs +7 -7
- data/core/io.rbs +192 -146
- data/core/kernel.rbs +198 -147
- data/core/marshal.rbs +3 -3
- data/core/match_data.rbs +14 -12
- data/core/math.rbs +69 -67
- data/core/method.rbs +6 -8
- data/core/module.rbs +148 -88
- data/core/nil_class.rbs +4 -3
- data/core/numeric.rbs +53 -50
- data/core/object.rbs +6 -8
- data/core/object_space.rbs +11 -10
- data/core/pathname.rbs +131 -81
- data/core/proc.rbs +65 -34
- data/core/process.rbs +221 -201
- data/core/ractor.rbs +15 -11
- data/core/random.rbs +21 -3
- data/core/range.rbs +152 -49
- data/core/rational.rbs +5 -56
- data/core/rbs/unnamed/argf.rbs +58 -51
- data/core/rbs/unnamed/env_class.rbs +18 -13
- data/core/rbs/unnamed/main_class.rbs +123 -0
- data/core/rbs/unnamed/random.rbs +7 -116
- data/core/regexp.rbs +236 -197
- data/core/ruby.rbs +1 -1
- data/core/ruby_vm.rbs +32 -30
- data/core/rubygems/config_file.rbs +5 -5
- data/core/rubygems/errors.rbs +1 -1
- data/core/rubygems/requirement.rbs +5 -5
- data/core/rubygems/rubygems.rbs +5 -3
- data/core/set.rbs +17 -16
- data/core/signal.rbs +2 -2
- data/core/string.rbs +318 -298
- data/core/struct.rbs +26 -25
- data/core/symbol.rbs +25 -24
- data/core/thread.rbs +40 -41
- data/core/time.rbs +47 -42
- data/core/trace_point.rbs +34 -31
- data/core/true_class.rbs +2 -2
- data/core/unbound_method.rbs +10 -10
- data/core/warning.rbs +7 -7
- data/docs/collection.md +1 -1
- data/docs/config.md +171 -0
- data/docs/inline.md +576 -0
- data/docs/syntax.md +46 -16
- data/docs/type_fingerprint.md +21 -0
- data/exe/rbs +1 -1
- data/ext/rbs_extension/ast_translation.c +595 -98
- data/ext/rbs_extension/class_constants.c +30 -0
- data/ext/rbs_extension/class_constants.h +15 -0
- data/ext/rbs_extension/legacy_location.c +30 -53
- data/ext/rbs_extension/legacy_location.h +37 -0
- data/ext/rbs_extension/main.c +125 -24
- data/include/rbs/ast.h +485 -150
- data/include/rbs/lexer.h +11 -4
- data/include/rbs/location.h +25 -44
- data/include/rbs/parser.h +20 -2
- data/include/rbs/util/rbs_constant_pool.h +0 -3
- data/include/rbs.h +8 -0
- data/lib/rbs/ast/annotation.rb +1 -1
- data/lib/rbs/ast/comment.rb +1 -1
- data/lib/rbs/ast/declarations.rb +10 -10
- data/lib/rbs/ast/members.rb +14 -14
- data/lib/rbs/ast/ruby/annotations.rb +409 -0
- data/lib/rbs/ast/ruby/comment_block.rb +245 -0
- data/lib/rbs/ast/ruby/declarations.rb +281 -0
- data/lib/rbs/ast/ruby/helpers/constant_helper.rb +28 -0
- data/lib/rbs/ast/ruby/helpers/location_helper.rb +15 -0
- data/lib/rbs/ast/ruby/members.rb +723 -0
- data/lib/rbs/ast/type_param.rb +24 -4
- data/lib/rbs/buffer.rb +105 -20
- data/lib/rbs/cli/diff.rb +16 -15
- data/lib/rbs/cli/validate.rb +62 -125
- data/lib/rbs/cli.rb +55 -23
- data/lib/rbs/collection/config/lockfile_generator.rb +8 -4
- data/lib/rbs/collection/sources/git.rb +1 -0
- data/lib/rbs/collection.rb +0 -1
- data/lib/rbs/definition.rb +6 -1
- data/lib/rbs/definition_builder/ancestor_builder.rb +119 -63
- data/lib/rbs/definition_builder/method_builder.rb +65 -30
- data/lib/rbs/definition_builder.rb +177 -20
- data/lib/rbs/diff.rb +7 -1
- data/lib/rbs/environment/class_entry.rb +69 -0
- data/lib/rbs/environment/module_entry.rb +66 -0
- data/lib/rbs/environment.rb +338 -155
- data/lib/rbs/environment_loader.rb +2 -2
- data/lib/rbs/errors.rb +30 -20
- data/lib/rbs/inline_parser/comment_association.rb +117 -0
- data/lib/rbs/inline_parser.rb +542 -0
- data/lib/rbs/location_aux.rb +36 -4
- data/lib/rbs/locator.rb +5 -1
- data/lib/rbs/method_type.rb +5 -3
- data/lib/rbs/namespace.rb +0 -7
- data/lib/rbs/parser_aux.rb +31 -8
- data/lib/rbs/prototype/helpers.rb +57 -0
- data/lib/rbs/prototype/rb.rb +3 -28
- data/lib/rbs/prototype/rbi.rb +3 -20
- data/lib/rbs/prototype/runtime.rb +10 -2
- data/lib/rbs/resolver/type_name_resolver.rb +0 -8
- data/lib/rbs/source.rb +99 -0
- data/lib/rbs/subtractor.rb +4 -3
- data/lib/rbs/test/type_check.rb +5 -2
- data/lib/rbs/type_name.rb +1 -8
- data/lib/rbs/types.rb +88 -78
- data/lib/rbs/unit_test/convertibles.rb +1 -0
- data/lib/rbs/unit_test/type_assertions.rb +35 -8
- data/lib/rbs/validator.rb +2 -2
- data/lib/rbs/version.rb +1 -1
- data/lib/rbs.rb +12 -1
- data/rbs.gemspec +3 -2
- data/rust/.gitignore +1 -0
- data/rust/Cargo.lock +378 -0
- data/rust/Cargo.toml +7 -0
- data/rust/ruby-rbs/Cargo.toml +22 -0
- data/rust/ruby-rbs/build.rs +764 -0
- data/rust/ruby-rbs/examples/locations.rs +60 -0
- data/rust/ruby-rbs/src/lib.rs +1 -0
- data/rust/ruby-rbs/src/node/mod.rs +742 -0
- data/rust/ruby-rbs/tests/sanity.rs +47 -0
- data/rust/ruby-rbs/vendor/rbs/config.yml +1 -0
- data/rust/ruby-rbs-sys/Cargo.toml +23 -0
- data/rust/ruby-rbs-sys/build.rs +204 -0
- data/rust/ruby-rbs-sys/src/lib.rs +50 -0
- data/rust/ruby-rbs-sys/vendor/rbs/include +1 -0
- data/rust/ruby-rbs-sys/vendor/rbs/src +1 -0
- data/rust/ruby-rbs-sys/wrapper.h +1 -0
- data/schema/typeParam.json +17 -1
- data/sig/ancestor_builder.rbs +1 -1
- data/sig/ast/ruby/annotations.rbs +421 -0
- data/sig/ast/ruby/comment_block.rbs +127 -0
- data/sig/ast/ruby/declarations.rbs +158 -0
- data/sig/ast/ruby/helpers/constant_helper.rbs +11 -0
- data/sig/ast/ruby/helpers/location_helper.rbs +15 -0
- data/sig/ast/ruby/members.rbs +178 -0
- data/sig/buffer.rbs +63 -5
- data/sig/cli/diff.rbs +5 -11
- data/sig/cli/validate.rbs +12 -8
- data/sig/cli.rbs +18 -18
- data/sig/definition.rbs +6 -0
- data/sig/definition_builder.rbs +3 -1
- data/sig/environment/class_entry.rbs +50 -0
- data/sig/environment/module_entry.rbs +50 -0
- data/sig/environment.rbs +37 -81
- data/sig/errors.rbs +26 -20
- data/sig/inline_parser/comment_association.rbs +71 -0
- data/sig/inline_parser.rbs +124 -0
- data/sig/location.rbs +32 -7
- data/sig/locator.rbs +0 -2
- data/sig/method_builder.rbs +9 -4
- data/sig/namespace.rbs +0 -5
- data/sig/parser.rbs +47 -13
- data/sig/prototype/helpers.rbs +2 -0
- data/sig/resolver/type_name_resolver.rbs +0 -3
- data/sig/source.rbs +48 -0
- data/sig/type_param.rbs +13 -8
- data/sig/typename.rbs +0 -5
- data/sig/types.rbs +6 -7
- data/sig/unit_test/spy.rbs +0 -8
- data/sig/unit_test/type_assertions.rbs +11 -0
- data/src/ast.c +491 -143
- data/src/lexer.c +1552 -1314
- data/src/lexer.re +7 -0
- data/src/lexstate.c +8 -1
- data/src/location.c +8 -48
- data/src/parser.c +1107 -409
- data/src/util/rbs_constant_pool.c +0 -4
- data/stdlib/bigdecimal/0/big_decimal.rbs +16 -16
- data/stdlib/cgi-escape/0/escape.rbs +4 -4
- data/stdlib/coverage/0/coverage.rbs +4 -3
- data/stdlib/date/0/date.rbs +33 -28
- data/stdlib/date/0/date_time.rbs +24 -23
- data/stdlib/did_you_mean/0/did_you_mean.rbs +17 -16
- data/stdlib/digest/0/digest.rbs +110 -0
- data/stdlib/erb/0/erb.rbs +64 -53
- data/stdlib/etc/0/etc.rbs +55 -50
- data/stdlib/fileutils/0/fileutils.rbs +140 -126
- data/stdlib/forwardable/0/forwardable.rbs +10 -10
- data/stdlib/io-console/0/io-console.rbs +2 -2
- data/stdlib/json/0/json.rbs +158 -131
- data/stdlib/monitor/0/monitor.rbs +3 -3
- data/stdlib/net-http/0/net-http.rbs +159 -134
- data/stdlib/objspace/0/objspace.rbs +8 -30
- data/stdlib/open-uri/0/open-uri.rbs +8 -8
- data/stdlib/open3/0/open3.rbs +469 -10
- data/stdlib/openssl/0/openssl.rbs +144 -129
- data/stdlib/optparse/0/optparse.rbs +23 -14
- data/stdlib/pathname/0/pathname.rbs +2 -2
- data/stdlib/pp/0/pp.rbs +9 -8
- data/stdlib/prettyprint/0/prettyprint.rbs +7 -7
- data/stdlib/pstore/0/pstore.rbs +35 -30
- data/stdlib/psych/0/psych.rbs +62 -9
- data/stdlib/psych/0/store.rbs +2 -4
- data/stdlib/pty/0/pty.rbs +9 -6
- data/stdlib/random-formatter/0/random-formatter.rbs +277 -0
- data/stdlib/rdoc/0/code_object.rbs +2 -1
- data/stdlib/rdoc/0/parser.rbs +1 -1
- data/stdlib/rdoc/0/store.rbs +1 -1
- data/stdlib/ripper/0/ripper.rbs +20 -17
- data/stdlib/securerandom/0/manifest.yaml +2 -0
- data/stdlib/securerandom/0/securerandom.rbs +7 -20
- data/stdlib/shellwords/0/shellwords.rbs +2 -2
- data/stdlib/socket/0/addrinfo.rbs +9 -9
- data/stdlib/socket/0/basic_socket.rbs +3 -3
- data/stdlib/socket/0/ip_socket.rbs +10 -8
- data/stdlib/socket/0/socket.rbs +10 -9
- data/stdlib/socket/0/tcp_server.rbs +1 -1
- data/stdlib/socket/0/tcp_socket.rbs +1 -1
- data/stdlib/socket/0/udp_socket.rbs +1 -1
- data/stdlib/socket/0/unix_server.rbs +1 -1
- data/stdlib/stringio/0/stringio.rbs +55 -54
- data/stdlib/strscan/0/string_scanner.rbs +46 -44
- data/stdlib/tempfile/0/tempfile.rbs +24 -20
- data/stdlib/time/0/time.rbs +7 -5
- data/stdlib/tsort/0/tsort.rbs +7 -6
- data/stdlib/uri/0/common.rbs +31 -18
- data/stdlib/uri/0/file.rbs +2 -2
- data/stdlib/uri/0/generic.rbs +9 -2
- data/stdlib/uri/0/http.rbs +2 -2
- data/stdlib/uri/0/ldap.rbs +2 -2
- data/stdlib/uri/0/mailto.rbs +3 -3
- data/stdlib/uri/0/rfc2396_parser.rbs +6 -5
- data/stdlib/zlib/0/deflate.rbs +4 -3
- data/stdlib/zlib/0/gzip_reader.rbs +6 -6
- data/stdlib/zlib/0/gzip_writer.rbs +14 -12
- data/stdlib/zlib/0/inflate.rbs +1 -1
- data/stdlib/zlib/0/need_dict.rbs +1 -1
- metadata +66 -3
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
|
|
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
|
-
#
|
|
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
|
-
#
|
|
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
|
-
# *
|
|
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,
|
|
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
|
-
#
|
|
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
|
-
#
|
|
296
|
-
# corresponding access method to read it. Also creates a method called
|
|
297
|
-
# to set the attribute. String arguments are converted to
|
|
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
|
|
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
|
|
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
|
-
#
|
|
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
|
-
#
|
|
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
|
|
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
|
-
#
|
|
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
|
-
#
|
|
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
|
|
639
|
-
# defined as a side-effect of loading the file, the
|
|
640
|
-
# stored in the constant. This implements an autoload
|
|
641
|
-
# Kernel#autoload and Module#autoload, though it differs in
|
|
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
|
|
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
|
-
#
|
|
775
|
+
# <em>produces:</em>
|
|
773
776
|
#
|
|
774
777
|
# In Fred
|
|
775
778
|
# Charge it!
|
|
@@ -798,8 +801,6 @@ class Module < Object
|
|
|
798
801
|
#
|
|
799
802
|
def deprecate_constant: (*interned) -> self
|
|
800
803
|
|
|
801
|
-
def eql?: (untyped other) -> bool
|
|
802
|
-
|
|
803
804
|
def equal?: (untyped other) -> bool
|
|
804
805
|
|
|
805
806
|
# <!--
|
|
@@ -823,12 +824,12 @@ class Module < Object
|
|
|
823
824
|
# (s = Array.new).extend Picky # Call Object.extend
|
|
824
825
|
# (s = "quick brown fox").extend Picky
|
|
825
826
|
#
|
|
826
|
-
#
|
|
827
|
+
# <em>produces:</em>
|
|
827
828
|
#
|
|
828
829
|
# Picky added to Array
|
|
829
830
|
# Can't add Picky to a String
|
|
830
831
|
#
|
|
831
|
-
def extend_object: (untyped arg0) -> untyped
|
|
832
|
+
private def extend_object: (untyped arg0) -> untyped
|
|
832
833
|
|
|
833
834
|
# <!--
|
|
834
835
|
# rdoc-file=object.c
|
|
@@ -846,7 +847,7 @@ class Module < Object
|
|
|
846
847
|
# end
|
|
847
848
|
# # => prints "A extended in Enumerable"
|
|
848
849
|
#
|
|
849
|
-
def extended: (Module othermod) -> untyped
|
|
850
|
+
private def extended: (Module othermod) -> untyped
|
|
850
851
|
|
|
851
852
|
# <!--
|
|
852
853
|
# rdoc-file=object.c
|
|
@@ -891,8 +892,8 @@ class Module < Object
|
|
|
891
892
|
# - included(othermod)
|
|
892
893
|
# -->
|
|
893
894
|
# Callback invoked whenever the receiver is included in another module or class.
|
|
894
|
-
# This should be used in preference to
|
|
895
|
-
# 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.
|
|
896
897
|
#
|
|
897
898
|
# module A
|
|
898
899
|
# def A.included(mod)
|
|
@@ -904,7 +905,7 @@ class Module < Object
|
|
|
904
905
|
# end
|
|
905
906
|
# # => prints "A included in Enumerable"
|
|
906
907
|
#
|
|
907
|
-
def included: (Module othermod) -> untyped
|
|
908
|
+
private def included: (Module othermod) -> untyped
|
|
908
909
|
|
|
909
910
|
# <!--
|
|
910
911
|
# rdoc-file=object.c
|
|
@@ -982,7 +983,7 @@ class Module < Object
|
|
|
982
983
|
# interpreter = Interpreter.new
|
|
983
984
|
# interpreter.interpret('dave')
|
|
984
985
|
#
|
|
985
|
-
#
|
|
986
|
+
# <em>produces:</em>
|
|
986
987
|
#
|
|
987
988
|
# Hello there, Dave!
|
|
988
989
|
#
|
|
@@ -1039,11 +1040,11 @@ class Module < Object
|
|
|
1039
1040
|
# def some_instance_method() end
|
|
1040
1041
|
# end
|
|
1041
1042
|
#
|
|
1042
|
-
#
|
|
1043
|
+
# <em>produces:</em>
|
|
1043
1044
|
#
|
|
1044
1045
|
# Adding :some_instance_method
|
|
1045
1046
|
#
|
|
1046
|
-
def method_added: (Symbol meth) -> untyped
|
|
1047
|
+
private def method_added: (Symbol meth) -> untyped
|
|
1047
1048
|
|
|
1048
1049
|
# <!--
|
|
1049
1050
|
# rdoc-file=vm_method.c
|
|
@@ -1100,11 +1101,36 @@ class Module < Object
|
|
|
1100
1101
|
# remove_method :some_instance_method
|
|
1101
1102
|
# end
|
|
1102
1103
|
#
|
|
1103
|
-
#
|
|
1104
|
+
# <em>produces:</em>
|
|
1104
1105
|
#
|
|
1105
1106
|
# Removing :some_instance_method
|
|
1106
1107
|
#
|
|
1107
|
-
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
|
|
1108
1134
|
|
|
1109
1135
|
# <!--
|
|
1110
1136
|
# rdoc-file=vm_eval.c
|
|
@@ -1126,7 +1152,7 @@ class Module < Object
|
|
|
1126
1152
|
# puts Thing.new.hello()
|
|
1127
1153
|
# Thing.module_eval("invalid code", "dummy", 123)
|
|
1128
1154
|
#
|
|
1129
|
-
#
|
|
1155
|
+
# <em>produces:</em>
|
|
1130
1156
|
#
|
|
1131
1157
|
# Hello there!
|
|
1132
1158
|
# dummy:123:in `module_eval': undefined local variable
|
|
@@ -1152,7 +1178,7 @@ class Module < Object
|
|
|
1152
1178
|
# }
|
|
1153
1179
|
# puts Thing.new.hello()
|
|
1154
1180
|
#
|
|
1155
|
-
#
|
|
1181
|
+
# <em>produces:</em>
|
|
1156
1182
|
#
|
|
1157
1183
|
# Hello there!
|
|
1158
1184
|
#
|
|
@@ -1197,11 +1223,11 @@ class Module < Object
|
|
|
1197
1223
|
# Mod.one #=> "This is one"
|
|
1198
1224
|
# c.call_one #=> "This is the new one"
|
|
1199
1225
|
#
|
|
1200
|
-
def module_function: () -> nil
|
|
1201
|
-
|
|
1202
|
-
|
|
1203
|
-
|
|
1204
|
-
|
|
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]
|
|
1205
1231
|
|
|
1206
1232
|
# <!--
|
|
1207
1233
|
# rdoc-file=object.c
|
|
@@ -1229,7 +1255,7 @@ class Module < Object
|
|
|
1229
1255
|
# this module to *mod* if this module has not already been added to *mod* or one
|
|
1230
1256
|
# of its ancestors. See also Module#prepend.
|
|
1231
1257
|
#
|
|
1232
|
-
def prepend_features: (Module arg0) -> self
|
|
1258
|
+
private def prepend_features: (Module arg0) -> self
|
|
1233
1259
|
|
|
1234
1260
|
# <!--
|
|
1235
1261
|
# rdoc-file=object.c
|
|
@@ -1247,7 +1273,7 @@ class Module < Object
|
|
|
1247
1273
|
# end
|
|
1248
1274
|
# # => prints "A prepended to Enumerable"
|
|
1249
1275
|
#
|
|
1250
|
-
def prepended: (Module othermod) -> untyped
|
|
1276
|
+
private def prepended: (Module othermod) -> untyped
|
|
1251
1277
|
|
|
1252
1278
|
# <!--
|
|
1253
1279
|
# rdoc-file=vm_method.c
|
|
@@ -1272,14 +1298,14 @@ class Module < Object
|
|
|
1272
1298
|
# end
|
|
1273
1299
|
# Mod.private_instance_methods #=> [:a, :c]
|
|
1274
1300
|
#
|
|
1275
|
-
# Note that to show a private method on RDoc, use
|
|
1301
|
+
# Note that to show a private method on RDoc, use <code>:doc:</code>.
|
|
1276
1302
|
#
|
|
1277
|
-
def private: () -> nil
|
|
1278
|
-
|
|
1279
|
-
|
|
1280
|
-
|
|
1281
|
-
|
|
1282
|
-
|
|
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]
|
|
1283
1309
|
|
|
1284
1310
|
# <!--
|
|
1285
1311
|
# rdoc-file=vm_method.c
|
|
@@ -1380,9 +1406,9 @@ class Module < Object
|
|
|
1380
1406
|
# Marking a method as protected allows **different objects of the same class**
|
|
1381
1407
|
# to call it.
|
|
1382
1408
|
#
|
|
1383
|
-
# One use case is for comparison methods, such as
|
|
1384
|
-
# method for comparison between objects of the same class without
|
|
1385
|
-
# 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.
|
|
1386
1412
|
#
|
|
1387
1413
|
# ## Performance considerations
|
|
1388
1414
|
#
|
|
@@ -1413,14 +1439,14 @@ class Module < Object
|
|
|
1413
1439
|
# account1 > account2 # => true (works)
|
|
1414
1440
|
# account1.balance # => NoMethodError (fails because balance is not public)
|
|
1415
1441
|
#
|
|
1416
|
-
# To show a private method on RDoc, use
|
|
1442
|
+
# To show a private method on RDoc, use <code>:doc:</code> instead of this.
|
|
1417
1443
|
#
|
|
1418
|
-
def protected: () -> nil
|
|
1419
|
-
|
|
1420
|
-
|
|
1421
|
-
|
|
1422
|
-
|
|
1423
|
-
|
|
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]
|
|
1424
1450
|
|
|
1425
1451
|
# <!--
|
|
1426
1452
|
# rdoc-file=object.c
|
|
@@ -1475,12 +1501,12 @@ class Module < Object
|
|
|
1475
1501
|
# returned. If no argument is passed, nil is returned. If multiple arguments are
|
|
1476
1502
|
# passed, the arguments are returned as an array.
|
|
1477
1503
|
#
|
|
1478
|
-
def public: () -> nil
|
|
1479
|
-
|
|
1480
|
-
|
|
1481
|
-
|
|
1482
|
-
|
|
1483
|
-
|
|
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]
|
|
1484
1510
|
|
|
1485
1511
|
# <!--
|
|
1486
1512
|
# rdoc-file=vm_method.c
|
|
@@ -1559,7 +1585,7 @@ class Module < Object
|
|
|
1559
1585
|
#
|
|
1560
1586
|
# Returns a module, where refined methods are defined.
|
|
1561
1587
|
#
|
|
1562
|
-
def refine: (Module mod) { () [self: Refinement] -> void } -> Refinement
|
|
1588
|
+
private def refine: (Module mod) { () [self: Refinement] -> void } -> Refinement
|
|
1563
1589
|
|
|
1564
1590
|
# <!--
|
|
1565
1591
|
# rdoc-file=eval.c
|
|
@@ -1577,7 +1603,7 @@ class Module < Object
|
|
|
1577
1603
|
#
|
|
1578
1604
|
# p A.refinements
|
|
1579
1605
|
#
|
|
1580
|
-
#
|
|
1606
|
+
# <em>produces:</em>
|
|
1581
1607
|
#
|
|
1582
1608
|
# [#<refinement:Integer@A>, #<refinement:String@A>]
|
|
1583
1609
|
#
|
|
@@ -1596,7 +1622,7 @@ class Module < Object
|
|
|
1596
1622
|
# p(defined? @@var)
|
|
1597
1623
|
# end
|
|
1598
1624
|
#
|
|
1599
|
-
#
|
|
1625
|
+
# <em>produces:</em>
|
|
1600
1626
|
#
|
|
1601
1627
|
# 99
|
|
1602
1628
|
# nil
|
|
@@ -1611,7 +1637,7 @@ class Module < Object
|
|
|
1611
1637
|
# previous value. If that constant referred to a module, this will not change
|
|
1612
1638
|
# that module's name and can lead to confusion.
|
|
1613
1639
|
#
|
|
1614
|
-
def remove_const: (interned arg0) -> untyped
|
|
1640
|
+
private def remove_const: (interned arg0) -> untyped
|
|
1615
1641
|
|
|
1616
1642
|
# <!--
|
|
1617
1643
|
# rdoc-file=vm_method.c
|
|
@@ -1623,6 +1649,43 @@ class Module < Object
|
|
|
1623
1649
|
#
|
|
1624
1650
|
def remove_method: (*interned arg0) -> self
|
|
1625
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
|
+
|
|
1626
1689
|
# <!--
|
|
1627
1690
|
# rdoc-file=object.c
|
|
1628
1691
|
# - mod.set_temporary_name(string) -> self
|
|
@@ -1730,7 +1793,7 @@ class Module < Object
|
|
|
1730
1793
|
# end
|
|
1731
1794
|
# c.hello
|
|
1732
1795
|
#
|
|
1733
|
-
#
|
|
1796
|
+
# <em>produces:</em>
|
|
1734
1797
|
#
|
|
1735
1798
|
# In child
|
|
1736
1799
|
# In parent
|
|
@@ -1754,7 +1817,7 @@ class Module < Object
|
|
|
1754
1817
|
# Import class refinements from *module* into the current class or module
|
|
1755
1818
|
# definition.
|
|
1756
1819
|
#
|
|
1757
|
-
def using: (Module arg0) -> self
|
|
1820
|
+
private def using: (Module arg0) -> self
|
|
1758
1821
|
|
|
1759
1822
|
# <!-- rdoc-file=object.c -->
|
|
1760
1823
|
# Returns a string representing this module or class. For basic classes and
|
|
@@ -1770,13 +1833,10 @@ class Module < Object
|
|
|
1770
1833
|
# - attr(name, false) -> array
|
|
1771
1834
|
# -->
|
|
1772
1835
|
# The first form is equivalent to #attr_reader. The second form is equivalent to
|
|
1773
|
-
#
|
|
1774
|
-
#
|
|
1775
|
-
# 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.
|
|
1776
1839
|
#
|
|
1777
|
-
def attr: (
|
|
1778
|
-
|
|
1779
|
-
# A previous incarnation of `interned` for backward-compatibility (see #1499)
|
|
1780
|
-
%a{deprecated: Use `interned`}
|
|
1781
|
-
type id = interned
|
|
1840
|
+
def attr: %a{deprecated} (interned, bool) -> Array[Symbol]
|
|
1841
|
+
| (*interned arg0) -> Array[Symbol]
|
|
1782
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
|
|
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
|
|
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
|
|
110
|
+
# Returns `true`. For all other objects, method <code>nil?</code> returns
|
|
111
|
+
# `false`.
|
|
111
112
|
#
|
|
112
113
|
def nil?: () -> true
|
|
113
114
|
|