rbs 0.12.1 → 0.15.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (106) hide show
  1. checksums.yaml +4 -4
  2. data/.github/workflows/ruby.yml +1 -1
  3. data/.gitignore +0 -1
  4. data/CHANGELOG.md +31 -0
  5. data/Gemfile +3 -0
  6. data/README.md +8 -2
  7. data/Rakefile +2 -2
  8. data/Steepfile +1 -0
  9. data/bin/annotate-with-rdoc +1 -1
  10. data/bin/setup +0 -2
  11. data/docs/CONTRIBUTING.md +1 -0
  12. data/docs/syntax.md +50 -6
  13. data/goodcheck.yml +22 -5
  14. data/lib/rbs/ast/comment.rb +1 -1
  15. data/lib/rbs/cli.rb +12 -4
  16. data/lib/rbs/constant.rb +1 -1
  17. data/lib/rbs/constant_table.rb +9 -8
  18. data/lib/rbs/definition_builder.rb +6 -7
  19. data/lib/rbs/environment.rb +5 -1
  20. data/lib/rbs/environment_loader.rb +12 -12
  21. data/lib/rbs/namespace.rb +1 -1
  22. data/lib/rbs/parser.rb +3148 -0
  23. data/lib/rbs/parser.y +10 -3
  24. data/lib/rbs/prototype/rb.rb +38 -6
  25. data/lib/rbs/prototype/runtime.rb +17 -7
  26. data/lib/rbs/test/hook.rb +2 -0
  27. data/lib/rbs/test/setup_helper.rb +4 -4
  28. data/lib/rbs/test/tester.rb +4 -1
  29. data/lib/rbs/test/type_check.rb +12 -6
  30. data/lib/rbs/type_name.rb +1 -1
  31. data/lib/rbs/variance_calculator.rb +2 -2
  32. data/lib/rbs/version.rb +1 -1
  33. data/lib/rbs/writer.rb +25 -15
  34. data/sig/constant.rbs +21 -0
  35. data/sig/constant_table.rbs +30 -0
  36. data/sig/declarations.rbs +2 -2
  37. data/sig/definition.rbs +2 -2
  38. data/sig/definition_builder.rbs +4 -5
  39. data/sig/environment_loader.rbs +54 -0
  40. data/sig/members.rbs +2 -2
  41. data/sig/method_types.rbs +1 -1
  42. data/sig/namespace.rbs +4 -4
  43. data/sig/parser.rbs +25 -0
  44. data/sig/substitution.rbs +3 -3
  45. data/sig/typename.rbs +1 -1
  46. data/sig/types.rbs +1 -1
  47. data/sig/version.rbs +3 -0
  48. data/sig/writer.rbs +40 -0
  49. data/stdlib/base64/base64.rbs +1 -1
  50. data/stdlib/benchmark/benchmark.rbs +2 -2
  51. data/stdlib/builtin/array.rbs +124 -120
  52. data/stdlib/builtin/basic_object.rbs +54 -54
  53. data/stdlib/builtin/binding.rbs +42 -42
  54. data/stdlib/builtin/builtin.rbs +28 -0
  55. data/stdlib/builtin/class.rbs +33 -33
  56. data/stdlib/builtin/complex.rbs +90 -90
  57. data/stdlib/builtin/encoding.rbs +33 -33
  58. data/stdlib/builtin/enumerable.rbs +58 -52
  59. data/stdlib/builtin/enumerator.rbs +35 -35
  60. data/stdlib/builtin/errors.rbs +2 -2
  61. data/stdlib/builtin/exception.rbs +50 -50
  62. data/stdlib/builtin/false_class.rbs +6 -6
  63. data/stdlib/builtin/fiber.rbs +14 -14
  64. data/stdlib/builtin/fiber_error.rbs +1 -1
  65. data/stdlib/builtin/float.rbs +161 -161
  66. data/stdlib/builtin/gc.rbs +3 -3
  67. data/stdlib/builtin/hash.rbs +7 -7
  68. data/stdlib/builtin/io.rbs +88 -88
  69. data/stdlib/builtin/kernel.rbs +71 -153
  70. data/stdlib/builtin/match_data.rbs +1 -1
  71. data/stdlib/builtin/method.rbs +19 -19
  72. data/stdlib/builtin/module.rbs +13 -13
  73. data/stdlib/builtin/nil_class.rbs +20 -20
  74. data/stdlib/builtin/numeric.rbs +101 -101
  75. data/stdlib/builtin/object.rbs +173 -173
  76. data/stdlib/builtin/proc.rbs +91 -91
  77. data/stdlib/builtin/random.rbs +1 -1
  78. data/stdlib/builtin/range.rbs +3 -5
  79. data/stdlib/builtin/rational.rbs +83 -83
  80. data/stdlib/builtin/signal.rbs +7 -7
  81. data/stdlib/builtin/string.rbs +10 -10
  82. data/stdlib/builtin/string_io.rbs +8 -8
  83. data/stdlib/builtin/struct.rbs +1 -1
  84. data/stdlib/builtin/symbol.rbs +1 -1
  85. data/stdlib/builtin/thread.rbs +189 -189
  86. data/stdlib/builtin/thread_group.rbs +2 -2
  87. data/stdlib/builtin/true_class.rbs +10 -10
  88. data/stdlib/builtin/warning.rbs +1 -1
  89. data/stdlib/coverage/coverage.rbs +2 -2
  90. data/stdlib/csv/csv.rbs +1 -1
  91. data/stdlib/date/date.rbs +4 -4
  92. data/stdlib/date/date_time.rbs +1 -1
  93. data/stdlib/find/find.rbs +12 -12
  94. data/stdlib/logger/log_device.rbs +1 -1
  95. data/stdlib/logger/logger.rbs +1 -1
  96. data/stdlib/pathname/pathname.rbs +41 -39
  97. data/stdlib/pstore/pstore.rbs +287 -0
  98. data/stdlib/pty/pty.rbs +5 -29
  99. data/stdlib/tmpdir/tmpdir.rbs +12 -12
  100. data/stdlib/uri/generic.rbs +2 -2
  101. data/stdlib/uri/http.rbs +158 -0
  102. data/stdlib/uri/https.rbs +108 -0
  103. data/stdlib/uri/ldap.rbs +224 -0
  104. data/stdlib/uri/ldaps.rbs +108 -0
  105. data/steep/Gemfile.lock +13 -17
  106. metadata +13 -3
@@ -2,7 +2,7 @@ module RBS
2
2
  module AST
3
3
  module Declarations
4
4
  type t = Class | Module | Interface | Constant | Global | Alias
5
-
5
+
6
6
  class Base
7
7
  end
8
8
 
@@ -14,7 +14,7 @@ module RBS
14
14
  attr_reader variance: variance
15
15
  attr_reader skip_validation: bool
16
16
 
17
- def initialize: (name: Symbol, variance: variance, skip_validation: bool) -> void
17
+ def initialize: (name: Symbol, variance: variance, skip_validation: boolish) -> void
18
18
 
19
19
  include _ToJson
20
20
  end
@@ -18,7 +18,7 @@ module RBS
18
18
  class TypeDef
19
19
  attr_reader type: MethodType
20
20
  attr_reader member: method_member
21
- attr_reader defined_in: TypeName?
21
+ attr_reader defined_in: TypeName
22
22
  attr_reader implemented_in: TypeName?
23
23
 
24
24
  def initialize: (type: MethodType, member: method_member, defined_in: TypeName?, implemented_in: TypeName?) -> void
@@ -28,7 +28,7 @@ module RBS
28
28
  def annotations: () -> Array[AST::Annotation]
29
29
 
30
30
  def update: (?type: MethodType, ?member: method_member, ?defined_in: TypeName?, ?implemented_in: TypeName?) -> TypeDef
31
-
31
+
32
32
  def overload?: () -> bool
33
33
  end
34
34
 
@@ -29,14 +29,14 @@ module RBS
29
29
 
30
30
  attr_reader env: Environment
31
31
  attr_reader type_name_resolver: TypeNameResolver
32
-
32
+
33
33
  attr_reader instance_cache: Hash[TypeName, Definition | false | nil]
34
34
  attr_reader singleton_cache: Hash[TypeName, Definition | false | nil]
35
35
  attr_reader interface_cache: Hash[TypeName, Definition | false | nil]
36
36
 
37
37
  attr_reader one_instance_cache: Hash[TypeName, Definition]
38
38
  attr_reader one_singleton_cache: Hash[TypeName, Definition]
39
-
39
+
40
40
  attr_reader instance_ancestors_cache: Hash[TypeName, Definition::InstanceAncestors]
41
41
  attr_reader singleton_ancestor_cache: Hash[TypeName, Definition::SingletonAncestors]
42
42
 
@@ -48,7 +48,7 @@ module RBS
48
48
  def validate_super_class!: (TypeName, Environment::ClassEntry) -> void
49
49
 
50
50
  def one_instance_ancestors: (TypeName) -> OneAncestors
51
-
51
+
52
52
  def one_singleton_ancestors: (TypeName) -> OneAncestors
53
53
 
54
54
  def instance_ancestors: (TypeName, ?building_ancestors: Array[Definition::Ancestor::t]) -> Definition::InstanceAncestors
@@ -69,7 +69,7 @@ module RBS
69
69
 
70
70
  def build_one_singleton: (TypeName) -> Definition
71
71
 
72
- def merge_definitions: (TypeName,
72
+ def merge_definitions: (TypeName,
73
73
  Array[[Definition::Ancestor::t, Definition]],
74
74
  entry: Environment::ModuleEntry | Environment::ClassEntry,
75
75
  self_type: Definition::self_type,
@@ -92,4 +92,3 @@ module RBS
92
92
  def expand_alias: (TypeName) -> Types::t
93
93
  end
94
94
  end
95
-
@@ -1,4 +1,58 @@
1
1
  module RBS
2
2
  class EnvironmentLoader
3
+ class UnknownLibraryNameError < StandardError
4
+ attr_reader name: String
5
+
6
+ def initialize: (name: String) -> void
7
+ end
8
+
9
+ class LibraryPath
10
+ attr_reader name: String
11
+ attr_reader path: Pathname
12
+
13
+ def initialize: (name: String, path: Pathname) -> void
14
+ end
15
+
16
+ class GemPath
17
+ attr_reader name: String
18
+ attr_reader version: String?
19
+ attr_reader path: Pathname
20
+
21
+ def initialize: (name: String, version: String?, path: Pathname) -> void
22
+ end
23
+
24
+ STDLIB_ROOT: Pathname
25
+
26
+ type path = Pathname | LibraryPath | GemPath
27
+
28
+ attr_reader paths: Array[path]
29
+ attr_reader stdlib_root: Pathname
30
+ attr_reader gem_vendor_path: Pathname?
31
+
32
+ def self.gem_sig_path: (String, String?) -> Pathname?
33
+
34
+ def initialize: (?stdlib_root: Pathname, ?gem_vendor_path: Pathname?) -> void
35
+
36
+ def add: (path: Pathname?) -> void
37
+ | (library: String?) -> void
38
+
39
+ def self.parse_library: (String) -> [String, String?]
40
+
41
+ def stdlib?: (String) -> Pathname?
42
+
43
+ def gem?: (String, String?) -> Pathname?
44
+
45
+ def each_signature: (Pathname, ?immediate: boolish) { (Pathname) -> void } -> void
46
+ | (Pathname, ?immediate: boolish) -> Enumerator[Pathname, void]
47
+
48
+ def each_library_path: { (path, Pathname) -> void } -> void
49
+
50
+ def no_builtin!: (?boolish) -> self
51
+
52
+ def no_builtin?: () -> bool
53
+
54
+ def each_decl: () { (AST::Declarations::t, Buffer, Pathname, path | :stdlib) -> void } -> void
55
+
56
+ def load: (env: Environment) -> Array[[AST::Declarations::t, Pathname, path | :stdlib]]
3
57
  end
4
58
  end
@@ -23,7 +23,7 @@ module RBS
23
23
  attr_reader comment: Comment?
24
24
  attr_reader overload: bool
25
25
 
26
- def initialize: (name: Symbol, kind: kind, types: Array[MethodType], annotations: Array[Annotation], location: Location?, comment: Comment?, overload: bool) -> void
26
+ def initialize: (name: Symbol, kind: kind, types: Array[MethodType], annotations: Array[Annotation], location: Location?, comment: Comment?, overload: boolish) -> void
27
27
 
28
28
  include _HashEqual
29
29
  include _ToJson
@@ -34,7 +34,7 @@ module RBS
34
34
 
35
35
  def overload?: () -> bool
36
36
 
37
- def update: (?name: Symbol, ?kind: kind, ?types: Array[MethodType], ?annotations: Array[Annotation], ?location: Location?, ?comment: Comment?, ?overload: bool) -> MethodDefinition
37
+ def update: (?name: Symbol, ?kind: kind, ?types: Array[MethodType], ?annotations: Array[Annotation], ?location: Location?, ?comment: Comment?, ?overload: boolish) -> MethodDefinition
38
38
  end
39
39
 
40
40
  module Var
@@ -4,7 +4,7 @@ module RBS
4
4
  attr_reader type: Types::Function
5
5
  attr_reader required: bool
6
6
 
7
- def initialize: (type: Types::Function, required: bool) -> void
7
+ def initialize: (type: Types::Function, required: boolish) -> void
8
8
 
9
9
  def ==: (untyped other) -> bool
10
10
 
@@ -1,6 +1,6 @@
1
1
  module RBS
2
2
  # Namespace instance represents a _prefix of module names_.
3
- #
3
+ #
4
4
  # vvvvvvvvvvvvvv TypeName
5
5
  # RBS::Namespace
6
6
  # ^^^^^ Namespace
@@ -28,7 +28,7 @@ module RBS
28
28
  class Namespace
29
29
  attr_reader path: Array[Symbol]
30
30
 
31
- def initialize: (path: Array[Symbol], absolute: bool) -> void
31
+ def initialize: (path: Array[Symbol], absolute: boolish) -> void
32
32
 
33
33
  # Returns new _empty_ namespace.
34
34
  def self.empty: () -> Namespace
@@ -44,7 +44,7 @@ module RBS
44
44
  # If `other` is an absolute namespace, it returns `other`.
45
45
  #
46
46
  # Namespace("Foo::") + Namespace("::Bar::") # => ::Bar::
47
- #
47
+ #
48
48
  def +: (Namespace other) -> Namespace
49
49
 
50
50
  # Add one path component to self.
@@ -62,7 +62,7 @@ module RBS
62
62
 
63
63
  # Returns true if self is absolute namespace.
64
64
  def absolute?: () -> bool
65
-
65
+
66
66
  # Returns true if self is relative namespace.
67
67
  def relative?: () -> bool
68
68
 
@@ -0,0 +1,25 @@
1
+ module RBS
2
+ class Parser
3
+ class SyntaxError < StandardError
4
+ attr_reader token_str: String
5
+ attr_reader error_value: untyped
6
+ attr_reader value_stack: untyped?
7
+
8
+ def initialize: (token_str: String, error_value: untyped, ?value_stack: untyped?) -> void
9
+ end
10
+
11
+ class SemanticsError < StandardError
12
+ attr_reader subject: untyped
13
+ attr_reader location: Location
14
+ attr_reader original_message: String
15
+
16
+ def initialize: (String message, subject: untyped, location: Location) -> void
17
+ end
18
+
19
+ def self.parse_method_type: (String | Buffer, ?variables: Array[Symbol], ?eof_re: Regexp?) -> MethodType
20
+
21
+ def self.parse_type: (String | Buffer, ?variables: Array[Symbol], ?eof_re: Regexp?) -> Types::t
22
+
23
+ def self.parse_signature: (String | Buffer, ?eof_re: Regexp?) -> Array[AST::Declarations::t]
24
+ end
25
+ end
@@ -1,6 +1,6 @@
1
1
  module RBS
2
2
  # Substitution from type variables to types.
3
- #
3
+ #
4
4
  # The substitution construction is in _destructive_ manner.
5
5
  #
6
6
  # sub = Substitution.new
@@ -25,7 +25,7 @@ module RBS
25
25
  # Utility method to construct a substitution.
26
26
  # Raises an error when `variables.size != types.size`.
27
27
  # `instance_type` defaults to `nil`.
28
- #
28
+ #
29
29
  # Yields types in `types` and the block value is used if block is given.
30
30
  #
31
31
  def self.build: (Array[Symbol] variables, Array[Types::t] types, ?instance_type: Types::t?) ?{ (Types::t) -> Types::t } -> instance
@@ -36,4 +36,4 @@ module RBS
36
36
  # Returns a substitution without variables given in `vars`.
37
37
  def without: (*Symbol vars) -> Substitution
38
38
  end
39
- end
39
+ end
@@ -1,6 +1,6 @@
1
1
  module RBS
2
2
  # TypeName represents name of types in RBS.
3
- #
3
+ #
4
4
  # TypeNames are one of the three kind, class, alias, and interface.
5
5
  # *class* type names corresponds to Ruby classes and modules.
6
6
  # There are no corresponding Ruby value to *alias* and *interface* type names.
@@ -154,7 +154,7 @@ module RBS
154
154
 
155
155
  include NoFreeVariables
156
156
  include NoSubst
157
- include EmptyEachType
157
+ include EmptyEachType
158
158
  end
159
159
 
160
160
  module Application
@@ -0,0 +1,3 @@
1
+ module RBS
2
+ VERSION: String
3
+ end
@@ -0,0 +1,40 @@
1
+ module RBS
2
+ class Writer
3
+ attr_reader out: IO
4
+ attr_reader indentation: Array[String]
5
+
6
+ def initialize: (out: IO) -> void
7
+
8
+ def indent: (?Integer size) { () -> void } -> void
9
+
10
+ def prefix: () -> String
11
+
12
+ def puts: (?String) -> void
13
+
14
+ def write_annotation: (Array[AST::Annotation]) -> void
15
+
16
+ def write_comment: (AST::Comment?) -> void
17
+
18
+ def write: (Array[AST::Declarations::t]) -> void
19
+
20
+ def write_decl: (AST::Declarations::t) -> void
21
+
22
+ def write_member: (AST::Declarations::Module::member) -> void
23
+
24
+ def name_and_params: (TypeName, AST::Declarations::ModuleTypeParams) -> String?
25
+
26
+ def name_and_args: (TypeName, Array[Types::t]) -> String?
27
+
28
+ def method_name: (Symbol) -> String
29
+
30
+ def write_def: (AST::Members::MethodDefinition) -> void
31
+
32
+ def attribute: (:reader | :writer | :accessor, AST::Members::Attribute) -> void
33
+
34
+ interface _Located
35
+ def location: () -> Location?
36
+ end
37
+
38
+ def preserve_empty_line: (_Located?, _Located) -> void
39
+ end
40
+ end
@@ -67,5 +67,5 @@ module Base64
67
67
  # 64 Encoding with URL and Filename Safe Alphabet'' in RFC 4648. The alphabet
68
68
  # uses '-' instead of '+' and '_' instead of '/'. Note that the result can still
69
69
  # contain '='. You can remove the padding by setting `padding` as false.
70
- def self?.urlsafe_encode64: (String bin, ?padding: bool) -> String
70
+ def self?.urlsafe_encode64: (String bin, ?padding: boolish) -> String
71
71
  end
@@ -53,9 +53,9 @@
53
53
  # times: 1.000000 0.000000 1.000000 ( 1.003611)
54
54
  # upto: 1.030000 0.000000 1.030000 ( 1.028098)
55
55
  #
56
- # * The times for some benchmarks depend on the order in which items are run.
56
+ # * The times for some benchmarks depend on the order in which items are run.
57
57
  # These differences are due to the cost of memory allocation and garbage
58
- # collection. To avoid these discrepancies, the #bmbm method is provided.
58
+ # collection. To avoid these discrepancies, the #bmbm method is provided.
59
59
  # For example, to compare ways to sort an array of floats:
60
60
  #
61
61
  # require 'benchmark'
@@ -234,7 +234,7 @@
234
234
  # for pack.c
235
235
  #
236
236
  class Array[unchecked out Elem] < Object
237
- include Enumerable[Elem, Array[Elem]]
237
+ include Enumerable[Elem, self]
238
238
 
239
239
  # Returns a new array.
240
240
  #
@@ -285,9 +285,9 @@ class Array[unchecked out Elem] < Object
285
285
  # a # => [{"cat"=>"feline"}, {}]
286
286
  #
287
287
  def initialize: () -> void
288
- | (Array[Elem] ary) -> void
288
+ | (::Array[Elem] ary) -> void
289
289
  | (int size, ?Elem val) -> void
290
- | (int size) { (Integer index) -> Elem } -> void
290
+ | (int size) { (::Integer index) -> Elem } -> void
291
291
 
292
292
  # Returns a new array populated with the given objects.
293
293
  #
@@ -324,7 +324,7 @@ class Array[unchecked out Elem] < Object
324
324
  #
325
325
  # See also Array#uniq.
326
326
  #
327
- def &: (Array[untyped] | _ToAry[untyped]) -> ::Array[Elem]
327
+ def &: (::Array[untyped] | _ToAry[untyped]) -> ::Array[Elem]
328
328
 
329
329
  # Repetition --- With a String argument, equivalent to `ary.join(str)`.
330
330
  #
@@ -334,8 +334,8 @@ class Array[unchecked out Elem] < Object
334
334
  # [ 1, 2, 3 ] * 3 #=> [ 1, 2, 3, 1, 2, 3, 1, 2, 3 ]
335
335
  # [ 1, 2, 3 ] * "," #=> "1,2,3"
336
336
  #
337
- def *: (string str) -> String
338
- | (int int) -> Array[Elem]
337
+ def *: (string str) -> ::String
338
+ | (int int) -> ::Array[Elem]
339
339
 
340
340
  # Concatenation --- Returns a new array built by concatenating the two arrays
341
341
  # together to produce a third array.
@@ -388,7 +388,7 @@ class Array[unchecked out Elem] < Object
388
388
  # a
389
389
  # #=> [ 1, 2, "c", "d", [ 3, 4 ] ]
390
390
  #
391
- def <<: (Elem) -> ::Array[Elem]
391
+ def <<: (Elem) -> self
392
392
 
393
393
  # Comparison --- Returns an integer (`-1`, `0`, or `+1`) if this array is less
394
394
  # than, equal to, or greater than `other_ary`.
@@ -413,7 +413,7 @@ class Array[unchecked out Elem] < Object
413
413
  # [ 1, 2, 3, 4, 5, 6 ] <=> [ 1, 2 ] #=> +1
414
414
  # [ 1, 2 ] <=> [ 1, :two ] #=> nil
415
415
  #
416
- def <=>: (untyped) -> Integer?
416
+ def <=>: (untyped) -> ::Integer?
417
417
 
418
418
  # Equality --- Two arrays are equal if they contain the same number of elements
419
419
  # and if each element is equal to (according to Object#==) the corresponding
@@ -452,7 +452,7 @@ class Array[unchecked out Elem] < Object
452
452
  #
453
453
  def []: (int index) -> Elem
454
454
  | (int start, int length) -> ::Array[Elem]?
455
- | (Range[Integer] range) -> ::Array[Elem]?
455
+ | (::Range[::Integer] range) -> ::Array[Elem]?
456
456
 
457
457
  # Element Assignment --- Sets the element at `index`, or replaces a subarray
458
458
  # from the `start` index for `length` elements, or replaces a subarray specified
@@ -484,17 +484,17 @@ class Array[unchecked out Elem] < Object
484
484
  #
485
485
  def []=: (int index, Elem obj) -> Elem
486
486
  | (int start, int length, Elem obj) -> Elem
487
- | (int start, int length, Array[Elem]) -> Array[Elem]
487
+ | (int start, int length, ::Array[Elem]) -> ::Array[Elem]
488
488
  | (int start, int length, nil) -> nil
489
- | (Range[Integer], Elem obj) -> Elem
490
- | (Range[Integer], Array[Elem]) -> Array[Elem]
491
- | (Range[Integer], nil) -> nil
489
+ | (::Range[::Integer], Elem obj) -> Elem
490
+ | (::Range[::Integer], ::Array[Elem]) -> ::Array[Elem]
491
+ | (::Range[::Integer], nil) -> nil
492
492
 
493
493
  # See also Enumerable#all?
494
494
  #
495
495
  def all?: () -> bool
496
496
  | (_Pattern[Elem] pattern) -> bool
497
- | () { (Elem obj) -> bool } -> bool
497
+ | () { (Elem obj) -> boolish } -> bool
498
498
 
499
499
  # See also Enumerable#any?
500
500
  #
@@ -517,7 +517,7 @@ class Array[unchecked out Elem] < Object
517
517
  # a.assoc("letters") #=> [ "letters", "a", "b", "c" ]
518
518
  # a.assoc("foo") #=> nil
519
519
  #
520
- def assoc: (untyped) -> Array[untyped]?
520
+ def assoc: (untyped) -> ::Array[untyped]?
521
521
 
522
522
  # Returns the element at `index`. A negative index counts from the end of
523
523
  # `self`. Returns `nil` if the index is out of range. See also Array#[].
@@ -577,7 +577,7 @@ class Array[unchecked out Elem] < Object
577
577
  # actually picked up at each iteration.
578
578
  #
579
579
  def bsearch: () { (Elem) -> (true | false) } -> Elem?
580
- | () { (Elem) -> Integer } -> Elem?
580
+ | () { (Elem) -> ::Integer } -> Elem?
581
581
 
582
582
  # By using binary search, finds an index of a value from this array which meets
583
583
  # the given condition in O(log n) where n is the size of the array.
@@ -587,8 +587,8 @@ class Array[unchecked out Elem] < Object
587
587
  # that this method returns the index of the element instead of the element
588
588
  # itself. For more details consult the documentation for #bsearch.
589
589
  #
590
- def bsearch_index: () { (Elem) -> (true | false) } -> Integer?
591
- | () { (Elem) -> Integer } -> Integer?
590
+ def bsearch_index: () { (Elem) -> (true | false) } -> ::Integer?
591
+ | () { (Elem) -> ::Integer } -> ::Integer?
592
592
 
593
593
  # Removes all elements from `self`.
594
594
  #
@@ -610,8 +610,8 @@ class Array[unchecked out Elem] < Object
610
610
  # a.map.with_index {|x, i| x * i} #=> ["", "b", "cc", "ddd"]
611
611
  # a #=> ["a", "b", "c", "d"]
612
612
  #
613
- def collect: [U] () { (Elem item) -> U } -> Array[U]
614
- | () -> Enumerator[Elem, Array[untyped]]
613
+ def collect: [U] () { (Elem item) -> U } -> ::Array[U]
614
+ | () -> ::Enumerator[Elem, ::Array[untyped]]
615
615
 
616
616
  # Invokes the given block once for each element of `self`, replacing the element
617
617
  # with the value returned by the block.
@@ -648,15 +648,15 @@ class Array[unchecked out Elem] < Object
648
648
  # a.combination(0).to_a #=> [[]] # one combination of length 0
649
649
  # a.combination(5).to_a #=> [] # no combinations of length 5
650
650
  #
651
- def combination: (int n) { (Array[Elem]) -> void } -> self
652
- | (int n) -> Enumerator[Array[Elem], self]
651
+ def combination: (int n) { (::Array[Elem]) -> void } -> self
652
+ | (int n) -> ::Enumerator[::Array[Elem], self]
653
653
 
654
654
  # Returns a copy of `self` with all `nil` elements removed.
655
655
  #
656
656
  # [ "a", nil, "b", nil, "c", nil ].compact
657
657
  # #=> [ "a", "b", "c" ]
658
658
  #
659
- def compact: () -> Array[Elem]
659
+ def compact: () -> ::Array[Elem]
660
660
 
661
661
  # Removes `nil` elements from the array.
662
662
  #
@@ -665,7 +665,7 @@ class Array[unchecked out Elem] < Object
665
665
  # [ "a", nil, "b", nil, "c" ].compact! #=> [ "a", "b", "c" ]
666
666
  # [ "a", "b", "c" ].compact! #=> nil
667
667
  #
668
- def compact!: () -> Array[Elem]?
668
+ def compact!: () -> self?
669
669
 
670
670
  # Appends the elements of `other_ary`s to `self`.
671
671
  #
@@ -682,7 +682,7 @@ class Array[unchecked out Elem] < Object
682
682
  #
683
683
  # See also Array#+.
684
684
  #
685
- def concat: (*Array[Elem] arrays) -> ::Array[Elem]
685
+ def concat: (*::Array[Elem] arrays) -> ::Array[Elem]
686
686
 
687
687
  # Returns the number of elements.
688
688
  #
@@ -697,9 +697,9 @@ class Array[unchecked out Elem] < Object
697
697
  # ary.count(2) #=> 2
698
698
  # ary.count {|x| x%2 == 0} #=> 3
699
699
  #
700
- def count: () -> Integer
701
- | (untyped obj) -> Integer
702
- | () { (Elem) -> bool } -> Integer
700
+ def count: () -> ::Integer
701
+ | (untyped obj) -> ::Integer
702
+ | () { (Elem) -> boolish } -> ::Integer
703
703
 
704
704
  # Calls the given block for each element `n` times or forever if `nil` is given.
705
705
  #
@@ -714,9 +714,9 @@ class Array[unchecked out Elem] < Object
714
714
  # a.cycle(2) {|x| puts x} # print, a, b, c, a, b, c.
715
715
  #
716
716
  def cycle: (?int? n) { (Elem) -> void } -> nil
717
- | (?int? n) -> Enumerator[Elem, nil]
717
+ | (?int? n) -> ::Enumerator[Elem, nil]
718
718
 
719
- def deconstruct: () -> Array[Integer]
719
+ def deconstruct: () -> self
720
720
 
721
721
  # Deletes all items from `self` that are equal to `obj`.
722
722
  #
@@ -759,8 +759,8 @@ class Array[unchecked out Elem] < Object
759
759
  # scores = [ 97, 42, 75 ]
760
760
  # scores.delete_if {|score| score < 80 } #=> [97]
761
761
  #
762
- def delete_if: () { (Elem item) -> bool } -> Array[Elem]
763
- | () -> Enumerator[Elem, self]
762
+ def delete_if: () { (Elem item) -> boolish } -> self
763
+ | () -> ::Enumerator[Elem, self]
764
764
 
765
765
  # Array Difference
766
766
  #
@@ -786,7 +786,7 @@ class Array[unchecked out Elem] < Object
786
786
  #
787
787
  # See also Array#-.
788
788
  #
789
- def difference: (*::Array[untyped] arrays) -> Array[Elem]
789
+ def difference: (*::Array[untyped] arrays) -> ::Array[Elem]
790
790
 
791
791
  # Extracts the nested value specified by the sequence of *idx* objects by
792
792
  # calling `dig` at each step, returning `nil` if any intermediate step is `nil`.
@@ -824,8 +824,8 @@ class Array[unchecked out Elem] < Object
824
824
  # a = [1, 2, 3, 4, 5, 0]
825
825
  # a.drop_while {|i| i < 3 } #=> [3, 4, 5, 0]
826
826
  #
827
- def drop_while: () { (Elem obj) -> bool } -> Array[Elem]
828
- | () -> ::Enumerator[Elem, Array[Elem]]
827
+ def drop_while: () { (Elem obj) -> boolish } -> ::Array[Elem]
828
+ | () -> ::Enumerator[Elem, ::Array[Elem]]
829
829
 
830
830
  # Calls the given block once for each element in `self`, passing that element as
831
831
  # a parameter. Returns the array itself.
@@ -839,8 +839,8 @@ class Array[unchecked out Elem] < Object
839
839
  #
840
840
  # a -- b -- c --
841
841
  #
842
- def each: () -> ::Enumerator[Elem, Array[Elem]]
843
- | () { (Elem item) -> void } -> Array[Elem]
842
+ def each: () -> ::Enumerator[Elem, self]
843
+ | () { (Elem item) -> void } -> self
844
844
 
845
845
  # Same as Array#each, but passes the `index` of the element instead of the
846
846
  # element itself.
@@ -854,8 +854,8 @@ class Array[unchecked out Elem] < Object
854
854
  #
855
855
  # 0 -- 1 -- 2 --
856
856
  #
857
- def each_index: () { (Integer index) -> void } -> Array[Elem]
858
- | () -> ::Enumerator[Elem, Array[Elem]]
857
+ def each_index: () { (::Integer index) -> void } -> self
858
+ | () -> ::Enumerator[Elem, self]
859
859
 
860
860
  # Returns `true` if `self` contains no elements.
861
861
  #
@@ -887,7 +887,7 @@ class Array[unchecked out Elem] < Object
887
887
  #
888
888
  def fetch: (int index) -> Elem
889
889
  | [T] (int index, T default) -> (Elem | T)
890
- | [T] (Integer index) { (Integer index) -> T } -> (Elem | T)
890
+ | [T] (int index) { (int index) -> T } -> (Elem | T)
891
891
 
892
892
  # The first three forms set the selected elements of `self` (which may be the
893
893
  # entire array) to `obj`.
@@ -911,9 +911,9 @@ class Array[unchecked out Elem] < Object
911
911
  #
912
912
  def fill: (Elem obj) -> self
913
913
  | (Elem obj, int? start, ?int? length) -> self
914
- | (Elem obj, Range[Integer] range) -> self
915
- | (?int? start, ?int? length) { (Integer index) -> Elem } -> self
916
- | (Range[Integer] range) { (Integer index) -> Elem } -> self
914
+ | (Elem obj, ::Range[::Integer] range) -> self
915
+ | (?int? start, ?int? length) { (::Integer index) -> Elem } -> self
916
+ | (::Range[::Integer] range) { (::Integer index) -> Elem } -> self
917
917
 
918
918
  # Returns a new array containing all elements of `ary` for which the given
919
919
  # `block` returns a true value.
@@ -929,8 +929,8 @@ class Array[unchecked out Elem] < Object
929
929
  #
930
930
  # Array#filter is an alias for Array#select.
931
931
  #
932
- def filter: () { (Elem item) -> bool } -> Array[Elem]
933
- | () -> Enumerator[Elem, Array[Elem]]
932
+ def filter: () { (Elem item) -> boolish } -> ::Array[Elem]
933
+ | () -> ::Enumerator[Elem, ::Array[Elem]]
934
934
 
935
935
  # Invokes the given block passing in successive elements from `self`, deleting
936
936
  # elements for which the block returns a `false` value.
@@ -945,8 +945,8 @@ class Array[unchecked out Elem] < Object
945
945
  #
946
946
  # Array#filter! is an alias for Array#select!.
947
947
  #
948
- def filter!: () { (Elem item) -> bool } -> Array[Elem]?
949
- | () -> Enumerator[Elem, Array[Elem]?]
948
+ def filter!: () { (Elem item) -> boolish } -> self?
949
+ | () -> ::Enumerator[Elem, self?]
950
950
 
951
951
  # Returns the *index* of the first object in `ary` such that the object is `==`
952
952
  # to `obj`.
@@ -964,9 +964,9 @@ class Array[unchecked out Elem] < Object
964
964
  # a.index("z") #=> nil
965
965
  # a.index {|x| x == "b"} #=> 1
966
966
  #
967
- def find_index: (untyped obj) -> Integer?
968
- | () { (Elem item) -> bool } -> Integer?
969
- | () -> Enumerator[Elem, Integer?]
967
+ def find_index: (untyped obj) -> ::Integer?
968
+ | () { (Elem item) -> boolish } -> ::Integer?
969
+ | () -> ::Enumerator[Elem, ::Integer?]
970
970
 
971
971
  # Returns the first element, or the first `n` elements, of the array. If the
972
972
  # array is empty, the first form returns `nil`, and the second form returns an
@@ -977,7 +977,7 @@ class Array[unchecked out Elem] < Object
977
977
  # a.first(2) #=> ["q", "r"]
978
978
  #
979
979
  def first: () -> Elem?
980
- | (int n) -> Array[Elem]
980
+ | (int n) -> ::Array[Elem]
981
981
 
982
982
  # Returns a new array that is a one-dimensional flattening of `self`
983
983
  # (recursively).
@@ -1010,7 +1010,7 @@ class Array[unchecked out Elem] < Object
1010
1010
  # a = [ 1, 2, [3, [4, 5] ] ]
1011
1011
  # a.flatten!(1) #=> [1, 2, 3, [4, 5]]
1012
1012
  #
1013
- def flatten!: (?int level) -> Array[untyped]?
1013
+ def flatten!: (?int level) -> self?
1014
1014
 
1015
1015
  # Compute a hash-code for this array.
1016
1016
  #
@@ -1019,7 +1019,7 @@ class Array[unchecked out Elem] < Object
1019
1019
  #
1020
1020
  # See also Object#hash.
1021
1021
  #
1022
- def hash: () -> Integer
1022
+ def hash: () -> ::Integer
1023
1023
 
1024
1024
  # Returns `true` if the given `object` is present in `self` (that is, if any
1025
1025
  # element `==` `object`), otherwise returns `false`.
@@ -1059,7 +1059,7 @@ class Array[unchecked out Elem] < Object
1059
1059
  # a.insert(2, 99) #=> ["a", "b", 99, "c", "d"]
1060
1060
  # a.insert(-2, 1, 2, 3) #=> ["a", "b", 99, "c", 1, 2, 3, "d"]
1061
1061
  #
1062
- def insert: (int index, *Elem obj) -> Array[Elem]
1062
+ def insert: (int index, *Elem obj) -> self
1063
1063
 
1064
1064
  # Creates a string representation of `self`, by calling #inspect on each
1065
1065
  # element.
@@ -1079,7 +1079,7 @@ class Array[unchecked out Elem] < Object
1079
1079
  #
1080
1080
  # See also Array#&.
1081
1081
  #
1082
- def intersection: (*Array[untyped] | _ToAry[untyped] other_ary) -> Array[Elem]
1082
+ def intersection: (*::Array[untyped] | _ToAry[untyped] other_ary) -> ::Array[Elem]
1083
1083
 
1084
1084
  # Returns a string created by converting each element of the array to a string,
1085
1085
  # separated by the given `separator`. If the `separator` is `nil`, it uses
@@ -1106,8 +1106,8 @@ class Array[unchecked out Elem] < Object
1106
1106
  #
1107
1107
  # See also Array#select!.
1108
1108
  #
1109
- def keep_if: () { (Elem item) -> bool } -> Array[Elem]
1110
- | () -> Enumerator[Elem, Array[Elem]]
1109
+ def keep_if: () { (Elem item) -> boolish } -> self
1110
+ | () -> ::Enumerator[Elem, self]
1111
1111
 
1112
1112
  # Returns the last element(s) of `self`. If the array is empty, the first form
1113
1113
  # returns `nil`.
@@ -1119,14 +1119,14 @@ class Array[unchecked out Elem] < Object
1119
1119
  # a.last(2) #=> ["y", "z"]
1120
1120
  #
1121
1121
  def last: () -> Elem?
1122
- | (int n) -> Array[Elem]
1122
+ | (int n) -> ::Array[Elem]
1123
1123
 
1124
1124
  # Returns the number of elements in `self`. May be zero.
1125
1125
  #
1126
1126
  # [ 1, 2, 3, 4, 5 ].length #=> 5
1127
1127
  # [].length #=> 0
1128
1128
  #
1129
- def length: () -> Integer
1129
+ def length: () -> ::Integer
1130
1130
 
1131
1131
  # Invokes the given block once for each element of `self`.
1132
1132
  #
@@ -1172,9 +1172,9 @@ class Array[unchecked out Elem] < Object
1172
1172
  # ary.max(2) {|a, b| a.length <=> b.length } #=> ["albatross", "horse"]
1173
1173
  #
1174
1174
  def max: () -> Elem?
1175
- | () { (Elem a, Elem b) -> Integer? } -> Elem?
1176
- | (int n) -> Array[Elem]
1177
- | (int n) { (Elem a, Elem b) -> Integer? } -> Array[Elem]
1175
+ | () { (Elem a, Elem b) -> ::Integer? } -> Elem?
1176
+ | (int n) -> ::Array[Elem]
1177
+ | (int n) { (Elem a, Elem b) -> ::Integer? } -> ::Array[Elem]
1178
1178
 
1179
1179
  # Returns the object in *ary* with the minimum value. The first form assumes all
1180
1180
  # objects implement Comparable; the second uses the block to return *a <=> b*.
@@ -1198,7 +1198,7 @@ class Array[unchecked out Elem] < Object
1198
1198
  # <=> b`.
1199
1199
  #
1200
1200
  def minmax: () -> [ Elem?, Elem? ]
1201
- | () { (Elem a, Elem b) -> Integer? } -> [ Elem?, Elem? ]
1201
+ | () { (Elem a, Elem b) -> ::Integer? } -> [ Elem?, Elem? ]
1202
1202
 
1203
1203
  # See also Enumerable#none?
1204
1204
  #
@@ -1352,8 +1352,8 @@ class Array[unchecked out Elem] < Object
1352
1352
  # a.permutation(0).to_a #=> [[]] # one permutation of length 0
1353
1353
  # a.permutation(4).to_a #=> [] # no permutations of length 4
1354
1354
  #
1355
- def permutation: (?Integer n) -> Enumerator[Array[Elem], Array[Elem]]
1356
- | (?Integer n) { (Array[Elem] p) -> void } -> Array[Elem]
1355
+ def permutation: (?int n) -> ::Enumerator[::Array[Elem], ::Array[Elem]]
1356
+ | (?int n) { (::Array[Elem] p) -> void } -> ::Array[Elem]
1357
1357
 
1358
1358
  # Removes the last element from `self` and returns it, or `nil` if the array is
1359
1359
  # empty.
@@ -1368,7 +1368,7 @@ class Array[unchecked out Elem] < Object
1368
1368
  # a #=> ["a"]
1369
1369
  #
1370
1370
  def pop: () -> Elem?
1371
- | (int n) -> Array[Elem]
1371
+ | (int n) -> ::Array[Elem]
1372
1372
 
1373
1373
  alias prepend unshift
1374
1374
 
@@ -1387,10 +1387,10 @@ class Array[unchecked out Elem] < Object
1387
1387
  # [1,2].product() #=> [[1],[2]]
1388
1388
  # [1,2].product([]) #=> []
1389
1389
  #
1390
- def product: () -> Array[[Elem]]
1391
- | [X] (Array[X] other_ary) -> Array[[Elem, X]]
1392
- | [X, Y] (Array[X] other_ary1, Array[Y] other_ary2) -> Array[[Elem, X, Y]]
1393
- | [U] (*::Array[U] other_arys) -> Array[Array[Elem | U]]
1390
+ def product: () -> ::Array[[Elem]]
1391
+ | [X] (::Array[X] other_ary) -> ::Array[[Elem, X]]
1392
+ | [X, Y] (::Array[X] other_ary1, ::Array[Y] other_ary2) -> ::Array[[Elem, X, Y]]
1393
+ | [U] (*::Array[U] other_arys) -> ::Array[::Array[Elem | U]]
1394
1394
 
1395
1395
  # Append --- Pushes the given object(s) on to the end of this array. This
1396
1396
  # expression returns the array itself, so several appends may be chained
@@ -1402,7 +1402,7 @@ class Array[unchecked out Elem] < Object
1402
1402
  # [1, 2, 3].push(4).push(5)
1403
1403
  # #=> [1, 2, 3, 4, 5]
1404
1404
  #
1405
- def push: (*Elem obj) -> Array[Elem]
1405
+ def push: (*Elem obj) -> self
1406
1406
 
1407
1407
  # Searches through the array whose elements are also arrays.
1408
1408
  #
@@ -1436,8 +1436,8 @@ class Array[unchecked out Elem] < Object
1436
1436
  #
1437
1437
  # If no block is given, an Enumerator is returned instead.
1438
1438
  #
1439
- def reject!: () { (Elem item) -> bool } -> Array[Elem]?
1440
- | () -> ::Enumerator[Elem, Array[Elem]?]
1439
+ def reject!: () { (Elem item) -> boolish } -> self?
1440
+ | () -> ::Enumerator[Elem, self?]
1441
1441
 
1442
1442
  # When invoked with a block, yields all repeated combinations of length `n` of
1443
1443
  # elements from the array and then returns the array itself.
@@ -1459,8 +1459,8 @@ class Array[unchecked out Elem] < Object
1459
1459
  # # [2,2,2,2],[2,2,2,3],[2,2,3,3],[2,3,3,3],[3,3,3,3]]
1460
1460
  # a.repeated_combination(0).to_a #=> [[]] # one combination of length 0
1461
1461
  #
1462
- def repeated_combination: (int n) { (Array[Elem] c) -> void } -> self
1463
- | (int n) -> Enumerator[Array[Elem], self]
1462
+ def repeated_combination: (int n) { (::Array[Elem] c) -> void } -> self
1463
+ | (int n) -> ::Enumerator[::Array[Elem], self]
1464
1464
 
1465
1465
  # When invoked with a block, yield all repeated permutations of length `n` of
1466
1466
  # the elements of the array, then return the array itself.
@@ -1479,8 +1479,8 @@ class Array[unchecked out Elem] < Object
1479
1479
  # # [2,1,1],[2,1,2],[2,2,1],[2,2,2]]
1480
1480
  # a.repeated_permutation(0).to_a #=> [[]] # one permutation of length 0
1481
1481
  #
1482
- def repeated_permutation: (int n) { (Array[Elem] p) -> void } -> self
1483
- | (int n) -> Enumerator[Array[Elem], self]
1482
+ def repeated_permutation: (int n) { (::Array[Elem] p) -> void } -> self
1483
+ | (int n) -> ::Enumerator[::Array[Elem], self]
1484
1484
 
1485
1485
  # Replaces the contents of `self` with the contents of `other_ary`, truncating
1486
1486
  # or expanding if necessary.
@@ -1489,14 +1489,14 @@ class Array[unchecked out Elem] < Object
1489
1489
  # a.replace([ "x", "y", "z" ]) #=> ["x", "y", "z"]
1490
1490
  # a #=> ["x", "y", "z"]
1491
1491
  #
1492
- def replace: (Array[Elem]) -> self
1492
+ def replace: (::Array[Elem]) -> self
1493
1493
 
1494
1494
  # Returns a new array containing `self`'s elements in reverse order.
1495
1495
  #
1496
1496
  # [ "a", "b", "c" ].reverse #=> ["c", "b", "a"]
1497
1497
  # [ 1 ].reverse #=> [1]
1498
1498
  #
1499
- def reverse: () -> Array[Elem]
1499
+ def reverse: () -> ::Array[Elem]
1500
1500
 
1501
1501
  # Reverses `self` in place.
1502
1502
  #
@@ -1504,7 +1504,7 @@ class Array[unchecked out Elem] < Object
1504
1504
  # a.reverse! #=> ["c", "b", "a"]
1505
1505
  # a #=> ["c", "b", "a"]
1506
1506
  #
1507
- def reverse!: () -> Array[Elem]
1507
+ def reverse!: () -> ::Array[Elem]
1508
1508
 
1509
1509
  # Same as Array#each, but traverses `self` in reverse order.
1510
1510
  #
@@ -1515,8 +1515,8 @@ class Array[unchecked out Elem] < Object
1515
1515
  #
1516
1516
  # c b a
1517
1517
  #
1518
- def reverse_each: () { (Elem item) -> void } -> Array[Elem]
1519
- | () -> Enumerator[Elem, Array[Elem]]
1518
+ def reverse_each: () { (Elem item) -> void } -> self
1519
+ | () -> ::Enumerator[Elem, self]
1520
1520
 
1521
1521
  # Returns the *index* of the last object in `self` `==` to `obj`.
1522
1522
  #
@@ -1534,9 +1534,9 @@ class Array[unchecked out Elem] < Object
1534
1534
  # a.rindex("z") #=> nil
1535
1535
  # a.rindex {|x| x == "b"} #=> 3
1536
1536
  #
1537
- def rindex: (untyped obj) -> Integer?
1538
- | () { (Elem item) -> bool } -> Integer?
1539
- | () -> Enumerator[Elem, Integer?]
1537
+ def rindex: (untyped obj) -> ::Integer?
1538
+ | () { (Elem item) -> boolish } -> ::Integer?
1539
+ | () -> ::Enumerator[Elem, ::Integer?]
1540
1540
 
1541
1541
  # Returns a new array by rotating `self` so that the element at `count` is the
1542
1542
  # first element of the new array.
@@ -1550,7 +1550,7 @@ class Array[unchecked out Elem] < Object
1550
1550
  # a.rotate(2) #=> ["c", "d", "a", "b"]
1551
1551
  # a.rotate(-3) #=> ["b", "c", "d", "a"]
1552
1552
  #
1553
- def rotate: (?int count) -> Array[Elem]
1553
+ def rotate: (?int count) -> ::Array[Elem]
1554
1554
 
1555
1555
  # Rotates `self` in place so that the element at `count` comes first, and
1556
1556
  # returns `self`.
@@ -1564,7 +1564,7 @@ class Array[unchecked out Elem] < Object
1564
1564
  # a.rotate!(2) #=> ["d", "a", "b", "c"]
1565
1565
  # a.rotate!(-3) #=> ["a", "b", "c", "d"]
1566
1566
  #
1567
- def rotate!: (?int count) -> Array[Elem]
1567
+ def rotate!: (?int count) -> self
1568
1568
 
1569
1569
  # Choose a random element or `n` random elements from the array.
1570
1570
  #
@@ -1601,8 +1601,8 @@ class Array[unchecked out Elem] < Object
1601
1601
  #
1602
1602
  # Array#filter is an alias for Array#select.
1603
1603
  #
1604
- def select: () { (Elem item) -> bool } -> Array[Elem]
1605
- | () -> Enumerator[Elem, Array[Elem]]
1604
+ def select: () { (Elem item) -> boolish } -> ::Array[Elem]
1605
+ | () -> ::Enumerator[Elem, ::Array[Elem]]
1606
1606
 
1607
1607
  # Invokes the given block passing in successive elements from `self`, deleting
1608
1608
  # elements for which the block returns a `false` value.
@@ -1617,8 +1617,8 @@ class Array[unchecked out Elem] < Object
1617
1617
  #
1618
1618
  # Array#filter! is an alias for Array#select!.
1619
1619
  #
1620
- def select!: () { (Elem item) -> bool } -> Array[Elem]?
1621
- | () -> ::Enumerator[Elem, Array[Elem]?]
1620
+ def select!: () { (Elem item) -> boolish } -> self?
1621
+ | () -> ::Enumerator[Elem, self?]
1622
1622
 
1623
1623
  # Removes the first element of `self` and returns it (shifting all other
1624
1624
  # elements down by one). Returns `nil` if the array is empty.
@@ -1637,7 +1637,7 @@ class Array[unchecked out Elem] < Object
1637
1637
  # args #=> ["filename"]
1638
1638
  #
1639
1639
  def shift: () -> Elem?
1640
- | (?int n) -> Array[Elem]
1640
+ | (?int n) -> ::Array[Elem]
1641
1641
 
1642
1642
  # Returns a new array with elements of `self` shuffled.
1643
1643
  #
@@ -1649,7 +1649,7 @@ class Array[unchecked out Elem] < Object
1649
1649
  #
1650
1650
  # a.shuffle(random: Random.new(1)) #=> [1, 3, 2]
1651
1651
  #
1652
- def shuffle: (?random: Random rng) -> Array[Elem]
1652
+ def shuffle: (?random: Random rng) -> ::Array[Elem]
1653
1653
 
1654
1654
  # Shuffles elements in `self` in place.
1655
1655
  #
@@ -1661,7 +1661,7 @@ class Array[unchecked out Elem] < Object
1661
1661
  #
1662
1662
  # a.shuffle!(random: Random.new(1)) #=> [1, 3, 2]
1663
1663
  #
1664
- def shuffle!: (?random: Random rng) -> Array[Elem]
1664
+ def shuffle!: (?random: Random rng) -> self
1665
1665
 
1666
1666
  alias size length
1667
1667
 
@@ -1691,8 +1691,8 @@ class Array[unchecked out Elem] < Object
1691
1691
  # a[5..10] #=> []
1692
1692
  #
1693
1693
  def slice: (int index) -> Elem?
1694
- | (int start, int length) -> Array[Elem]?
1695
- | (Range[Integer] range) -> Array[Elem]?
1694
+ | (int start, int length) -> ::Array[Elem]?
1695
+ | (::Range[::Integer] range) -> ::Array[Elem]?
1696
1696
 
1697
1697
  # Deletes the element(s) given by an `index` (optionally up to `length`
1698
1698
  # elements) or by a `range`.
@@ -1709,8 +1709,8 @@ class Array[unchecked out Elem] < Object
1709
1709
  # a #=> ["a"]
1710
1710
  #
1711
1711
  def slice!: (int index) -> Elem?
1712
- | (int start, int length) -> Array[Elem]?
1713
- | (Range[Integer] range) -> Array[Elem]?
1712
+ | (int start, int length) -> ::Array[Elem]?
1713
+ | (::Range[::Integer] range) -> ::Array[Elem]?
1714
1714
 
1715
1715
  # Returns a new array created by sorting `self`.
1716
1716
  #
@@ -1736,7 +1736,7 @@ class Array[unchecked out Elem] < Object
1736
1736
  # See also Enumerable#sort_by.
1737
1737
  #
1738
1738
  def sort: () -> ::Array[Elem]
1739
- | () { (Elem a, Elem b) -> Integer? } -> Array[Elem]
1739
+ | () { (Elem a, Elem b) -> ::Integer? } -> ::Array[Elem]
1740
1740
 
1741
1741
  # Sorts `self` in place.
1742
1742
  #
@@ -1756,8 +1756,8 @@ class Array[unchecked out Elem] < Object
1756
1756
  #
1757
1757
  # See also Enumerable#sort_by.
1758
1758
  #
1759
- def sort!: () -> Array[Elem]
1760
- | () { (Elem a, Elem b) -> Integer? } -> Array[Elem]
1759
+ def sort!: () -> self
1760
+ | () { (Elem a, Elem b) -> ::Integer? } -> self
1761
1761
 
1762
1762
  # Sorts `self` in place using a set of keys generated by mapping the values in
1763
1763
  # `self` through the given block.
@@ -1769,8 +1769,8 @@ class Array[unchecked out Elem] < Object
1769
1769
  #
1770
1770
  # See also Enumerable#sort_by.
1771
1771
  #
1772
- def sort_by!: [U] () { (Elem obj) -> U } -> Array[Elem]
1773
- | () -> Enumerator[Elem, Array[Elem]]
1772
+ def sort_by!: [U] () { (Elem obj) -> U } -> ::Array[Elem]
1773
+ | () -> ::Enumerator[Elem, ::Array[Elem]]
1774
1774
 
1775
1775
  # Returns the sum of elements. For example, [e1, e2, e3].sum returns init + e1 +
1776
1776
  # e2 + e3.
@@ -1828,14 +1828,14 @@ class Array[unchecked out Elem] < Object
1828
1828
  # a = [1, 2, 3, 4, 5, 0]
1829
1829
  # a.take_while {|i| i < 3} #=> [1, 2]
1830
1830
  #
1831
- def take_while: () { (Elem obj) -> bool } -> Array[Elem]
1832
- | () -> Enumerator[Elem, Array[Elem]]
1831
+ def take_while: () { (Elem obj) -> boolish } -> ::Array[Elem]
1832
+ | () -> ::Enumerator[Elem, ::Array[Elem]]
1833
1833
 
1834
1834
  # Returns `self`.
1835
1835
  #
1836
1836
  # If called on a subclass of Array, converts the receiver to an Array object.
1837
1837
  #
1838
- def to_a: () -> Array[Elem]
1838
+ def to_a: () -> ::Array[Elem]
1839
1839
 
1840
1840
  # Returns `self`.
1841
1841
  #
@@ -1864,7 +1864,7 @@ class Array[unchecked out Elem] < Object
1864
1864
  #
1865
1865
  # If the length of the subarrays don't match, an IndexError is raised.
1866
1866
  #
1867
- def transpose: () -> Array[Array[untyped]]
1867
+ def transpose: () -> ::Array[::Array[untyped]]
1868
1868
 
1869
1869
  # Set Union --- Returns a new array by joining `other_ary`s with `self`,
1870
1870
  # excluding any duplicates and preserving the order from the given arrays.
@@ -1877,7 +1877,7 @@ class Array[unchecked out Elem] < Object
1877
1877
  #
1878
1878
  # See also Array#|.
1879
1879
  #
1880
- def union: [T] (*Array[T] other_arys) -> Array[T | Elem]
1880
+ def union: [T] (*::Array[T] other_arys) -> ::Array[T | Elem]
1881
1881
 
1882
1882
  # Returns a new array by removing duplicate values in `self`.
1883
1883
  #
@@ -1893,8 +1893,8 @@ class Array[unchecked out Elem] < Object
1893
1893
  # b = [["student","sam"], ["student","george"], ["teacher","matz"]]
1894
1894
  # b.uniq {|s| s.first} # => [["student", "sam"], ["teacher", "matz"]]
1895
1895
  #
1896
- def uniq: () -> Array[Elem]
1897
- | () { (Elem item) -> untyped } -> Array[Elem]
1896
+ def uniq: () -> ::Array[Elem]
1897
+ | () { (Elem item) -> untyped } -> ::Array[Elem]
1898
1898
 
1899
1899
  # Removes duplicate elements from `self`.
1900
1900
  #
@@ -1915,8 +1915,8 @@ class Array[unchecked out Elem] < Object
1915
1915
  # c = [["student","sam"], ["student","george"], ["teacher","matz"]]
1916
1916
  # c.uniq! {|s| s.first} # => [["student", "sam"], ["teacher", "matz"]]
1917
1917
  #
1918
- def uniq!: () -> Array[Elem]?
1919
- | () { (Elem) -> untyped } -> Array[Elem]?
1918
+ def uniq!: () -> self?
1919
+ | () { (Elem) -> untyped } -> self?
1920
1920
 
1921
1921
  # Prepends objects to the front of `self`, moving other elements upwards. See
1922
1922
  # also Array#shift for the opposite effect.
@@ -1925,7 +1925,7 @@ class Array[unchecked out Elem] < Object
1925
1925
  # a.unshift("a") #=> ["a", "b", "c", "d"]
1926
1926
  # a.unshift(1, 2) #=> [ 1, 2, "a", "b", "c", "d"]
1927
1927
  #
1928
- def unshift: (*Elem obj) -> ::Array[Elem]
1928
+ def unshift: (*Elem obj) -> self
1929
1929
 
1930
1930
  # Returns an array containing the elements in `self` corresponding to the given
1931
1931
  # `selector`(s).
@@ -1940,7 +1940,7 @@ class Array[unchecked out Elem] < Object
1940
1940
  # a.values_at(-1, -2, -2, -7) # => ["f", "e", "e", nil]
1941
1941
  # a.values_at(4..6, 3...6) # => ["e", "f", nil, "d", "e", "f"]
1942
1942
  #
1943
- def values_at: (*int | Range[Integer] selector) -> Array[Elem?]
1943
+ def values_at: (*int | ::Range[::Integer] selector) -> ::Array[Elem?]
1944
1944
 
1945
1945
  # Converts any arguments to arrays, then merges elements of `self` with
1946
1946
  # corresponding elements from each argument.
@@ -1960,10 +1960,10 @@ class Array[unchecked out Elem] < Object
1960
1960
  # [1, 2].zip(a, b) #=> [[1, 4, 7], [2, 5, 8]]
1961
1961
  # a.zip([1, 2], [8]) #=> [[4, 1, 8], [5, 2, nil], [6, nil, nil]]
1962
1962
  #
1963
- def zip: [U] (Array[U] arg) -> Array[[ Elem, U? ]]
1964
- | (Array[untyped] arg, *Array[untyped] args) -> Array[Array[untyped]]
1965
- | [U] (Array[U] arg) { ([Elem, U?]) -> void } -> void
1966
- | (Array[untyped] arg, *Array[untyped] args) { (Array[untyped]) -> void } -> void
1963
+ def zip: [U] (::Array[U] arg) -> ::Array[[ Elem, U? ]]
1964
+ | (::Array[untyped] arg, *::Array[untyped] args) -> ::Array[::Array[untyped]]
1965
+ | [U] (::Array[U] arg) { ([Elem, U?]) -> void } -> void
1966
+ | (::Array[untyped] arg, *::Array[untyped] args) { (::Array[untyped]) -> void } -> void
1967
1967
 
1968
1968
  # Set Union --- Returns a new array by joining `ary` with `other_ary`, excluding
1969
1969
  # any duplicates and preserving the order from the given arrays.
@@ -1975,7 +1975,7 @@ class Array[unchecked out Elem] < Object
1975
1975
  #
1976
1976
  # See also Array#union.
1977
1977
  #
1978
- def |: [T] (Array[T] other_ary) -> Array[Elem | T]
1978
+ def |: [T] (::Array[T] other_ary) -> ::Array[Elem | T]
1979
1979
 
1980
1980
  private
1981
1981
 
@@ -1989,8 +1989,12 @@ class Array[unchecked out Elem] < Object
1989
1989
  def initialize_copy: (self other_ary) -> void
1990
1990
  end
1991
1991
 
1992
+ interface _ToA[T]
1993
+ def to_a: () -> Array[T]
1994
+ end
1995
+
1992
1996
  interface _ToAry[T]
1993
- def to_ary: () -> Array[T]
1997
+ def to_ary: () -> ::Array[T]
1994
1998
  end
1995
1999
 
1996
2000
  interface Array::_Pattern[T]