rbs 0.18.1 → 1.0.0.pre2

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 (66) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGELOG.md +31 -0
  3. data/Rakefile +12 -0
  4. data/Steepfile +2 -1
  5. data/bin/annotate-with-rdoc +0 -4
  6. data/core/builtin.rbs +4 -0
  7. data/core/file.rbs +3 -4
  8. data/core/hash.rbs +1 -3
  9. data/core/io.rbs +165 -7
  10. data/core/kernel.rbs +1 -1
  11. data/core/module.rbs +41 -0
  12. data/core/time.rbs +0 -12
  13. data/docs/syntax.md +0 -17
  14. data/goodcheck.yml +22 -2
  15. data/lib/rbs.rb +2 -0
  16. data/lib/rbs/ast/declarations.rb +7 -49
  17. data/lib/rbs/ast/members.rb +10 -4
  18. data/lib/rbs/cli.rb +10 -10
  19. data/lib/rbs/definition.rb +70 -3
  20. data/lib/rbs/definition_builder.rb +573 -984
  21. data/lib/rbs/definition_builder/ancestor_builder.rb +525 -0
  22. data/lib/rbs/definition_builder/method_builder.rb +217 -0
  23. data/lib/rbs/environment.rb +6 -8
  24. data/lib/rbs/environment_loader.rb +8 -4
  25. data/lib/rbs/errors.rb +88 -121
  26. data/lib/rbs/method_type.rb +1 -31
  27. data/lib/rbs/parser.rb +1082 -1014
  28. data/lib/rbs/parser.y +108 -76
  29. data/lib/rbs/prototype/rb.rb +18 -3
  30. data/lib/rbs/prototype/rbi.rb +6 -6
  31. data/lib/rbs/prototype/runtime.rb +71 -35
  32. data/lib/rbs/substitution.rb +4 -0
  33. data/lib/rbs/test.rb +3 -1
  34. data/lib/rbs/test/hook.rb +26 -8
  35. data/lib/rbs/types.rb +68 -7
  36. data/lib/rbs/validator.rb +4 -2
  37. data/lib/rbs/variance_calculator.rb +5 -1
  38. data/lib/rbs/version.rb +1 -1
  39. data/lib/rbs/writer.rb +13 -4
  40. data/schema/members.json +5 -1
  41. data/sig/ancestor_builder.rbs +98 -0
  42. data/sig/declarations.rbs +4 -16
  43. data/sig/definition.rbs +6 -1
  44. data/sig/definition_builder.rbs +15 -67
  45. data/sig/errors.rbs +159 -0
  46. data/sig/members.rbs +4 -1
  47. data/sig/method_builder.rbs +71 -0
  48. data/sig/method_types.rbs +3 -16
  49. data/sig/substitution.rbs +3 -0
  50. data/sig/type_name_resolver.rbs +4 -2
  51. data/sig/types.rbs +17 -15
  52. data/sig/validator.rbs +12 -0
  53. data/stdlib/csv/0/csv.rbs +3 -0
  54. data/stdlib/dbm/0/dbm.rbs +0 -2
  55. data/stdlib/logger/0/log_device.rbs +1 -2
  56. data/stdlib/monitor/0/monitor.rbs +119 -0
  57. data/stdlib/pathname/0/pathname.rbs +1 -1
  58. data/stdlib/prime/0/prime.rbs +6 -0
  59. data/stdlib/securerandom/0/securerandom.rbs +2 -0
  60. data/stdlib/time/0/time.rbs +327 -0
  61. data/stdlib/tsort/0/tsort.rbs +8 -0
  62. data/stdlib/uri/0/common.rbs +401 -0
  63. data/stdlib/uri/0/rfc2396_parser.rbs +9 -0
  64. data/stdlib/uri/0/rfc3986_parser.rbs +2 -0
  65. data/steep/Gemfile.lock +13 -14
  66. metadata +16 -5
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: e206f65853958ab46b6893d2c8b631676a82bd3eb62ea2f6f0f5c19bef2ce2a0
4
- data.tar.gz: 502bdf2a7ccc7578b3cfe816cfcae57a84677e4da171204d82e5e8f7c9f71091
3
+ metadata.gz: 876e6bbb99faa21b1446731aaa99e9e184952dfff4a74c40278a8e4473ab0153
4
+ data.tar.gz: dbe783feb6db3cef15000018b0d9120b5761775fa9e635355b75f23783d558c1
5
5
  SHA512:
6
- metadata.gz: 6665849050b6ef83c7d9d4f4fb32a712b96a5afb38bb236d7749f5e55bebc939ca08f04251ab1af482f2a090bd285d12ae421593076bcdc53fffedccb6e31d9e
7
- data.tar.gz: ff18d27e825dfbddafba1f6b493fbeee50e47274fcf47fad33db55e69e4edc72f25ed9a24449217178ca3d279079f5a8216440080104f147d62e9bccc67926d7
6
+ metadata.gz: 9bdc0e3cca9cff43bfd69dba8f8635745a5e164c8590c627434075f839fee353173a9f8e829ee5bbcdd3114fe0035fbd5fef54c56d17382135563c3d2e6d8b4b
7
+ data.tar.gz: ae9c5ca0eae79d4261263235817d031e1541e82e07d70826e6d7cd69fda211cf6fd4c933706b839a39ea221b45ca044cd3381b04ff480df1c3ba06a9ee9c528b
@@ -2,6 +2,37 @@
2
2
 
3
3
  ## master
4
4
 
5
+ ## 1.0.0 (Pre released)
6
+
7
+ * Signature updates for `URI`, `IO`, `File`, `Pathname`, `Module`, and `Time` ([#529](https://github.com/ruby/rbs/pull/529), [#521](https://github.com/ruby/rbs/pull/521), [#520](https://github.com/ruby/rbs/pull/520), [#511](https://github.com/ruby/rbs/pull/511), [#517](https://github.com/ruby/rbs/pull/517), [#542](https://github.com/ruby/rbs/pull/542), [#546](https://github.com/ruby/rbs/pull/546), [#540](https://github.com/ruby/rbs/pull/540), [#538](https://github.com/ruby/rbs/pull/538))
8
+ * `rbs prototype runtime` generates `extend`s ([#535](https://github.com/ruby/rbs/pull/535))
9
+ * `rbs prototype runtime` stability improvements ([#533](https://github.com/ruby/rbs/pull/533), [#526](https://github.com/ruby/rbs/pull/526))
10
+ * `rbs prototype rb` compatibility improvements ([#545](https://github.com/ruby/rbs/pull/545))
11
+ * Implement method names escape in `RBS::Writer` ([#537](https://github.com/ruby/rbs/pull/537))
12
+ * Improve runtime type checker compatibility ([#532](https://github.com/ruby/rbs/pull/532), [#528](https://github.com/ruby/rbs/pull/528), [#547](https://github.com/ruby/rbs/pull/547))
13
+ * Fix `ruby2_keywords` for `Proc` in Ruby <2.7 ([#513](https://github.com/ruby/rbs/pull/513))
14
+ * Better compatibility for record type attribute names ([#525](https://github.com/ruby/rbs/pull/525), [#524](https://github.com/ruby/rbs/pull/524))
15
+ * Let module self-types be classes ([#523](https://github.com/ruby/rbs/pull/523))
16
+ * Delete `extension` syntax ([#543](https://github.com/ruby/rbs/pull/543))
17
+ * Method resolution improvements about `alias` and `.new` ([#522](https://github.com/ruby/rbs/pull/522), [#519](https://github.com/ruby/rbs/pull/519), [#516](https://github.com/ruby/rbs/pull/516))
18
+ * Better message for `DuplicatedMethodDefinitionError` ([#539](https://github.com/ruby/rbs/pull/539))
19
+
20
+ ## 0.20.1 (2020-12-06)
21
+
22
+ * Make the order of RBS load reproducible ([#508](https://github.com/ruby/rbs/pull/508))
23
+
24
+ ## 0.20.0 (2020-12-06)
25
+
26
+ * Signature updates for `TSort`, `DBM`, `Time`, and `Hash` ([#496](https://github.com/ruby/rbs/pull/496), [#497](https://github.com/ruby/rbs/pull/497), [#499](https://github.com/ruby/rbs/pull/499), [#507](https://github.com/ruby/rbs/pull/507))
27
+ * Add _singleton attribute_ syntax ([#502](https://github.com/ruby/rbs/pull/502), [#506](https://github.com/ruby/rbs/pull/506), [#505](https://github.com/ruby/rbs/pull/505))
28
+ * Proc types with blocks ([#503](https://github.com/ruby/rbs/pull/503))
29
+ * Add support for escape sequences in string literal types ([#501](https://github.com/ruby/rbs/pull/501))
30
+ * Fix runtime type checking of blocks with keyword args ([#500](https://github.com/ruby/rbs/pull/500))
31
+
32
+ ## 0.19.0 (2020-12-02)
33
+
34
+ * Signature updates for `Monitor` and File ([#485](https://github.com/ruby/rbs/pull/485), [#495](https://github.com/ruby/rbs/pull/495))
35
+
5
36
  ## 0.18.1 (2020-12-01)
6
37
 
7
38
  * Fix `EnvironmentWalker#each_type_name` ([#494](https://github.com/ruby/rbs/pull/494))
data/Rakefile CHANGED
@@ -41,6 +41,18 @@ task :validate => :parser do
41
41
  lib << "pstore"
42
42
  end
43
43
 
44
+ if lib == ["logger"]
45
+ lib << "monitor"
46
+ end
47
+
48
+ if lib == ["csv"]
49
+ lib << "forwardable"
50
+ end
51
+
52
+ if lib == ["prime"]
53
+ lib << "singleton"
54
+ end
55
+
44
56
  sh "#{ruby} #{rbs} #{lib.map {|l| "-r #{l}"}.join(" ")} validate --silent"
45
57
  end
46
58
  end
data/Steepfile CHANGED
@@ -2,8 +2,9 @@ target :lib do
2
2
  signature "sig"
3
3
  check "lib"
4
4
  ignore "lib/rbs/parser.rb"
5
+ ignore "lib/rbs/prototype", "lib/rbs/test", "lib/rbs/test.rb"
5
6
 
6
- library "set", "pathname", "json", "logger"
7
+ library "set", "pathname", "json", "logger", "monitor", "tsort"
7
8
  end
8
9
 
9
10
  # target :lib do
@@ -140,10 +140,6 @@ ARGV.map {|f| Pathname(f) }.each do |path|
140
140
  comment = comment_for_class(decl, stores: stores)
141
141
  decl.instance_variable_set(:@comment, comment)
142
142
 
143
- print_members stores, decl.name.to_s, decl.members
144
- when RBS::AST::Declarations::Extension
145
- puts " Importing documentation for #{decl.name} (#{decl.extension_name})"
146
-
147
143
  print_members stores, decl.name.to_s, decl.members
148
144
  end
149
145
  end
@@ -34,6 +34,10 @@ interface _Reader
34
34
  def read: (?int length, ?string outbuf) -> String?
35
35
  end
36
36
 
37
+ interface _ReaderPartial
38
+ def readpartial: (int maxlen, ?string outbuf) -> String
39
+ end
40
+
37
41
  interface _Writer
38
42
  # Writes the +data+ string. Returns the number of bytes written
39
43
  def write: (*_ToS data) -> Integer
@@ -192,10 +192,6 @@ class File < IO
192
192
  #
193
193
  def self.exist?: (string | _ToPath | IO file_name) -> bool
194
194
 
195
- # Deprecated method. Don't use.
196
- #
197
- alias self.exists? self.exist?
198
-
199
195
  # Converts a pathname to an absolute pathname. Relative paths are referenced
200
196
  # from the current working directory of the process unless `dir_string` is
201
197
  # given, in which case it will be used as the starting point. The given pathname
@@ -535,6 +531,9 @@ class File < IO
535
531
  #
536
532
  def self.mtime: (string | _ToPath | IO file_name) -> Time
537
533
 
534
+ # Alias of `File.new`.
535
+ def self.open: (string | _ToPath | int file_name, ?(string | int) mode, ?int perm) -> instance
536
+
538
537
  # Returns `true` if the named file exists and the effective used id of the
539
538
  # calling process is the owner of the file.
540
539
  #
@@ -563,8 +563,6 @@ class Hash[unchecked out K, unchecked out V] < Object
563
563
  #
564
564
  alias include? has_key?
565
565
 
566
- def index: (V) -> K?
567
-
568
566
  # Return the contents of this hash as a string.
569
567
  #
570
568
  # h = { "c" => 300, "a" => 100, "d" => 400, "c" => 300 }
@@ -615,7 +613,7 @@ class Hash[unchecked out K, unchecked out V] < Object
615
613
  # h.key(300) #=> "c"
616
614
  # h.key(999) #=> nil
617
615
  #
618
- alias key index
616
+ def key: (V) -> K?
619
617
 
620
618
  # Returns `true` if the given key is present in *hsh*.
621
619
  #
@@ -405,7 +405,63 @@ class IO < Object
405
405
 
406
406
  def puts: (*untyped arg0) -> NilClass
407
407
 
408
- def read: (?Integer length, ?String outbuf) -> String?
408
+ # Reads *length* bytes from the I/O stream.
409
+ #
410
+ # *length* must be a non-negative integer or `nil`.
411
+ #
412
+ # If *length* is a positive integer, `read` tries to read *length* bytes without
413
+ # any conversion (binary mode). It returns `nil` if an EOF is encountered before
414
+ # anything can be read. Fewer than *length* bytes are returned if an EOF is
415
+ # encountered during the read. In the case of an integer *length*, the resulting
416
+ # string is always in ASCII-8BIT encoding.
417
+ #
418
+ # If *length* is omitted or is `nil`, it reads until EOF and the encoding
419
+ # conversion is applied, if applicable. A string is returned even if EOF is
420
+ # encountered before any data is read.
421
+ #
422
+ # If *length* is zero, it returns an empty string (`""`).
423
+ #
424
+ # If the optional *outbuf* argument is present, it must reference a String,
425
+ # which will receive the data. The *outbuf* will contain only the received data
426
+ # after the method call even if it is not empty at the beginning.
427
+ #
428
+ # When this method is called at end of file, it returns `nil` or `""`, depending
429
+ # on *length*: `read`, `read(nil)`, and `read(0)` return `""`,
430
+ # `read(*positive_integer*)` returns `nil`.
431
+ #
432
+ # f = File.new("testfile")
433
+ # f.read(16) #=> "This is line one"
434
+ #
435
+ # # read whole file
436
+ # open("file") do |f|
437
+ # data = f.read # This returns a string even if the file is empty.
438
+ # # ...
439
+ # end
440
+ #
441
+ # # iterate over fixed length records
442
+ # open("fixed-record-file") do |f|
443
+ # while record = f.read(256)
444
+ # # ...
445
+ # end
446
+ # end
447
+ #
448
+ # # iterate over variable length records,
449
+ # # each record is prefixed by its 32-bit length
450
+ # open("variable-record-file") do |f|
451
+ # while len = f.read(4)
452
+ # len = len.unpack("N")[0] # 32-bit length
453
+ # record = f.read(len) # This returns a string even if len is 0.
454
+ # end
455
+ # end
456
+ #
457
+ # Note that this method behaves like the fread() function in C. This means it
458
+ # retries to invoke read(2) system calls to read data with the specified length
459
+ # (or until EOF). This behavior is preserved even if *ios* is in non-blocking
460
+ # mode. (This method is non-blocking flag insensitive as other methods.) If you
461
+ # need the behavior like a single read(2) system call, consider #readpartial,
462
+ # #read_nonblock, and #sysread.
463
+ #
464
+ def read: (?Integer? length, ?String outbuf) -> String?
409
465
 
410
466
  def read_nonblock: (Integer len) -> String
411
467
  | (Integer len, ?String buf) -> String
@@ -428,8 +484,63 @@ class IO < Object
428
484
 
429
485
  def readlines: (?String sep, ?Integer limit) -> ::Array[String]
430
486
 
431
- def readpartial: (Integer maxlen) -> String
432
- | (Integer maxlen, ?String outbuf) -> String
487
+ # Reads at most *maxlen* bytes from the I/O stream. It blocks only if *ios* has
488
+ # no data immediately available. It doesn't block if some data available.
489
+ #
490
+ # If the optional *outbuf* argument is present, it must reference a String,
491
+ # which will receive the data. The *outbuf* will contain only the received data
492
+ # after the method call even if it is not empty at the beginning.
493
+ #
494
+ # It raises EOFError on end of file.
495
+ #
496
+ # readpartial is designed for streams such as pipe, socket, tty, etc. It blocks
497
+ # only when no data immediately available. This means that it blocks only when
498
+ # following all conditions hold.
499
+ # * the byte buffer in the IO object is empty.
500
+ # * the content of the stream is empty.
501
+ # * the stream is not reached to EOF.
502
+ #
503
+ #
504
+ # When readpartial blocks, it waits data or EOF on the stream. If some data is
505
+ # reached, readpartial returns with the data. If EOF is reached, readpartial
506
+ # raises EOFError.
507
+ #
508
+ # When readpartial doesn't blocks, it returns or raises immediately. If the byte
509
+ # buffer is not empty, it returns the data in the buffer. Otherwise if the
510
+ # stream has some content, it returns the data in the stream. Otherwise if the
511
+ # stream is reached to EOF, it raises EOFError.
512
+ #
513
+ # r, w = IO.pipe # buffer pipe content
514
+ # w << "abc" # "" "abc".
515
+ # r.readpartial(4096) #=> "abc" "" ""
516
+ # r.readpartial(4096) # blocks because buffer and pipe is empty.
517
+ #
518
+ # r, w = IO.pipe # buffer pipe content
519
+ # w << "abc" # "" "abc"
520
+ # w.close # "" "abc" EOF
521
+ # r.readpartial(4096) #=> "abc" "" EOF
522
+ # r.readpartial(4096) # raises EOFError
523
+ #
524
+ # r, w = IO.pipe # buffer pipe content
525
+ # w << "abc\ndef\n" # "" "abc\ndef\n"
526
+ # r.gets #=> "abc\n" "def\n" ""
527
+ # w << "ghi\n" # "def\n" "ghi\n"
528
+ # r.readpartial(4096) #=> "def\n" "" "ghi\n"
529
+ # r.readpartial(4096) #=> "ghi\n" "" ""
530
+ #
531
+ # Note that readpartial behaves similar to sysread. The differences are:
532
+ # * If the byte buffer is not empty, read from the byte buffer instead of
533
+ # "sysread for buffered IO (IOError)".
534
+ # * It doesn't cause Errno::EWOULDBLOCK and Errno::EINTR. When readpartial
535
+ # meets EWOULDBLOCK and EINTR by read system call, readpartial retry the
536
+ # system call.
537
+ #
538
+ #
539
+ # The latter means that readpartial is nonblocking-flag insensitive. It blocks
540
+ # on the situation IO#sysread causes Errno::EWOULDBLOCK as if the fd is blocking
541
+ # mode.
542
+ #
543
+ def readpartial: (Integer maxlen, ?String outbuf) -> String
433
544
 
434
545
  def reopen: (IO other_IO_or_path) -> IO
435
546
  | (String other_IO_or_path, ?String mode_str) -> IO
@@ -508,13 +619,55 @@ class IO < Object
508
619
 
509
620
  def ungetc: (String arg0) -> NilClass
510
621
 
511
- def write: (*_ToS arg0) -> Integer
622
+ # Writes the given strings to *ios*. The stream must be opened for writing.
623
+ # Arguments that are not a string will be converted to a string using `to_s`.
624
+ # Returns the number of bytes written in total.
625
+ #
626
+ # count = $stdout.write("This is", " a test\n")
627
+ # puts "That was #{count} bytes of data"
628
+ #
629
+ # *produces:*
630
+ #
631
+ # This is a test
632
+ # That was 15 bytes of data
633
+ #
634
+ def write: (*_ToS string) -> Integer
512
635
 
636
+ # Opens the file, optionally seeks to the given *offset*, then returns *length*
637
+ # bytes (defaulting to the rest of the file). #binread ensures the file is
638
+ # closed before returning. The open mode would be `"rb:ASCII-8BIT"`.
639
+ #
640
+ # IO.binread("testfile") #=> "This is line one\nThis is line two\nThis is line three\nAnd so on...\n"
641
+ # IO.binread("testfile", 20) #=> "This is line one\nThi"
642
+ # IO.binread("testfile", 20, 10) #=> "ne one\nThis is line "
643
+ #
513
644
  def self.binread: (String name, ?Integer length, ?Integer offset) -> String
514
645
 
515
- def self.binwrite: (String name, _ToS arg0, ?Integer offset, ?external_encoding: String external_encoding, ?internal_encoding: String internal_encoding, ?encoding: String encoding, ?textmode: untyped textmode, ?binmode: untyped binmode, ?autoclose: untyped autoclose, ?mode: String mode) -> Integer
646
+ # Same as IO.write except opening the file in binary mode and ASCII-8BIT
647
+ # encoding (`"wb:ASCII-8BIT"`).
648
+ #
649
+ def self.binwrite: (String name, _ToS string, ?Integer offset, ?mode: String mode) -> Integer
516
650
 
517
- def self.copy_stream: (_Reader src, _Writer dst, ?Integer copy_length, ?Integer src_offset) -> Integer
651
+ # IO.copy_stream copies *src* to *dst*. *src* and *dst* is either a filename or
652
+ # an IO-like object. IO-like object for *src* should have #readpartial or #read
653
+ # method. IO-like object for *dst* should have #write method. (Specialized
654
+ # mechanisms, such as sendfile system call, may be used on appropriate
655
+ # situation.)
656
+ #
657
+ # This method returns the number of bytes copied.
658
+ #
659
+ # If optional arguments are not given, the start position of the copy is the
660
+ # beginning of the filename or the current file offset of the IO. The end
661
+ # position of the copy is the end of file.
662
+ #
663
+ # If *copy_length* is given, No more than *copy_length* bytes are copied.
664
+ #
665
+ # If *src_offset* is given, it specifies the start position of the copy.
666
+ #
667
+ # When *src_offset* is specified and *src* is an IO, IO.copy_stream doesn't move
668
+ # the current file offset.
669
+ #
670
+ def self.copy_stream: ((String | _Reader | _ReaderPartial) src, (String | _Writer) dst, ?Integer copy_length, ?Integer src_offset) -> Integer
518
671
 
519
672
  def self.popen: (*untyped args) -> untyped
520
673
 
@@ -530,7 +683,12 @@ class IO < Object
530
683
 
531
684
  def self.write: (String name, _ToS arg0, ?Integer offset, ?external_encoding: String external_encoding, ?internal_encoding: String internal_encoding, ?encoding: String encoding, ?textmode: untyped textmode, ?binmode: untyped binmode, ?autoclose: untyped autoclose, ?mode: String mode) -> Integer
532
685
 
533
- def self.for_fd: (Integer fd, ?Integer mode, ?Integer opt) -> self
686
+ def self.for_fd: (int fd, ?(string | int) mode, **untyped opt) -> instance
687
+
688
+ alias self.open self.for_fd
689
+
690
+ def self.open: [A] (int fd, ?(string | int) mode, **untyped opt) { (instance) -> A } -> A
691
+ | ...
534
692
 
535
693
  def bytes: () { (Integer arg0) -> untyped } -> self
536
694
  | () -> ::Enumerator[Integer, self]
@@ -10,7 +10,7 @@
10
10
  # ```ruby
11
11
  # sprintf "%.1f", 1.234 #=> "1.2"
12
12
  # ```
13
- module Kernel
13
+ module Kernel : BasicObject
14
14
  private
15
15
 
16
16
  def caller: (?Integer start_or_range, ?Integer length) -> ::Array[String]?
@@ -443,6 +443,47 @@ class Module < Object
443
443
  #
444
444
  def const_set: (Symbol | String arg0, untyped arg1) -> untyped
445
445
 
446
+ # Returns the Ruby source filename and line number containing first definition
447
+ # of constant specified. If the named constant is not found, `nil` is returned.
448
+ # If the constant is found, but its source location can not be extracted
449
+ # (constant is defined in C code), empty array is returned.
450
+ #
451
+ # *inherit* specifies whether to lookup in `mod.ancestors` (`true` by default).
452
+ #
453
+ # # test.rb:
454
+ # class A
455
+ # C1 = 1
456
+ # end
457
+ #
458
+ # module M
459
+ # C2 = 2
460
+ # end
461
+ #
462
+ # class B < A
463
+ # include M
464
+ # C3 = 3
465
+ # end
466
+ #
467
+ # class A # continuation of A definition
468
+ # end
469
+ #
470
+ # p B.const_source_location('C3') # => ["test.rb", 11]
471
+ # p B.const_source_location('C2') # => ["test.rb", 6]
472
+ # p B.const_source_location('C1') # => ["test.rb", 2]
473
+ #
474
+ # p B.const_source_location('C2', false) # => nil -- don't lookup in ancestors
475
+ #
476
+ # p Object.const_source_location('B') # => ["test.rb", 9]
477
+ # p Object.const_source_location('A') # => ["test.rb", 1] -- note it is first entry, not "continuation"
478
+ #
479
+ # p B.const_source_location('A') # => ["test.rb", 1] -- because Object is in ancestors
480
+ # p M.const_source_location('A') # => ["test.rb", 1] -- Object is not ancestor, but additionally checked for modules
481
+ #
482
+ # p Object.const_source_location('A::C1') # => ["test.rb", 2] -- nesting is supported
483
+ # p Object.const_source_location('String') # => [] -- constant is defined in C code
484
+ #
485
+ def const_source_location: (Symbol | String name, ?boolish inherit) -> ([String, Integer] | [ ] | nil)
486
+
446
487
  # Returns an array of the names of the constants accessible in *mod*. This
447
488
  # includes the names of constants in any included modules (example at start of
448
489
  # section), unless the *inherit* parameter is set to `false`.
@@ -757,18 +757,6 @@ class Time < Object
757
757
  #
758
758
  def subsec: () -> Numeric
759
759
 
760
- # Returns a new Time object, one second later than *time*. Time#succ is obsolete
761
- # since 1.9.2 for time is not a discrete value.
762
- #
763
- # t = Time.now #=> 2007-11-19 08:23:57 -0600
764
- # t.succ #=> 2007-11-19 08:23:58 -0600
765
- #
766
- # Use instead `time + 1`
767
- #
768
- # t + 1 #=> 2007-11-19 08:23:58 -0600
769
- #
770
- def succ: () -> Time
771
-
772
760
  # Returns `true` if *time* represents Sunday.
773
761
  #
774
762
  # t = Time.local(1990, 4, 1) #=> 1990-04-01 00:00:00 -0600
@@ -531,23 +531,6 @@ interface _Foo
531
531
  end
532
532
  ```
533
533
 
534
- ### Extension declaration
535
-
536
- Extension is to model _open class_.
537
-
538
- ```
539
- extension Kernel (Pathname)
540
- def Pathname: (String) -> Pathname
541
- end
542
-
543
- extension Array[A] (ActiveSupport)
544
- def to: (Integer) -> Array[A]
545
- def from: (Integer) -> Array[A]
546
- def second: () -> A?
547
- def third: () -> A?
548
- end
549
- ```
550
-
551
534
  ### Type alias declaration
552
535
 
553
536
  You can declare an alias of types.