rbs 0.14.0 → 0.18.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.github/workflows/ruby.yml +8 -4
- data/CHANGELOG.md +35 -0
- data/Gemfile +1 -0
- data/README.md +1 -1
- data/Rakefile +19 -1
- data/Steepfile +0 -1
- data/bin/test_runner.rb +15 -1
- data/{stdlib/builtin → core}/array.rbs +124 -120
- data/{stdlib/builtin → core}/basic_object.rbs +0 -0
- data/{stdlib/builtin → core}/binding.rbs +0 -0
- data/core/builtin.rbs +70 -0
- data/{stdlib/builtin → core}/class.rbs +0 -0
- data/{stdlib/builtin → core}/comparable.rbs +0 -0
- data/{stdlib/builtin → core}/complex.rbs +0 -0
- data/{stdlib/builtin → core}/constants.rbs +0 -0
- data/{stdlib/builtin → core}/data.rbs +0 -0
- data/{stdlib/builtin → core}/deprecated.rbs +0 -0
- data/{stdlib/builtin → core}/dir.rbs +1 -1
- data/{stdlib/builtin → core}/encoding.rbs +0 -0
- data/{stdlib/builtin → core}/enumerable.rbs +67 -60
- data/{stdlib/builtin → core}/enumerator.rbs +5 -5
- data/{stdlib/builtin → core}/errno.rbs +0 -0
- data/{stdlib/builtin → core}/errors.rbs +1 -1
- data/{stdlib/builtin → core}/exception.rbs +0 -0
- data/{stdlib/builtin → core}/false_class.rbs +0 -0
- data/{stdlib/builtin → core}/fiber.rbs +0 -0
- data/{stdlib/builtin → core}/fiber_error.rbs +0 -0
- data/{stdlib/builtin → core}/file.rbs +0 -0
- data/{stdlib/builtin → core}/file_test.rbs +0 -0
- data/{stdlib/builtin → core}/float.rbs +0 -0
- data/{stdlib/builtin → core}/gc.rbs +2 -2
- data/{stdlib/builtin → core}/hash.rbs +15 -15
- data/{stdlib/builtin → core}/integer.rbs +0 -0
- data/{stdlib/builtin → core}/io.rbs +6 -6
- data/{stdlib/builtin → core}/kernel.rbs +1 -85
- data/{stdlib/builtin → core}/marshal.rbs +0 -0
- data/{stdlib/builtin → core}/match_data.rbs +0 -0
- data/{stdlib/builtin → core}/math.rbs +0 -0
- data/{stdlib/builtin → core}/method.rbs +0 -0
- data/{stdlib/builtin → core}/module.rbs +13 -13
- data/{stdlib/builtin → core}/nil_class.rbs +0 -0
- data/{stdlib/builtin → core}/numeric.rbs +0 -0
- data/{stdlib/builtin → core}/object.rbs +1 -1
- data/core/object_space.rbs +98 -0
- data/{stdlib/builtin → core}/proc.rbs +0 -0
- data/{stdlib/builtin → core}/process.rbs +0 -0
- data/{stdlib/builtin → core}/random.rbs +1 -1
- data/{stdlib/builtin → core}/range.rbs +3 -3
- data/{stdlib/builtin → core}/rational.rbs +0 -0
- data/{stdlib/builtin → core}/rb_config.rbs +0 -0
- data/{stdlib/builtin → core}/regexp.rbs +0 -0
- data/{stdlib/builtin → core}/ruby_vm.rbs +0 -0
- data/{stdlib/builtin → core}/signal.rbs +0 -0
- data/{stdlib/builtin → core}/string.rbs +6 -6
- data/{stdlib/builtin → core}/string_io.rbs +7 -7
- data/{stdlib/builtin → core}/struct.rbs +2 -2
- data/{stdlib/builtin → core}/symbol.rbs +1 -1
- data/{stdlib/builtin → core}/thread.rbs +4 -4
- data/{stdlib/builtin → core}/thread_group.rbs +0 -0
- data/{stdlib/builtin → core}/time.rbs +0 -0
- data/{stdlib/builtin → core}/trace_point.rbs +0 -0
- data/{stdlib/builtin → core}/true_class.rbs +1 -1
- data/{stdlib/builtin → core}/unbound_method.rbs +0 -0
- data/{stdlib/builtin → core}/warning.rbs +0 -0
- data/docs/repo.md +125 -0
- data/docs/syntax.md +50 -6
- data/lib/rbs.rb +1 -0
- data/lib/rbs/cli.rb +105 -103
- data/lib/rbs/definition.rb +9 -4
- data/lib/rbs/definition_builder.rb +50 -17
- data/lib/rbs/environment_loader.rb +79 -105
- data/lib/rbs/environment_walker.rb +70 -35
- data/lib/rbs/parser.rb +404 -397
- data/lib/rbs/parser.y +18 -9
- data/lib/rbs/prototype/rb.rb +186 -25
- data/lib/rbs/prototype/runtime.rb +18 -7
- data/lib/rbs/repository.rb +121 -0
- data/lib/rbs/test/hook.rb +27 -15
- data/lib/rbs/test/setup.rb +5 -3
- data/lib/rbs/test/tester.rb +4 -1
- data/lib/rbs/test/type_check.rb +16 -5
- data/lib/rbs/type_name.rb +2 -1
- data/lib/rbs/vendorer.rb +38 -16
- data/lib/rbs/version.rb +1 -1
- data/sig/cli.rbs +58 -0
- data/sig/constant_table.rbs +1 -1
- data/sig/declarations.rbs +1 -1
- data/sig/definition.rbs +9 -4
- data/sig/definition_builder.rbs +4 -1
- data/sig/environment_loader.rbs +92 -46
- data/sig/members.rbs +2 -2
- data/sig/method_types.rbs +1 -1
- data/sig/namespace.rbs +1 -1
- data/sig/polyfill.rbs +42 -0
- data/sig/rbs.rbs +8 -0
- data/sig/repository.rbs +79 -0
- data/sig/vendorer.rbs +44 -0
- data/stdlib/abbrev/{abbrev.rbs → 0/abbrev.rbs} +0 -0
- data/stdlib/base64/{base64.rbs → 0/base64.rbs} +1 -1
- data/stdlib/benchmark/{benchmark.rbs → 0/benchmark.rbs} +0 -0
- data/stdlib/{bigdecimal/math → bigdecimal-math/0}/big_math.rbs +0 -0
- data/stdlib/bigdecimal/{big_decimal.rbs → 0/big_decimal.rbs} +0 -0
- data/stdlib/coverage/{coverage.rbs → 0/coverage.rbs} +2 -2
- data/stdlib/csv/{csv.rbs → 0/csv.rbs} +4 -4
- data/stdlib/date/{date.rbs → 0/date.rbs} +2 -2
- data/stdlib/date/{date_time.rbs → 0/date_time.rbs} +1 -1
- data/stdlib/dbm/0/dbm.rbs +277 -0
- data/stdlib/erb/{erb.rbs → 0/erb.rbs} +0 -0
- data/stdlib/fiber/{fiber.rbs → 0/fiber.rbs} +0 -0
- data/stdlib/find/{find.rbs → 0/find.rbs} +2 -2
- data/stdlib/forwardable/{forwardable.rbs → 0/forwardable.rbs} +0 -0
- data/stdlib/ipaddr/{ipaddr.rbs → 0/ipaddr.rbs} +0 -0
- data/stdlib/json/{json.rbs → 0/json.rbs} +0 -0
- data/stdlib/logger/{formatter.rbs → 0/formatter.rbs} +0 -0
- data/stdlib/logger/{log_device.rbs → 0/log_device.rbs} +1 -1
- data/stdlib/logger/{logger.rbs → 0/logger.rbs} +1 -1
- data/stdlib/logger/{period.rbs → 0/period.rbs} +0 -0
- data/stdlib/logger/{severity.rbs → 0/severity.rbs} +0 -0
- data/stdlib/mutex_m/{mutex_m.rbs → 0/mutex_m.rbs} +0 -0
- data/stdlib/pathname/{pathname.rbs → 0/pathname.rbs} +39 -39
- data/stdlib/prime/{integer-extension.rbs → 0/integer-extension.rbs} +0 -0
- data/stdlib/prime/{prime.rbs → 0/prime.rbs} +1 -1
- data/stdlib/pstore/0/pstore.rbs +287 -0
- data/stdlib/pty/{pty.rbs → 0/pty.rbs} +1 -1
- data/stdlib/securerandom/{securerandom.rbs → 0/securerandom.rbs} +0 -0
- data/stdlib/set/{set.rbs → 0/set.rbs} +10 -10
- data/stdlib/singleton/0/singleton.rbs +111 -0
- data/stdlib/tmpdir/{tmpdir.rbs → 0/tmpdir.rbs} +0 -0
- data/stdlib/tsort/0/cyclic.rbs +4 -0
- data/stdlib/tsort/0/interfaces.rbs +19 -0
- data/stdlib/tsort/0/tsort.rbs +363 -0
- data/stdlib/uri/{file.rbs → 0/file.rbs} +0 -0
- data/stdlib/uri/{generic.rbs → 0/generic.rbs} +1 -1
- data/stdlib/uri/{http.rbs → 0/http.rbs} +0 -0
- data/stdlib/uri/{https.rbs → 0/https.rbs} +0 -0
- data/stdlib/uri/{ldap.rbs → 0/ldap.rbs} +0 -0
- data/stdlib/uri/{ldaps.rbs → 0/ldaps.rbs} +0 -0
- data/stdlib/yaml/0/dbm.rbs +221 -0
- data/stdlib/yaml/0/store.rbs +53 -0
- data/stdlib/zlib/{zlib.rbs → 0/zlib.rbs} +0 -0
- data/steep/Gemfile.lock +9 -9
- metadata +108 -94
- data/stdlib/builtin/builtin.rbs +0 -42
File without changes
|
File without changes
|
data/core/builtin.rbs
ADDED
@@ -0,0 +1,70 @@
|
|
1
|
+
interface _ToI
|
2
|
+
def to_i: -> Integer
|
3
|
+
end
|
4
|
+
|
5
|
+
interface _ToInt
|
6
|
+
def to_int: -> Integer
|
7
|
+
end
|
8
|
+
|
9
|
+
interface _ToS
|
10
|
+
def to_s: -> String
|
11
|
+
end
|
12
|
+
|
13
|
+
interface _ToStr
|
14
|
+
def to_str: () -> String
|
15
|
+
end
|
16
|
+
|
17
|
+
interface _ToHash[K, V]
|
18
|
+
def to_hash: () -> Hash[K, V]
|
19
|
+
end
|
20
|
+
|
21
|
+
interface _ToProc
|
22
|
+
def to_proc: () -> untyped
|
23
|
+
end
|
24
|
+
|
25
|
+
interface _ToPath
|
26
|
+
def to_path: () -> String
|
27
|
+
end
|
28
|
+
|
29
|
+
interface _Each[out A]
|
30
|
+
def each: { (A) -> void } -> void
|
31
|
+
end
|
32
|
+
|
33
|
+
interface _Reader
|
34
|
+
def read: (?int length, ?string outbuf) -> String?
|
35
|
+
end
|
36
|
+
|
37
|
+
interface _Writer
|
38
|
+
# Writes the +data+ string. Returns the number of bytes written
|
39
|
+
def write: (*_ToS data) -> Integer
|
40
|
+
end
|
41
|
+
|
42
|
+
interface _Rewindable
|
43
|
+
# Positions the stream to the beginning of input, resetting `lineno` to zero.
|
44
|
+
#
|
45
|
+
def rewind: () -> Integer
|
46
|
+
end
|
47
|
+
|
48
|
+
interface _ToIO
|
49
|
+
def to_io: () -> IO
|
50
|
+
end
|
51
|
+
|
52
|
+
interface _Exception
|
53
|
+
def exception: () -> Exception
|
54
|
+
| (String arg0) -> Exception
|
55
|
+
end
|
56
|
+
|
57
|
+
type int = Integer | _ToInt
|
58
|
+
type real = Integer | Float | Rational
|
59
|
+
|
60
|
+
type string = String | _ToStr
|
61
|
+
type encoding = Encoding | string
|
62
|
+
|
63
|
+
type io = IO | _ToIO
|
64
|
+
|
65
|
+
# `boolish` is a type for documentation.
|
66
|
+
# It means the value of this type is only for testing a condition.
|
67
|
+
# Unlike `bool` type, it doesn't require the value is one of `true` or `false`.
|
68
|
+
# Any Ruby object can have `boolish` type.
|
69
|
+
#
|
70
|
+
type boolish = top
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
@@ -5,7 +5,7 @@
|
|
5
5
|
# objects in the collection must also implement a meaningful `<=>`
|
6
6
|
# operator, as these methods rely on an ordering between members of the
|
7
7
|
# collection.
|
8
|
-
module Enumerable[unchecked out Elem
|
8
|
+
module Enumerable[unchecked out Elem]: _Each[Elem]
|
9
9
|
# Passes each element of the collection to the given block. The method
|
10
10
|
# returns `true` if the block never returns `false` or `nil` . If the
|
11
11
|
# block is not given, Ruby adds an implicit block of `{ |obj| obj }` which
|
@@ -22,7 +22,7 @@ module Enumerable[unchecked out Elem, out Return]: _Each[Elem, Return]
|
|
22
22
|
# [nil, true, 99].all? #=> false
|
23
23
|
# [].all? #=> true
|
24
24
|
def all?: () -> bool
|
25
|
-
| () { (Elem
|
25
|
+
| () { (Elem) -> boolish } -> bool
|
26
26
|
|
27
27
|
# Passes each element of the collection to the given block. The method
|
28
28
|
# returns `true` if the block ever returns a value other than `false` or
|
@@ -43,7 +43,7 @@ module Enumerable[unchecked out Elem, out Return]: _Each[Elem, Return]
|
|
43
43
|
# [].any? #=> false
|
44
44
|
# ```
|
45
45
|
def `any?`: () -> bool
|
46
|
-
| () { (Elem
|
46
|
+
| () { (Elem) -> boolish } -> bool
|
47
47
|
|
48
48
|
def collect: [U] () { (Elem arg0) -> U } -> ::Array[U]
|
49
49
|
| () -> ::Enumerator[Elem, ::Array[untyped]]
|
@@ -62,28 +62,28 @@ module Enumerable[unchecked out Elem, out Return]: _Each[Elem, Return]
|
|
62
62
|
# ary.count{ |x| x%2==0 } #=> 3
|
63
63
|
# ```
|
64
64
|
def count: () -> Integer
|
65
|
-
| (?untyped
|
66
|
-
| () { (Elem
|
65
|
+
| (?untyped) -> Integer
|
66
|
+
| () { (Elem) -> boolish } -> Integer
|
67
67
|
|
68
68
|
def cycle: (?Integer n) { (Elem arg0) -> untyped } -> NilClass
|
69
|
-
| (?Integer n) -> ::Enumerator[Elem,
|
69
|
+
| (?Integer n) -> ::Enumerator[Elem, NilClass]
|
70
70
|
|
71
|
-
def detect: (?Proc ifnone) { (Elem
|
72
|
-
| (?Proc ifnone) -> ::Enumerator[Elem,
|
71
|
+
def detect: (?Proc ifnone) { (Elem) -> boolish } -> Elem?
|
72
|
+
| (?Proc ifnone) -> ::Enumerator[Elem, Elem?]
|
73
73
|
|
74
74
|
def drop: (Integer n) -> ::Array[Elem]
|
75
75
|
|
76
|
-
def drop_while: () { (Elem
|
77
|
-
| () -> ::Enumerator[Elem,
|
76
|
+
def drop_while: () { (Elem) -> boolish } -> ::Array[Elem]
|
77
|
+
| () -> ::Enumerator[Elem, ::Array[Elem]]
|
78
78
|
|
79
79
|
def each_cons: (Integer n) { (::Array[Elem] arg0) -> untyped } -> NilClass
|
80
|
-
| (Integer n) -> ::Enumerator[::Array[Elem],
|
80
|
+
| (Integer n) -> ::Enumerator[::Array[Elem], NilClass]
|
81
81
|
|
82
|
-
def each_with_index: () { (Elem arg0, Integer arg1) -> untyped } ->
|
83
|
-
| () -> ::Enumerator[[ Elem, Integer ],
|
82
|
+
def each_with_index: () { (Elem arg0, Integer arg1) -> untyped } -> void
|
83
|
+
| () -> ::Enumerator[[ Elem, Integer ], void]
|
84
84
|
|
85
85
|
def each_with_object: [U] (U arg0) { (Elem arg0, untyped arg1) -> untyped } -> U
|
86
|
-
| [U] (U arg0) -> ::Enumerator[[ Elem, U ],
|
86
|
+
| [U] (U arg0) -> ::Enumerator[[ Elem, U ], U]
|
87
87
|
|
88
88
|
# Returns an array containing the items in *enum* .
|
89
89
|
#
|
@@ -96,15 +96,15 @@ module Enumerable[unchecked out Elem, out Return]: _Each[Elem, Return]
|
|
96
96
|
# ```
|
97
97
|
def entries: () -> ::Array[Elem]
|
98
98
|
|
99
|
-
def find_all: () { (Elem
|
100
|
-
| () -> ::Enumerator[Elem,
|
99
|
+
def find_all: () { (Elem) -> boolish } -> ::Array[Elem]
|
100
|
+
| () -> ::Enumerator[Elem, ::Array[Elem]]
|
101
101
|
|
102
102
|
alias select find_all
|
103
103
|
alias filter find_all
|
104
104
|
|
105
105
|
def find_index: (?untyped value) -> Integer?
|
106
|
-
| () { (Elem
|
107
|
-
| () -> ::Enumerator[Elem,
|
106
|
+
| () { (Elem) -> boolish } -> Integer?
|
107
|
+
| () -> ::Enumerator[Elem, Integer?]
|
108
108
|
|
109
109
|
# Returns the first element, or the first `n` elements, of the enumerable.
|
110
110
|
# If the enumerable is empty, the first form returns `nil`, and the
|
@@ -118,7 +118,7 @@ module Enumerable[unchecked out Elem, out Return]: _Each[Elem, Return]
|
|
118
118
|
# [].first(10) #=> []
|
119
119
|
# ```
|
120
120
|
def first: () -> Elem?
|
121
|
-
| (
|
121
|
+
| (Integer n) -> ::Array[Elem]?
|
122
122
|
|
123
123
|
def grep: (untyped arg0) -> ::Array[Elem]
|
124
124
|
| [U] (untyped arg0) { (Elem arg0) -> U } -> ::Array[U]
|
@@ -127,7 +127,7 @@ module Enumerable[unchecked out Elem, out Return]: _Each[Elem, Return]
|
|
127
127
|
| [U] (untyped arg0) { (Elem arg0) -> U } -> ::Array[U]
|
128
128
|
|
129
129
|
def group_by: [U] () { (Elem arg0) -> U } -> ::Hash[U, ::Array[Elem]]
|
130
|
-
| () -> ::Enumerator[Elem,
|
130
|
+
| () -> ::Enumerator[Elem, ::Array[Elem]]
|
131
131
|
|
132
132
|
def `include?`: (untyped arg0) -> bool
|
133
133
|
|
@@ -157,13 +157,13 @@ module Enumerable[unchecked out Elem, out Return]: _Each[Elem, Return]
|
|
157
157
|
# ```
|
158
158
|
def max: () -> Elem?
|
159
159
|
| () { (Elem arg0, Elem arg1) -> Integer } -> Elem?
|
160
|
-
| (
|
161
|
-
| (
|
160
|
+
| (Integer arg0) -> ::Array[Elem]
|
161
|
+
| (Integer arg0) { (Elem arg0, Elem arg1) -> Integer } -> ::Array[Elem]
|
162
162
|
|
163
|
-
def max_by: () -> ::Enumerator[Elem,
|
163
|
+
def max_by: () -> ::Enumerator[Elem, Elem?]
|
164
164
|
| () { (Elem arg0) -> (Comparable | ::Array[untyped]) } -> Elem?
|
165
|
-
| (
|
166
|
-
| (
|
165
|
+
| (Integer arg0) -> ::Enumerator[Elem, ::Array[Elem]]
|
166
|
+
| (Integer arg0) { (Elem arg0) -> (Comparable | ::Array[untyped]) } -> ::Array[Elem]
|
167
167
|
|
168
168
|
# Returns the object in *enum* with the minimum value. The first form
|
169
169
|
# assumes all objects implement `Comparable` ; the second uses the block
|
@@ -186,13 +186,13 @@ module Enumerable[unchecked out Elem, out Return]: _Each[Elem, Return]
|
|
186
186
|
# ```
|
187
187
|
def min: () -> Elem?
|
188
188
|
| () { (Elem arg0, Elem arg1) -> Integer } -> Elem?
|
189
|
-
| (
|
190
|
-
| (
|
189
|
+
| (Integer arg0) -> ::Array[Elem]
|
190
|
+
| (Integer arg0) { (Elem arg0, Elem arg1) -> Integer } -> ::Array[Elem]
|
191
191
|
|
192
|
-
def min_by: () -> ::Enumerator[Elem,
|
192
|
+
def min_by: () -> ::Enumerator[Elem, Elem?]
|
193
193
|
| () { (Elem arg0) -> (Comparable | ::Array[untyped]) } -> Elem?
|
194
|
-
| (
|
195
|
-
| (
|
194
|
+
| (Integer arg0) -> ::Enumerator[Elem, ::Array[Elem]]
|
195
|
+
| (Integer arg0) { (Elem arg0) -> (Comparable | ::Array[untyped]) } -> ::Array[Elem]
|
196
196
|
|
197
197
|
# Returns a two element array which contains the minimum and the maximum
|
198
198
|
# value in the enumerable. The first form assumes all objects implement
|
@@ -207,7 +207,7 @@ module Enumerable[unchecked out Elem, out Return]: _Each[Elem, Return]
|
|
207
207
|
| () { (Elem arg0, Elem arg1) -> Integer } -> [ Elem?, Elem? ]
|
208
208
|
|
209
209
|
def minmax_by: () -> [ Elem?, Elem? ]
|
210
|
-
| () { (Elem arg0) -> (Comparable | ::Array[untyped]) } ->
|
210
|
+
| () { (Elem arg0) -> (Comparable | ::Array[untyped]) } -> [ Elem?, Elem? ]
|
211
211
|
|
212
212
|
# Passes each element of the collection to the given block. The method
|
213
213
|
# returns `true` if the block never returns `true` for all elements. If
|
@@ -228,7 +228,7 @@ module Enumerable[unchecked out Elem, out Return]: _Each[Elem, Return]
|
|
228
228
|
# [nil, false, true].none? #=> false
|
229
229
|
# ```
|
230
230
|
def none?: () -> bool
|
231
|
-
| () { (Elem
|
231
|
+
| () { (Elem) -> boolish } -> bool
|
232
232
|
|
233
233
|
# Passes each element of the collection to the given block. The method
|
234
234
|
# returns `true` if the block returns `true` exactly once. If the block is
|
@@ -249,16 +249,16 @@ module Enumerable[unchecked out Elem, out Return]: _Each[Elem, Return]
|
|
249
249
|
# [].one? #=> false
|
250
250
|
# ```
|
251
251
|
def one?: () -> bool
|
252
|
-
| () { (Elem
|
252
|
+
| () { (Elem) -> boolish } -> bool
|
253
253
|
|
254
|
-
def partition: () { (Elem
|
255
|
-
| () -> ::Enumerator[Elem,
|
254
|
+
def partition: () { (Elem) -> boolish } -> [ ::Array[Elem], ::Array[Elem] ]
|
255
|
+
| () -> ::Enumerator[Elem, [ ::Array[Elem], ::Array[Elem] ]]
|
256
256
|
|
257
|
-
def reject: () { (Elem
|
258
|
-
| () -> ::Enumerator[Elem,
|
257
|
+
def reject: () { (Elem) -> boolish } -> ::Array[Elem]
|
258
|
+
| () -> ::Enumerator[Elem, ::Array[Elem]]
|
259
259
|
|
260
|
-
def reverse_each: () { (Elem arg0) -> untyped } ->
|
261
|
-
| () -> ::Enumerator[Elem,
|
260
|
+
def reverse_each: () { (Elem arg0) -> untyped } -> void
|
261
|
+
| () -> ::Enumerator[Elem, void]
|
262
262
|
|
263
263
|
# Returns an array containing the items in *enum* sorted.
|
264
264
|
#
|
@@ -284,12 +284,12 @@ module Enumerable[unchecked out Elem, out Return]: _Each[Elem, Return]
|
|
284
284
|
| () { (Elem arg0, Elem arg1) -> Integer } -> ::Array[Elem]
|
285
285
|
|
286
286
|
def sort_by: () { (Elem arg0) -> (Comparable | ::Array[untyped]) } -> ::Array[Elem]
|
287
|
-
| () -> ::Enumerator[Elem,
|
287
|
+
| () -> ::Enumerator[Elem, ::Array[Elem]]
|
288
288
|
|
289
289
|
def take: (Integer n) -> ::Array[Elem]?
|
290
290
|
|
291
|
-
def take_while: () { (Elem
|
292
|
-
| () -> ::Enumerator[Elem,
|
291
|
+
def take_while: () { (Elem) -> boolish } -> ::Array[Elem]
|
292
|
+
| () -> ::Enumerator[Elem, ::Array[Elem]]
|
293
293
|
|
294
294
|
# Implemented in C++
|
295
295
|
# Returns the result of interpreting *enum* as a list of `[key, value]`
|
@@ -306,15 +306,22 @@ module Enumerable[unchecked out Elem, out Return]: _Each[Elem, Return]
|
|
306
306
|
# #=> {1=>1, 2=>4, 3=>9, 4=>16, 5=>25}
|
307
307
|
# ```
|
308
308
|
def to_h: () -> ::Hash[untyped, untyped]
|
309
|
+
| [T, U] () { (Elem) -> [T, U] } -> ::Hash[T, U]
|
309
310
|
|
310
|
-
def each_slice: (Integer n) { (::Array[Elem]
|
311
|
-
| (Integer n) -> ::Enumerator[::Array[Elem],
|
311
|
+
def each_slice: (Integer n) { (::Array[Elem]) -> untyped } -> NilClass
|
312
|
+
| (Integer n) -> ::Enumerator[::Array[Elem], NilClass]
|
312
313
|
|
313
|
-
|
314
|
-
|
314
|
+
interface _NotFound[T]
|
315
|
+
def call: () -> T
|
316
|
+
end
|
315
317
|
|
316
|
-
def
|
317
|
-
|
318
|
+
def find: () { (Elem) -> boolish } -> Elem?
|
319
|
+
| () -> ::Enumerator[Elem, Elem?]
|
320
|
+
| [T] (_NotFound[T] ifnone) { (Elem) -> boolish } -> (Elem | T)
|
321
|
+
| [T] (_NotFound[T] ifnone) -> ::Enumerator[Elem, Elem | T]
|
322
|
+
|
323
|
+
def flat_map: [U] () { (Elem) -> (Array[U] | U) } -> Array[U]
|
324
|
+
| () -> ::Enumerator[Elem, Array[untyped]]
|
318
325
|
|
319
326
|
def map: [U] () { (Elem arg0) -> U } -> ::Array[U]
|
320
327
|
| () -> ::Enumerator[Elem, ::Array[untyped]]
|
@@ -364,7 +371,7 @@ module Enumerable[unchecked out Elem, out Return]: _Each[Elem, Return]
|
|
364
371
|
# # show pythagorean triples less than 100
|
365
372
|
# p pythagorean_triples.take_while { |*, z| z < 100 }.force
|
366
373
|
# ```
|
367
|
-
def lazy: () -> Enumerator::Lazy[Elem,
|
374
|
+
def lazy: () -> Enumerator::Lazy[Elem, void]
|
368
375
|
|
369
376
|
def uniq: () -> ::Array[Elem]
|
370
377
|
| () { (Elem item) -> untyped } -> ::Array[Elem]
|
@@ -375,30 +382,30 @@ module Enumerable[unchecked out Elem, out Return]: _Each[Elem, Return]
|
|
375
382
|
| [U] (?U arg0) { (Elem arg0) -> U } -> U
|
376
383
|
|
377
384
|
def filter_map: [U] () { (Elem elem) -> (nil | false | U) } -> ::Array[U]
|
378
|
-
| () -> ::Enumerator[Elem,
|
385
|
+
| () -> ::Enumerator[Elem, ::Array[untyped]]
|
379
386
|
|
380
|
-
def chain: (*self enumerables) -> ::Enumerator::Chain[Elem
|
387
|
+
def chain: (*self enumerables) -> ::Enumerator::Chain[Elem]
|
381
388
|
|
382
389
|
def tally: () -> ::Hash[Elem, Integer]
|
383
390
|
|
384
|
-
def each_entry: () -> ::Enumerator[Elem,
|
391
|
+
def each_entry: () -> ::Enumerator[Elem, self]
|
385
392
|
| () { (Elem arg0) -> untyped } -> self
|
386
393
|
|
387
394
|
# variadic type parameter is not supported yet
|
388
395
|
# https://github.com/ruby/rbs/issues/21
|
389
|
-
def zip: [Elem2
|
390
|
-
| [U, Elem2
|
396
|
+
def zip: [Elem2] (::Enumerable[Elem2] enum) -> ::Array[[Elem, Elem2 | nil]]
|
397
|
+
| [U, Elem2] (::Enumerable[Elem2]) { ([Elem, Elem2 | nil]) -> U } -> nil
|
391
398
|
|
392
|
-
def chunk: () -> ::Enumerator[Elem,
|
393
|
-
|
|
399
|
+
def chunk: [U] () { (Elem elt) -> U } -> ::Enumerator[[U, Array[Elem]], void]
|
400
|
+
| () -> ::Enumerator[Elem, Enumerator[untyped, untyped]]
|
394
401
|
|
395
|
-
def chunk_while: () { (Elem elt_before, Elem elt_after) ->
|
402
|
+
def chunk_while: () { (Elem elt_before, Elem elt_after) -> boolish } -> ::Enumerator[::Array[Elem], void]
|
396
403
|
|
397
|
-
def slice_when: () { (Elem elt_before, Elem elt_after) ->
|
404
|
+
def slice_when: () { (Elem elt_before, Elem elt_after) -> boolish } -> ::Enumerator[::Array[Elem], void]
|
398
405
|
|
399
406
|
def slice_after: (untyped pattern) -> ::Enumerator[::Array[Elem], void]
|
400
|
-
| () { (Elem elt) ->
|
407
|
+
| () { (Elem elt) -> boolish } -> ::Enumerator[::Array[Elem], void]
|
401
408
|
|
402
409
|
def slice_before: (untyped pattern) -> ::Enumerator[::Array[Elem], void]
|
403
|
-
| () { (Elem elt) ->
|
410
|
+
| () { (Elem elt) -> boolish } -> ::Enumerator[::Array[Elem], void]
|
404
411
|
end
|
@@ -96,7 +96,7 @@
|
|
96
96
|
# # => [], [:b], [1], [:b, 1], [1, 2], [:b, 1, 2], 3
|
97
97
|
# ```
|
98
98
|
class Enumerator[unchecked out Elem, out Return] < Object
|
99
|
-
include Enumerable[Elem
|
99
|
+
include Enumerable[Elem]
|
100
100
|
|
101
101
|
def each: () { (Elem arg0) -> untyped } -> Return
|
102
102
|
| () -> self
|
@@ -242,8 +242,8 @@ class Enumerator[unchecked out Elem, out Return] < Object
|
|
242
242
|
| [U] (U arg0) -> ::Enumerator[[ Elem, U ], Return]
|
243
243
|
end
|
244
244
|
|
245
|
-
class Enumerator::Generator[out Elem
|
246
|
-
include Enumerable[Elem
|
245
|
+
class Enumerator::Generator[out Elem] < Object
|
246
|
+
include Enumerable[Elem]
|
247
247
|
end
|
248
248
|
|
249
249
|
class Enumerator::Lazy[out Elem, out Return] < Enumerator[Elem, Return]
|
@@ -257,6 +257,6 @@ class Enumerator::Yielder < Object
|
|
257
257
|
def to_proc: () -> Proc
|
258
258
|
end
|
259
259
|
|
260
|
-
class Enumerator::Chain[out Elem
|
261
|
-
include Enumerable[Elem
|
260
|
+
class Enumerator::Chain[out Elem] < Object
|
261
|
+
include Enumerable[Elem]
|
262
262
|
end
|
File without changes
|
@@ -266,7 +266,7 @@ class NoMethodError[T] < NameError[T]
|
|
266
266
|
#
|
267
267
|
# *receiver* argument stores an object whose method was called.
|
268
268
|
#
|
269
|
-
def initialize: (?string? msg, ?String? name, ?Array[untyped] args, ?
|
269
|
+
def initialize: (?string? msg, ?String? name, ?Array[untyped] args, ?boolish `private`, ?receiver: T?) -> void
|
270
270
|
|
271
271
|
public
|
272
272
|
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
@@ -42,7 +42,7 @@ module GC
|
|
42
42
|
# are not guaranteed to be future-compatible, and may be ignored if the
|
43
43
|
# underlying implementation does not support them.
|
44
44
|
#
|
45
|
-
def self.start: (?immediate_sweep:
|
45
|
+
def self.start: (?immediate_sweep: boolish immediate_sweep, ?immediate_mark: boolish immediate_mark, ?full_mark: boolish full_mark) -> nil
|
46
46
|
|
47
47
|
# Returns a Hash containing information about the GC.
|
48
48
|
#
|
@@ -132,7 +132,7 @@ module GC
|
|
132
132
|
| [K] (?Hash[K, untyped] hash) -> ::Hash[::Symbol | K, untyped]
|
133
133
|
| (Symbol key) -> untyped
|
134
134
|
|
135
|
-
def garbage_collect: (?immediate_sweep:
|
135
|
+
def garbage_collect: (?immediate_sweep: boolish immediate_sweep, ?immediate_mark: boolish immediate_mark, ?full_mark: boolish full_mark) -> nil
|
136
136
|
end
|
137
137
|
|
138
138
|
# internal constants
|
@@ -106,7 +106,7 @@
|
|
106
106
|
# See also Object#hash and Object#eql?
|
107
107
|
#
|
108
108
|
class Hash[unchecked out K, unchecked out V] < Object
|
109
|
-
include Enumerable[[K, V]
|
109
|
+
include Enumerable[[K, V]]
|
110
110
|
|
111
111
|
# Creates a new hash populated with the given objects.
|
112
112
|
#
|
@@ -143,7 +143,7 @@ class Hash[unchecked out K, unchecked out V] < Object
|
|
143
143
|
# h2 < h1 #=> false
|
144
144
|
# h1 < h1 #=> false
|
145
145
|
#
|
146
|
-
def <: (::Hash[
|
146
|
+
def <: [A, B] (::Hash[A, B]) -> bool
|
147
147
|
|
148
148
|
# Returns `true` if *hash* is subset of *other* or equals to *other*.
|
149
149
|
#
|
@@ -153,7 +153,7 @@ class Hash[unchecked out K, unchecked out V] < Object
|
|
153
153
|
# h2 <= h1 #=> false
|
154
154
|
# h1 <= h1 #=> true
|
155
155
|
#
|
156
|
-
def <=: (::Hash[
|
156
|
+
def <=: [A, B] (::Hash[A, B]) -> bool
|
157
157
|
|
158
158
|
# Equality---Two hashes are equal if they each contain the same number of keys
|
159
159
|
# and if each key-value pair is equal to (according to Object#==) the
|
@@ -183,7 +183,7 @@ class Hash[unchecked out K, unchecked out V] < Object
|
|
183
183
|
# h2 > h1 #=> true
|
184
184
|
# h1 > h1 #=> false
|
185
185
|
#
|
186
|
-
def >: (::Hash[
|
186
|
+
def >: [A, B] (::Hash[A, B]) -> bool
|
187
187
|
|
188
188
|
# Returns `true` if *other* is subset of *hash* or equals to *hash*.
|
189
189
|
#
|
@@ -193,7 +193,7 @@ class Hash[unchecked out K, unchecked out V] < Object
|
|
193
193
|
# h2 >= h1 #=> true
|
194
194
|
# h1 >= h1 #=> true
|
195
195
|
#
|
196
|
-
def >=: (::Hash[
|
196
|
+
def >=: [A, B] (::Hash[A, B]) -> bool
|
197
197
|
|
198
198
|
# Element Reference---Retrieves the *value* object corresponding to the *key*
|
199
199
|
# object. If not found, returns the default value (see Hash::new for details).
|
@@ -230,7 +230,7 @@ class Hash[unchecked out K, unchecked out V] < Object
|
|
230
230
|
#
|
231
231
|
def any?: () -> bool
|
232
232
|
| (untyped pattern) -> bool
|
233
|
-
| () { (K, V) ->
|
233
|
+
| () { (K, V) -> boolish } -> bool
|
234
234
|
|
235
235
|
# Searches through the hash comparing *obj* with the key using `==`. Returns the
|
236
236
|
# key-value pair (two elements array) or `nil` if no match is found. See
|
@@ -360,7 +360,7 @@ class Hash[unchecked out K, unchecked out V] < Object
|
|
360
360
|
# h = { "a" => 100, "b" => 200, "c" => 300 }
|
361
361
|
# h.delete_if {|key, value| key >= "b" } #=> {"a"=>100}
|
362
362
|
#
|
363
|
-
def delete_if: () { (K
|
363
|
+
def delete_if: () { (K, V) -> boolish } -> self
|
364
364
|
| () -> ::Enumerator[[ K, V ], self]
|
365
365
|
|
366
366
|
# Extracts the nested value specified by the sequence of *key* objects by
|
@@ -498,14 +498,14 @@ class Hash[unchecked out K, unchecked out V] < Object
|
|
498
498
|
#
|
499
499
|
# Hash#filter is an alias for Hash#select.
|
500
500
|
#
|
501
|
-
def filter: () { (K
|
501
|
+
def filter: () { (K, V) -> boolish } -> self
|
502
502
|
| () -> ::Enumerator[[ K, V ], self]
|
503
503
|
|
504
504
|
# Equivalent to Hash#keep_if, but returns `nil` if no changes were made.
|
505
505
|
#
|
506
506
|
# Hash#filter! is an alias for Hash#select!.
|
507
507
|
#
|
508
|
-
def filter!: () { (K
|
508
|
+
def filter!: () { (K, V) -> boolish } -> self?
|
509
509
|
| () -> ::Enumerator[[ K, V ], self?]
|
510
510
|
|
511
511
|
# Returns a new array that is a one-dimensional flattening of this hash. That
|
@@ -604,7 +604,7 @@ class Hash[unchecked out K, unchecked out V] < Object
|
|
604
604
|
#
|
605
605
|
# See also Hash#select!.
|
606
606
|
#
|
607
|
-
def keep_if: () { (K, V) ->
|
607
|
+
def keep_if: () { (K, V) -> boolish } -> self
|
608
608
|
| () -> ::Enumerator[[ K, V ], self]
|
609
609
|
|
610
610
|
# Returns the key of an occurrence of a given value. If the value is not found,
|
@@ -720,8 +720,8 @@ class Hash[unchecked out K, unchecked out V] < Object
|
|
720
720
|
#
|
721
721
|
# Hash#update is an alias for Hash#merge!.
|
722
722
|
#
|
723
|
-
def merge!:
|
724
|
-
|
|
723
|
+
def merge!: (*::Hash[K, V] other_hashes) -> self
|
724
|
+
| (*::Hash[K, V] other_hashes) { (K key, V oldval, V newval) -> (V) } -> self
|
725
725
|
|
726
726
|
# Searches through the hash comparing *obj* with the value using `==`. Returns
|
727
727
|
# the first key-value pair (two-element array) that matches. See also
|
@@ -758,19 +758,19 @@ class Hash[unchecked out K, unchecked out V] < Object
|
|
758
758
|
# h.reject {|k,v| v > 100} #=> {"a" => 100}
|
759
759
|
#
|
760
760
|
def reject: () -> ::Enumerator[[ K, V ], self]
|
761
|
-
| () { (K
|
761
|
+
| () { (K, V) -> boolish } -> self
|
762
762
|
|
763
763
|
# Equivalent to Hash#delete_if, but returns `nil` if no changes were made.
|
764
764
|
#
|
765
765
|
def reject!: () -> ::Enumerator[[ K, V ], self?]
|
766
|
-
| () { (K
|
766
|
+
| () { (K, V) -> boolish } -> self?
|
767
767
|
|
768
768
|
# Replaces the contents of *hsh* with the contents of *other_hash*.
|
769
769
|
#
|
770
770
|
# h = { "a" => 100, "b" => 200 }
|
771
771
|
# h.replace({ "c" => 300, "d" => 400 }) #=> {"c"=>300, "d"=>400}
|
772
772
|
#
|
773
|
-
def replace:
|
773
|
+
def replace: (Hash[K, V]) -> self
|
774
774
|
|
775
775
|
# Returns a new hash consisting of entries for which the block returns true.
|
776
776
|
#
|