rbs 3.3.2 → 3.4.0.pre.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (128) hide show
  1. checksums.yaml +4 -4
  2. data/.github/workflows/comments.yml +2 -5
  3. data/.github/workflows/ruby.yml +7 -8
  4. data/.github/workflows/typecheck.yml +37 -0
  5. data/CHANGELOG.md +50 -0
  6. data/Gemfile +1 -1
  7. data/Gemfile.lock +11 -11
  8. data/Steepfile +2 -2
  9. data/core/array.rbs +19 -49
  10. data/core/basic_object.rbs +2 -2
  11. data/core/comparable.rbs +17 -8
  12. data/core/complex.rbs +82 -43
  13. data/core/data.rbs +2 -4
  14. data/core/dir.rbs +635 -295
  15. data/core/enumerable.rbs +11 -18
  16. data/core/enumerator.rbs +37 -31
  17. data/core/errors.rbs +4 -0
  18. data/core/false_class.rbs +34 -15
  19. data/core/fiber.rbs +23 -0
  20. data/core/file.rbs +329 -120
  21. data/core/float.rbs +17 -32
  22. data/core/gc.rbs +17 -11
  23. data/core/hash.rbs +22 -44
  24. data/core/integer.rbs +82 -113
  25. data/core/io/buffer.rbs +90 -47
  26. data/core/io.rbs +39 -116
  27. data/core/kernel.rbs +442 -489
  28. data/core/match_data.rbs +55 -56
  29. data/core/module.rbs +45 -1
  30. data/core/nil_class.rbs +98 -35
  31. data/core/numeric.rbs +22 -32
  32. data/core/object_space/weak_key_map.rbs +102 -0
  33. data/core/process.rbs +1242 -655
  34. data/core/ractor.rbs +139 -120
  35. data/core/range.rbs +100 -4
  36. data/core/rational.rbs +0 -4
  37. data/core/rbs/unnamed/argf.rbs +16 -8
  38. data/core/rbs/unnamed/env_class.rbs +0 -24
  39. data/core/refinement.rbs +8 -0
  40. data/core/regexp.rbs +1149 -598
  41. data/core/ruby_vm.rbs +126 -12
  42. data/core/rubygems/platform.rbs +9 -0
  43. data/core/rubygems/rubygems.rbs +1 -1
  44. data/core/rubygems/version.rbs +5 -1
  45. data/core/set.rbs +20 -22
  46. data/core/signal.rbs +4 -4
  47. data/core/string.rbs +283 -230
  48. data/core/string_io.rbs +2 -14
  49. data/core/struct.rbs +404 -24
  50. data/core/symbol.rbs +1 -19
  51. data/core/thread.rbs +29 -12
  52. data/core/time.rbs +227 -104
  53. data/core/trace_point.rbs +2 -5
  54. data/core/true_class.rbs +54 -21
  55. data/core/warning.rbs +14 -11
  56. data/docs/data_and_struct.md +29 -0
  57. data/docs/syntax.md +3 -5
  58. data/docs/tools.md +1 -0
  59. data/ext/rbs_extension/lexer.c +643 -559
  60. data/ext/rbs_extension/lexer.re +5 -1
  61. data/ext/rbs_extension/parser.c +12 -3
  62. data/ext/rbs_extension/unescape.c +7 -47
  63. data/lib/rbs/cli/diff.rb +4 -1
  64. data/lib/rbs/cli/validate.rb +280 -0
  65. data/lib/rbs/cli.rb +2 -194
  66. data/lib/rbs/collection/config.rb +5 -6
  67. data/lib/rbs/collection/sources/git.rb +1 -1
  68. data/lib/rbs/collection.rb +1 -0
  69. data/lib/rbs/diff.rb +7 -4
  70. data/lib/rbs/errors.rb +11 -0
  71. data/lib/rbs/test/errors.rb +4 -1
  72. data/lib/rbs/test/guaranteed.rb +2 -3
  73. data/lib/rbs/test/type_check.rb +15 -10
  74. data/lib/rbs/test.rb +3 -3
  75. data/lib/rbs/types.rb +29 -0
  76. data/lib/rbs/unit_test/convertibles.rb +176 -0
  77. data/lib/rbs/unit_test/spy.rb +136 -0
  78. data/lib/rbs/unit_test/type_assertions.rb +341 -0
  79. data/lib/rbs/unit_test/with_aliases.rb +143 -0
  80. data/lib/rbs/unit_test.rb +6 -0
  81. data/lib/rbs/version.rb +1 -1
  82. data/sig/cli/validate.rbs +43 -0
  83. data/sig/diff.rbs +3 -1
  84. data/sig/errors.rbs +8 -0
  85. data/sig/rbs.rbs +1 -1
  86. data/sig/test/errors.rbs +52 -0
  87. data/sig/test/guranteed.rbs +9 -0
  88. data/sig/test/type_check.rbs +19 -0
  89. data/sig/test.rbs +82 -0
  90. data/sig/types.rbs +6 -1
  91. data/sig/unit_test/convertibles.rbs +154 -0
  92. data/sig/unit_test/spy.rbs +28 -0
  93. data/sig/unit_test/type_assertions.rbs +194 -0
  94. data/sig/unit_test/with_aliases.rbs +136 -0
  95. data/stdlib/base64/0/base64.rbs +307 -45
  96. data/stdlib/bigdecimal/0/big_decimal.rbs +35 -15
  97. data/stdlib/coverage/0/coverage.rbs +2 -2
  98. data/stdlib/csv/0/csv.rbs +25 -55
  99. data/stdlib/date/0/date.rbs +1 -43
  100. data/stdlib/date/0/date_time.rbs +1 -13
  101. data/stdlib/delegate/0/delegator.rbs +186 -0
  102. data/stdlib/delegate/0/kernel.rbs +47 -0
  103. data/stdlib/delegate/0/simple_delegator.rbs +98 -0
  104. data/stdlib/did_you_mean/0/did_you_mean.rbs +1 -1
  105. data/stdlib/erb/0/erb.rbs +2 -2
  106. data/stdlib/fileutils/0/fileutils.rbs +0 -19
  107. data/stdlib/io-console/0/io-console.rbs +12 -1
  108. data/stdlib/ipaddr/0/ipaddr.rbs +2 -1
  109. data/stdlib/json/0/json.rbs +320 -81
  110. data/stdlib/logger/0/logger.rbs +9 -5
  111. data/stdlib/monitor/0/monitor.rbs +78 -0
  112. data/stdlib/net-http/0/net-http.rbs +1880 -543
  113. data/stdlib/objspace/0/objspace.rbs +19 -13
  114. data/stdlib/openssl/0/openssl.rbs +508 -127
  115. data/stdlib/optparse/0/optparse.rbs +25 -11
  116. data/stdlib/pathname/0/pathname.rbs +1 -1
  117. data/stdlib/pp/0/pp.rbs +2 -5
  118. data/stdlib/prettyprint/0/prettyprint.rbs +2 -2
  119. data/stdlib/pstore/0/pstore.rbs +2 -4
  120. data/stdlib/rdoc/0/comment.rbs +1 -2
  121. data/stdlib/resolv/0/resolv.rbs +4 -2
  122. data/stdlib/socket/0/socket.rbs +2 -2
  123. data/stdlib/socket/0/unix_socket.rbs +2 -2
  124. data/stdlib/strscan/0/string_scanner.rbs +3 -2
  125. data/stdlib/tempfile/0/tempfile.rbs +1 -1
  126. data/stdlib/uri/0/common.rbs +245 -123
  127. metadata +23 -4
  128. data/lib/rbs/test/spy.rb +0 -6
@@ -0,0 +1,102 @@
1
+ %a{annotate:rdoc:skip}
2
+ module ObjectSpace
3
+ # <!-- rdoc-file=weakmap.c -->
4
+ # An ObjectSpace::WeakKeyMap object holds references to any objects, but objects
5
+ # uses as keys can be garbage collected.
6
+ #
7
+ # Objects used as values can't be garbage collected until the key is.
8
+ #
9
+ class WeakKeyMap[Key, Value]
10
+ public
11
+
12
+ # <!--
13
+ # rdoc-file=weakmap.c
14
+ # - map[key] -> value
15
+ # -->
16
+ # Returns the value associated with the given `key` if found.
17
+ #
18
+ # If `key` is not found, returns `nil`.
19
+ #
20
+ def []: (Key) -> Value?
21
+
22
+ # <!--
23
+ # rdoc-file=weakmap.c
24
+ # - map[key] = value -> value
25
+ # -->
26
+ # Associates the given `value` with the given `key`; returns `value`.
27
+ #
28
+ # The reference to `key` is weak, so when there is no other reference to `key`
29
+ # it may be garbage collected.
30
+ #
31
+ # If the given `key` exists, replaces its value with the given `value`; the
32
+ # ordering is not affected
33
+ #
34
+ def []=: (Key, Value?) -> Value?
35
+
36
+ # <!--
37
+ # rdoc-file=weakmap.c
38
+ # - map.clear -> self
39
+ # -->
40
+ # Removes all map entries; returns `self`.
41
+ #
42
+ def clear: () -> self
43
+
44
+ # <!--
45
+ # rdoc-file=weakmap.c
46
+ # - map.delete(key) -> value or nil
47
+ # - map.delete(key) {|key| ... } -> object
48
+ # -->
49
+ # Deletes the entry for the given `key` and returns its associated value.
50
+ #
51
+ # If no block is given and `key` is found, deletes the entry and returns the
52
+ # associated value:
53
+ # m = ObjectSpace::WeakKeyMap.new
54
+ # m["foo"] = 1
55
+ # m.delete("foo") # => 1
56
+ # m["foo"] # => nil
57
+ #
58
+ # If no block given and `key` is not found, returns `nil`.
59
+ #
60
+ # If a block is given and `key` is found, ignores the block, deletes the entry,
61
+ # and returns the associated value:
62
+ # m = ObjectSpace::WeakKeyMap.new
63
+ # m["foo"] = 2
64
+ # h.delete("foo") { |key| raise 'Will never happen'} # => 2
65
+ #
66
+ # If a block is given and `key` is not found, calls the block and returns the
67
+ # block's return value:
68
+ # m = ObjectSpace::WeakKeyMap.new
69
+ # h.delete("nosuch") { |key| "Key #{key} not found" } # => "Key nosuch not found"
70
+ #
71
+ def delete: (Key) -> Value?
72
+ | [T] (Key) { (Key) -> T } -> (Value | T)
73
+
74
+ # <!--
75
+ # rdoc-file=weakmap.c
76
+ # - map.getkey(key) -> existing_key or nil
77
+ # -->
78
+ # Returns the existing equal key if it exists, otherwise returns `nil`.
79
+ #
80
+ def getkey: (untyped) -> Key?
81
+
82
+ # <!--
83
+ # rdoc-file=weakmap.c
84
+ # - map.inspect -> new_string
85
+ # -->
86
+ # Returns a new String containing informations about the map:
87
+ #
88
+ # m = ObjectSpace::WeakKeyMap.new
89
+ # m[key] = value
90
+ # m.inspect # => "#<ObjectSpace::WeakKeyMap:0x00000001028dcba8 size=1>"
91
+ #
92
+ def inspect: () -> String
93
+
94
+ # <!--
95
+ # rdoc-file=weakmap.c
96
+ # - hash.key?(key) -> true or false
97
+ # -->
98
+ # Returns `true` if `key` is a key in `self`, otherwise `false`.
99
+ #
100
+ def key?: (Key) -> bool
101
+ end
102
+ end