Skip to content

Commit f07be48

Browse files
committed
update rbs signatures to be more consistent with generics
1 parent 36ba133 commit f07be48

File tree

18 files changed

+420
-420
lines changed

18 files changed

+420
-420
lines changed

core/array.rbs

Lines changed: 145 additions & 145 deletions
Large diffs are not rendered by default.

core/enumerable.rbs

Lines changed: 111 additions & 111 deletions
Large diffs are not rendered by default.

core/enumerator.rbs

Lines changed: 25 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -125,8 +125,8 @@
125125
# puts ext_each(o.to_enum) {|*x| puts x; [:b, *x] }
126126
# # => [], [:b], [1], [:b, 1], [1, 2], [:b, 1, 2], 3
127127
#
128-
class Enumerator[unchecked out Elem, out Return = void] < Object
129-
include Enumerable[Elem]
128+
class Enumerator[unchecked out T, out R = void] < Object
129+
include Enumerable[T]
130130

131131
# A convenience interface for `each` with optional block
132132
#
@@ -210,7 +210,7 @@ class Enumerator[unchecked out Elem, out Return = void] < Object
210210
# When a block is given, calls the block with each N-element array generated and
211211
# returns `nil`.
212212
#
213-
def self.product: [Elem] (*_EachEntry[Elem]) -> Product[Elem]
213+
def self.product: [T] (*_EachEntry[T]) -> Product[T]
214214

215215
# <!--
216216
# rdoc-file=enumerator.c
@@ -247,7 +247,7 @@ class Enumerator[unchecked out Elem, out Return = void] < Object
247247
# enum.each(:y, :z).equal?(enum) #=> false
248248
# enum.each(:y, :z) { |elm| elm } #=> :method_returned
249249
#
250-
def each: () { (Elem arg0) -> untyped } -> Return
250+
def each: () { (T arg0) -> untyped } -> R
251251
| () -> self
252252

253253
# <!--
@@ -295,7 +295,7 @@ class Enumerator[unchecked out Elem, out Return = void] < Object
295295
# e.next # (7)
296296
# # (10)
297297
#
298-
def feed: (Elem arg0) -> NilClass
298+
def feed: (T arg0) -> NilClass
299299

300300
# <!--
301301
# rdoc-file=enumerator.c
@@ -321,7 +321,7 @@ class Enumerator[unchecked out Elem, out Return = void] < Object
321321
# lazy fashion (see Enumerator#size). It can either be a value or a callable
322322
# object.
323323
#
324-
def initialize: (?Integer arg0) { (Enumerator::Yielder arg0) -> Return } -> void
324+
def initialize: (?Integer arg0) { (Enumerator::Yielder arg0) -> R } -> void
325325

326326
# <!--
327327
# rdoc-file=enumerator.c
@@ -349,7 +349,7 @@ class Enumerator[unchecked out Elem, out Return = void] < Object
349349
#
350350
# See class-level notes about external iterators.
351351
#
352-
def next: () -> Elem
352+
def next: () -> T
353353

354354
# <!--
355355
# rdoc-file=enumerator.c
@@ -393,7 +393,7 @@ class Enumerator[unchecked out Elem, out Return = void] < Object
393393
# # yield nil [nil] nil
394394
# # yield [1, 2] [[1, 2]] [1, 2]
395395
#
396-
def next_values: () -> ::Array[Elem]
396+
def next_values: () -> ::Array[T]
397397

398398
# <!--
399399
# rdoc-file=enumerator.c
@@ -417,7 +417,7 @@ class Enumerator[unchecked out Elem, out Return = void] < Object
417417
# p e.next #=> 3
418418
# p e.peek #raises StopIteration
419419
#
420-
def peek: () -> Elem
420+
def peek: () -> T
421421

422422
# <!--
423423
# rdoc-file=enumerator.c
@@ -447,7 +447,7 @@ class Enumerator[unchecked out Elem, out Return = void] < Object
447447
# e.next
448448
# p e.peek_values # raises StopIteration
449449
#
450-
def peek_values: () -> ::Array[Elem]
450+
def peek_values: () -> ::Array[T]
451451

452452
# <!--
453453
# rdoc-file=enumerator.c
@@ -500,7 +500,7 @@ class Enumerator[unchecked out Elem, out Return = void] < Object
500500
# e = (1..3).each + [4, 5]
501501
# e.to_a #=> [1, 2, 3, 4, 5]
502502
#
503-
def +: [Elem2] (::_Each[Elem2]) -> ::Enumerator::Chain[Elem | Elem2]
503+
def +: [Elem2] (::_Each[Elem2]) -> ::Enumerator::Chain[T | Elem2]
504504

505505
# <!--
506506
# rdoc-file=enumerator.c
@@ -514,8 +514,8 @@ class Enumerator[unchecked out Elem, out Return = void] < Object
514514
# `offset`
515515
# : the starting index to use
516516
#
517-
def with_index: (?Integer offset) { (Elem arg0, Integer arg1) -> untyped } -> Return
518-
| (?Integer offset) -> ::Enumerator[[ Elem, Integer ], Return]
517+
def with_index: (?Integer offset) { (T arg0, Integer arg1) -> untyped } -> R
518+
| (?Integer offset) -> ::Enumerator[[ T, Integer ], R]
519519

520520
# <!-- rdoc-file=enumerator.c -->
521521
# Iterates the given block for each element with an arbitrary object, `obj`, and
@@ -540,17 +540,17 @@ class Enumerator[unchecked out Elem, out Return = void] < Object
540540
# # => foo: 1
541541
# # => foo: 2
542542
#
543-
def with_object: [U] (U obj) { (Elem, U obj) -> untyped } -> U
544-
| [U] (U obj) -> ::Enumerator[[ Elem, U ], U]
543+
def with_object: [U] (U obj) { (T, U obj) -> untyped } -> U
544+
| [U] (U obj) -> ::Enumerator[[ T, U ], U]
545545
end
546546

547547
# <!-- rdoc-file=enumerator.c -->
548548
# Generator
549549
#
550-
class Enumerator::Generator[out Elem] < Object
551-
include Enumerable[Elem]
550+
class Enumerator::Generator[out T] < Object
551+
include Enumerable[T]
552552

553-
def each: () { (Elem) -> void } -> void
553+
def each: () { (T) -> void } -> void
554554
end
555555

556556
# <!-- rdoc-file=enumerator.c -->
@@ -619,7 +619,7 @@ end
619619
# # This returns an array of items like a normal enumerator does.
620620
# all_checked = active_items.select(&:checked)
621621
#
622-
class Enumerator::Lazy[out Elem, out Return = void] < Enumerator[Elem, Return]
622+
class Enumerator::Lazy[out T, out R = void] < Enumerator[T, R]
623623
# <!-- rdoc-file=enumerator.c -->
624624
# Expands `lazy` enumerator to an array. See Enumerable#to_a.
625625
#
@@ -631,15 +631,15 @@ class Enumerator::Lazy[out Elem, out Return = void] < Enumerator[Elem, Return]
631631
# -->
632632
# Like Enumerable#compact, but chains operation to be lazy-evaluated.
633633
#
634-
def compact: () -> Enumerator::Lazy[Elem, Return]
634+
def compact: () -> Enumerator::Lazy[T, R]
635635

636636
# <!--
637637
# rdoc-file=enumerator.c
638638
# - lzy.eager -> enum
639639
# -->
640640
# Returns a non-lazy Enumerator converted from the lazy enumerator.
641641
#
642-
def eager: () -> ::Enumerator[Elem, Return]
642+
def eager: () -> ::Enumerator[T, R]
643643
end
644644

645645
# <!-- rdoc-file=enumerator.c -->
@@ -674,7 +674,7 @@ end
674674
#
675675
# This type of objects can be created by Enumerable#chain and Enumerator#+.
676676
#
677-
class Enumerator::Chain[out Elem] < Enumerator[Elem, void]
677+
class Enumerator::Chain[out T] < Enumerator[T, void]
678678
# <!--
679679
# rdoc-file=enumerator.c
680680
# - Enumerator::Chain.new(*enums) -> enum
@@ -686,7 +686,7 @@ class Enumerator::Chain[out Elem] < Enumerator[Elem, void]
686686
# e.to_a #=> [1, 2, 3, 4, 5]
687687
# e.size #=> 5
688688
#
689-
def initialize: (*_Each[Elem] enums) -> void
689+
def initialize: (*_Each[T] enums) -> void
690690

691691
# <!--
692692
# rdoc-file=enumerator.c
@@ -699,6 +699,6 @@ class Enumerator::Chain[out Elem] < Enumerator[Elem, void]
699699
#
700700
# If no block is given, returns an enumerator.
701701
#
702-
def each: () { (Elem) -> void } -> self
703-
| () -> Enumerator[Elem, self]
702+
def each: () { (T) -> void } -> self
703+
| () -> Enumerator[T, self]
704704
end

core/enumerator/product.rbs

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
%a{annotate:rdoc:skip}
2-
class Enumerator[unchecked out Elem, out Return = void]
2+
class Enumerator[unchecked out T, out R = void]
33
# <!-- rdoc-file=enumerator.c -->
44
# Enumerator::Product generates a Cartesian product of any number of enumerable
55
# objects. Iterating over the product of enumerable objects is roughly
@@ -30,7 +30,7 @@ class Enumerator[unchecked out Elem, out Return = void]
3030
#
3131
# This type of objects can be created by Enumerator.product.
3232
#
33-
class Product[unchecked out Elem] < Enumerator[Array[Elem], Product[Elem]]
33+
class Product[unchecked out T] < Enumerator[Array[T], Product[T]]
3434
# <!--
3535
# rdoc-file=enumerator.c
3636
# - Enumerator::Product.new(*enums) -> enum
@@ -42,7 +42,7 @@ class Enumerator[unchecked out Elem, out Return = void]
4242
# e.to_a #=> [[1, 4], [1, 5], [2, 4], [2, 5], [3, 4], [3, 5]]
4343
# e.size #=> 6
4444
#
45-
def initialize: (*_EachEntry[Elem]) -> void
45+
def initialize: (*_EachEntry[T]) -> void
4646

4747
# <!--
4848
# rdoc-file=enumerator.c
@@ -55,7 +55,7 @@ class Enumerator[unchecked out Elem, out Return = void]
5555
#
5656
# If no block is given, returns an enumerator. Otherwise, returns self.
5757
#
58-
def each: () { (Array[Elem]) -> void } -> self
58+
def each: () { (Array[T]) -> void } -> self
5959

6060
# <!--
6161
# rdoc-file=enumerator.c
@@ -87,6 +87,6 @@ class Enumerator[unchecked out Elem, out Return = void]
8787

8888
private
8989

90-
def initialize_copy: (Product[Elem]) -> void
90+
def initialize_copy: (Product[T]) -> void
9191
end
9292
end

core/object_space/weak_key_map.rbs

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,7 @@ module ObjectSpace
5757
# attributes always, but the values that aren't needed anymore wouldn't be
5858
# sitting in the cache forever.
5959
#
60-
class WeakKeyMap[Key, Value]
60+
class WeakKeyMap[K, V]
6161
# <!--
6262
# rdoc-file=weakmap.c
6363
# - map[key] -> value
@@ -66,7 +66,7 @@ module ObjectSpace
6666
#
6767
# If `key` is not found, returns `nil`.
6868
#
69-
def []: (Key) -> Value?
69+
def []: (K) -> V?
7070

7171
# <!--
7272
# rdoc-file=weakmap.c
@@ -80,7 +80,7 @@ module ObjectSpace
8080
# If the given `key` exists, replaces its value with the given `value`; the
8181
# ordering is not affected
8282
#
83-
def []=: (Key, Value?) -> Value?
83+
def []=: (K, V?) -> V?
8484

8585
# <!--
8686
# rdoc-file=weakmap.c
@@ -119,8 +119,8 @@ module ObjectSpace
119119
# m = ObjectSpace::WeakKeyMap.new
120120
# m.delete("nosuch") { |key| "Key #{key} not found" } # => "Key nosuch not found"
121121
#
122-
def delete: (Key) -> Value?
123-
| [T] (Key) { (Key) -> T } -> (Value | T)
122+
def delete: (K) -> V?
123+
| [T] (K) { (K) -> T } -> (V | T)
124124

125125
# <!--
126126
# rdoc-file=weakmap.c
@@ -141,7 +141,7 @@ module ObjectSpace
141141
# copy = cache.getkey({amount: 1, currency: 'USD'})
142142
# copy.object_id == value.object_id #=> true
143143
#
144-
def getkey: (untyped) -> Key?
144+
def getkey: (untyped) -> K?
145145

146146
# <!--
147147
# rdoc-file=weakmap.c
@@ -161,6 +161,6 @@ module ObjectSpace
161161
# -->
162162
# Returns `true` if `key` is a key in `self`, otherwise `false`.
163163
#
164-
def key?: (Key) -> bool
164+
def key?: (K) -> bool
165165
end
166166
end

0 commit comments

Comments
 (0)