rbs 0.13.0 → 0.17.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (156) hide show
  1. checksums.yaml +4 -4
  2. data/.github/workflows/ruby.yml +9 -5
  3. data/.gitignore +0 -1
  4. data/CHANGELOG.md +33 -1
  5. data/Gemfile +4 -0
  6. data/README.md +9 -3
  7. data/Rakefile +14 -1
  8. data/Steepfile +1 -1
  9. data/bin/annotate-with-rdoc +1 -1
  10. data/bin/setup +0 -2
  11. data/bin/test_runner.rb +15 -1
  12. data/{stdlib/builtin → core}/array.rbs +124 -120
  13. data/{stdlib/builtin → core}/basic_object.rbs +54 -54
  14. data/{stdlib/builtin → core}/binding.rbs +42 -42
  15. data/core/builtin.rbs +70 -0
  16. data/{stdlib/builtin → core}/class.rbs +33 -33
  17. data/{stdlib/builtin → core}/comparable.rbs +0 -0
  18. data/{stdlib/builtin → core}/complex.rbs +90 -90
  19. data/{stdlib/builtin → core}/constants.rbs +0 -0
  20. data/{stdlib/builtin → core}/data.rbs +0 -0
  21. data/{stdlib/builtin → core}/deprecated.rbs +0 -0
  22. data/{stdlib/builtin → core}/dir.rbs +1 -1
  23. data/{stdlib/builtin → core}/encoding.rbs +33 -33
  24. data/{stdlib/builtin → core}/enumerable.rbs +99 -92
  25. data/{stdlib/builtin → core}/enumerator.rbs +40 -40
  26. data/{stdlib/builtin → core}/errno.rbs +0 -0
  27. data/{stdlib/builtin → core}/errors.rbs +2 -2
  28. data/{stdlib/builtin → core}/exception.rbs +50 -50
  29. data/{stdlib/builtin → core}/false_class.rbs +6 -6
  30. data/{stdlib/builtin → core}/fiber.rbs +14 -14
  31. data/{stdlib/builtin → core}/fiber_error.rbs +1 -1
  32. data/{stdlib/builtin → core}/file.rbs +0 -0
  33. data/{stdlib/builtin → core}/file_test.rbs +0 -0
  34. data/{stdlib/builtin → core}/float.rbs +161 -161
  35. data/{stdlib/builtin → core}/gc.rbs +3 -3
  36. data/{stdlib/builtin → core}/hash.rbs +15 -15
  37. data/{stdlib/builtin → core}/integer.rbs +0 -0
  38. data/{stdlib/builtin → core}/io.rbs +89 -89
  39. data/{stdlib/builtin → core}/kernel.rbs +70 -154
  40. data/{stdlib/builtin → core}/marshal.rbs +0 -0
  41. data/{stdlib/builtin → core}/match_data.rbs +1 -1
  42. data/{stdlib/builtin → core}/math.rbs +0 -0
  43. data/{stdlib/builtin → core}/method.rbs +19 -19
  44. data/{stdlib/builtin → core}/module.rbs +13 -13
  45. data/{stdlib/builtin → core}/nil_class.rbs +20 -20
  46. data/{stdlib/builtin → core}/numeric.rbs +101 -101
  47. data/{stdlib/builtin → core}/object.rbs +173 -173
  48. data/{stdlib/builtin → core}/proc.rbs +91 -91
  49. data/{stdlib/builtin → core}/process.rbs +0 -0
  50. data/{stdlib/builtin → core}/random.rbs +1 -1
  51. data/{stdlib/builtin → core}/range.rbs +4 -6
  52. data/{stdlib/builtin → core}/rational.rbs +83 -83
  53. data/{stdlib/builtin → core}/rb_config.rbs +0 -0
  54. data/{stdlib/builtin → core}/regexp.rbs +0 -0
  55. data/{stdlib/builtin → core}/ruby_vm.rbs +0 -0
  56. data/{stdlib/builtin → core}/signal.rbs +7 -7
  57. data/{stdlib/builtin → core}/string.rbs +10 -10
  58. data/{stdlib/builtin → core}/string_io.rbs +8 -8
  59. data/{stdlib/builtin → core}/struct.rbs +2 -2
  60. data/{stdlib/builtin → core}/symbol.rbs +1 -1
  61. data/{stdlib/builtin → core}/thread.rbs +189 -189
  62. data/{stdlib/builtin → core}/thread_group.rbs +2 -2
  63. data/{stdlib/builtin → core}/time.rbs +0 -0
  64. data/{stdlib/builtin → core}/trace_point.rbs +0 -0
  65. data/{stdlib/builtin → core}/true_class.rbs +10 -10
  66. data/{stdlib/builtin → core}/unbound_method.rbs +0 -0
  67. data/{stdlib/builtin → core}/warning.rbs +1 -1
  68. data/docs/CONTRIBUTING.md +1 -0
  69. data/docs/repo.md +125 -0
  70. data/docs/syntax.md +50 -6
  71. data/goodcheck.yml +22 -5
  72. data/lib/rbs.rb +1 -0
  73. data/lib/rbs/ast/comment.rb +1 -1
  74. data/lib/rbs/cli.rb +105 -103
  75. data/lib/rbs/definition.rb +9 -4
  76. data/lib/rbs/definition_builder.rb +54 -22
  77. data/lib/rbs/environment.rb +1 -1
  78. data/lib/rbs/environment_loader.rb +79 -105
  79. data/lib/rbs/namespace.rb +1 -1
  80. data/lib/rbs/parser.rb +3153 -0
  81. data/lib/rbs/parser.y +25 -11
  82. data/lib/rbs/prototype/rb.rb +47 -9
  83. data/lib/rbs/prototype/runtime.rb +17 -7
  84. data/lib/rbs/repository.rb +121 -0
  85. data/lib/rbs/test/hook.rb +2 -0
  86. data/lib/rbs/test/setup.rb +5 -3
  87. data/lib/rbs/test/setup_helper.rb +4 -4
  88. data/lib/rbs/test/tester.rb +4 -1
  89. data/lib/rbs/test/type_check.rb +12 -6
  90. data/lib/rbs/type_name.rb +3 -2
  91. data/lib/rbs/variance_calculator.rb +1 -1
  92. data/lib/rbs/vendorer.rb +38 -16
  93. data/lib/rbs/version.rb +1 -1
  94. data/lib/rbs/writer.rb +1 -1
  95. data/sig/cli.rbs +58 -0
  96. data/sig/constant.rbs +2 -2
  97. data/sig/constant_table.rbs +11 -11
  98. data/sig/declarations.rbs +2 -2
  99. data/sig/definition.rbs +10 -5
  100. data/sig/definition_builder.rbs +4 -1
  101. data/sig/environment_loader.rbs +92 -46
  102. data/sig/members.rbs +2 -2
  103. data/sig/method_types.rbs +1 -1
  104. data/sig/namespace.rbs +4 -4
  105. data/sig/parser.rbs +25 -0
  106. data/sig/polyfill.rbs +42 -0
  107. data/sig/rbs.rbs +8 -0
  108. data/sig/repository.rbs +79 -0
  109. data/sig/substitution.rbs +3 -3
  110. data/sig/typename.rbs +1 -1
  111. data/sig/types.rbs +1 -1
  112. data/sig/vendorer.rbs +44 -0
  113. data/sig/writer.rbs +15 -15
  114. data/stdlib/abbrev/{abbrev.rbs → 0/abbrev.rbs} +0 -0
  115. data/stdlib/base64/{base64.rbs → 0/base64.rbs} +1 -1
  116. data/stdlib/benchmark/{benchmark.rbs → 0/benchmark.rbs} +2 -2
  117. data/stdlib/{bigdecimal/math → bigdecimal-math/0}/big_math.rbs +0 -0
  118. data/stdlib/bigdecimal/{big_decimal.rbs → 0/big_decimal.rbs} +0 -0
  119. data/stdlib/coverage/{coverage.rbs → 0/coverage.rbs} +2 -2
  120. data/stdlib/csv/{csv.rbs → 0/csv.rbs} +4 -4
  121. data/stdlib/date/{date.rbs → 0/date.rbs} +4 -4
  122. data/stdlib/date/{date_time.rbs → 0/date_time.rbs} +1 -1
  123. data/stdlib/dbm/0/dbm.rbs +277 -0
  124. data/stdlib/erb/{erb.rbs → 0/erb.rbs} +0 -0
  125. data/stdlib/fiber/{fiber.rbs → 0/fiber.rbs} +0 -0
  126. data/stdlib/find/{find.rbs → 0/find.rbs} +12 -12
  127. data/stdlib/forwardable/{forwardable.rbs → 0/forwardable.rbs} +0 -0
  128. data/stdlib/ipaddr/{ipaddr.rbs → 0/ipaddr.rbs} +0 -0
  129. data/stdlib/json/{json.rbs → 0/json.rbs} +0 -0
  130. data/stdlib/logger/{formatter.rbs → 0/formatter.rbs} +0 -0
  131. data/stdlib/logger/{log_device.rbs → 0/log_device.rbs} +1 -1
  132. data/stdlib/logger/{logger.rbs → 0/logger.rbs} +1 -1
  133. data/stdlib/logger/{period.rbs → 0/period.rbs} +0 -0
  134. data/stdlib/logger/{severity.rbs → 0/severity.rbs} +0 -0
  135. data/stdlib/mutex_m/{mutex_m.rbs → 0/mutex_m.rbs} +0 -0
  136. data/stdlib/pathname/{pathname.rbs → 0/pathname.rbs} +40 -40
  137. data/stdlib/prime/{integer-extension.rbs → 0/integer-extension.rbs} +0 -0
  138. data/stdlib/prime/{prime.rbs → 0/prime.rbs} +1 -1
  139. data/stdlib/pstore/0/pstore.rbs +287 -0
  140. data/stdlib/pty/{pty.rbs → 0/pty.rbs} +1 -1
  141. data/stdlib/securerandom/{securerandom.rbs → 0/securerandom.rbs} +0 -0
  142. data/stdlib/set/{set.rbs → 0/set.rbs} +10 -10
  143. data/stdlib/tmpdir/{tmpdir.rbs → 0/tmpdir.rbs} +12 -12
  144. data/stdlib/tsort/0/cyclic.rbs +4 -0
  145. data/stdlib/tsort/0/interfaces.rbs +19 -0
  146. data/stdlib/tsort/0/tsort.rbs +363 -0
  147. data/stdlib/uri/{file.rbs → 0/file.rbs} +0 -0
  148. data/stdlib/uri/{generic.rbs → 0/generic.rbs} +1 -1
  149. data/stdlib/uri/{http.rbs → 0/http.rbs} +0 -0
  150. data/stdlib/uri/{https.rbs → 0/https.rbs} +0 -0
  151. data/stdlib/uri/{ldap.rbs → 0/ldap.rbs} +0 -0
  152. data/stdlib/uri/{ldaps.rbs → 0/ldaps.rbs} +0 -0
  153. data/stdlib/zlib/{zlib.rbs → 0/zlib.rbs} +0 -0
  154. data/steep/Gemfile.lock +9 -9
  155. metadata +104 -93
  156. data/stdlib/builtin/builtin.rbs +0 -42
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: b9e733e8a7ed63c585d2a2253728700a7cdca633fd6a7953fb95cda24f423604
4
- data.tar.gz: e690e3412cc614e0ce7d8c379e78f2d39d5a2def56f2e7165322db7c421cffd2
3
+ metadata.gz: f458be96f0cfc3e45e51bb77f4d42aafba7f1fee62e0ed8695eb6a95b85189b2
4
+ data.tar.gz: 9b84c8860182155f4e5979e668a953d1b8191754f01c6443d549fc14b5be1908
5
5
  SHA512:
6
- metadata.gz: 87bcb3459cb7ef4ac2e56f1047064e0d2b7412d19023ae63b1329e8e40a1dcff3ce3766cfc1086c8447aa2b2e4aea5207e1bf901b25c3f3d49072d90f5a6c694
7
- data.tar.gz: 916e9bb2f678fa321862700f386b09b7de88a127e7d4ba92d9b6139f030a865db18a976e51a5820b84caa4c6598aafda876c5e7183a3ed3ff19b8054cfa16842
6
+ metadata.gz: f0c7616abdb3a3d4e08212014aebad858e113acf265641e4f657b2d48b9e20ec8ac7744a18f90459086be39953eb7ebef9d32acd3b22362e31d6e12e83251baf
7
+ data.tar.gz: ee12553e0611d2b8826d9687ab63fcc38bfb67435bcf537950b31ef6070c26d85fcf8d956ccc1285072e6513facdbd43521935ae9372a11cae6f100e16691084
@@ -12,17 +12,21 @@ jobs:
12
12
  strategy:
13
13
  matrix:
14
14
  container_tag:
15
- - master-nightly-bionic
16
- - 2.6.5-bionic
17
- - 2.7.0-bionic
15
+ - master-nightly-bionic
16
+ - 2.6-bionic
17
+ - 2.7-bionic
18
18
  job:
19
19
  - test
20
20
  - stdlib_test
21
- - rubocop validate test_doc build test_generate_stdlib
21
+ - rubocop validate test_doc build test_generate_stdlib confirm_parser
22
22
  container:
23
23
  image: rubylang/ruby:${{ matrix.container_tag }}
24
24
  steps:
25
25
  - uses: actions/checkout@v1
26
+ - name: Install dependencies
27
+ run: |
28
+ apt-get update
29
+ apt-get install -y libdb-dev
26
30
  - name: Install
27
31
  run: |
28
32
  ruby -v
@@ -31,4 +35,4 @@ jobs:
31
35
  - name: Run test
32
36
  run: |
33
37
  bundle exec rake ${{ matrix.job }}
34
- if: "!(matrix.job == 'stdlib_test' && contains(matrix.container_tag, '2.6.5'))"
38
+ if: "!(matrix.job == 'stdlib_test' && contains(matrix.container_tag, '2.6'))"
data/.gitignore CHANGED
@@ -6,7 +6,6 @@
6
6
  /spec/reports/
7
7
  /tmp/
8
8
  /.ruby-version
9
- /lib/rbs/parser.rb
10
9
  /lib/rbs/parser.output
11
10
  /vendor/sigs
12
11
  /Gemfile.lock
@@ -2,7 +2,39 @@
2
2
 
3
3
  ## master
4
4
 
5
- ## 0.13.0 (2020-09-09)
5
+ ## 0.17.0 (2020-11-14)
6
+
7
+ * Signature updates for `Enumerable`, `Hash`, and `TSort` ([#462](https://github.com/ruby/rbs/pull/462), [#468](https://github.com/ruby/rbs/pull/468), [#471](https://github.com/ruby/rbs/pull/471), [#472](https://github.com/ruby/rbs/pull/472), [#473](https://github.com/ruby/rbs/pull/473), [#474](https://github.com/ruby/rbs/pull/474))
8
+ * Parser error handling improvement ([#463](https://github.com/ruby/rbs/pull/463), [#475](https://github.com/ruby/rbs/pull/475))
9
+ * Hash spread syntax handling improvement with `prototype rb` ([#465](https://github.com/ruby/rbs/pull/465))
10
+
11
+ ## 0.16.0 (2020-11-05)
12
+
13
+ * Signature update for `DBM` ([#441](https://github.com/ruby/rbs/pull/441))
14
+ * RBS repository ([#405](https://github.com/ruby/rbs/pull/405))
15
+ * Support `alias` in `rbs prototype rb` ([#457](https://github.com/ruby/rbs/pull/457))
16
+
17
+ ## 0.15.0 (2020-11-02)
18
+
19
+ * Signature updates for `Kernel`, `PStore`, `Enumerable`, and `Array` ([#450](https://github.com/ruby/rbs/pull/450), [#443](https://github.com/ruby/rbs/pull/443), [#438](https://github.com/ruby/rbs/pull/438), [#437](https://github.com/ruby/rbs/pull/437), [#433](https://github.com/ruby/rbs/pull/433), [#432](https://github.com/ruby/rbs/pull/432))
20
+ * Add helper interfaces ([#434](https://github.com/ruby/rbs/pull/434), [#428](https://github.com/ruby/rbs/pull/428))
21
+ * Change `bool` type semantics ([#456](https://github.com/ruby/rbs/pull/456))
22
+ * Support alias in `rbs prototype rb` ([#457](https://github.com/ruby/rbs/pull/457))
23
+ * Runtime testing improvements ([#455](https://github.com/ruby/rbs/pull/455), [#447](https://github.com/ruby/rbs/pull/447), [#444](https://github.com/ruby/rbs/pull/444), [#431](https://github.com/ruby/rbs/pull/431))
24
+ * Fix proc type parsing ([#451](https://github.com/ruby/rbs/pull/451))
25
+ * Fix type variable parsing ([#442](https://github.com/ruby/rbs/pull/442))
26
+
27
+
28
+ ## 0.14.0 (2020-10-17)
29
+
30
+ * Allow keyword names ending with `?` and `!` ([#417](https://github.com/ruby/rbs/pull/417))
31
+ * Make `Range[T]` covariant ([#418](https://github.com/ruby/rbs/pull/418))
32
+
33
+ ## 0.13.1 (2020-10-09)
34
+
35
+ * Fix test for CI of ruby/ruby ([#412](https://github.com/ruby/rbs/pull/412))
36
+
37
+ ## 0.13.0 (2020-10-09)
6
38
 
7
39
  * Signature updates for `URI` classes.
8
40
  * Fix tests ([#410](https://github.com/ruby/rbs/pull/410))
data/Gemfile CHANGED
@@ -15,7 +15,11 @@ gem "json"
15
15
  gem "json-schema"
16
16
  gem 'stackprof'
17
17
  gem "goodcheck"
18
+ gem "dbm"
18
19
 
19
20
  # Test gems
20
21
  gem "rbs-amber", path: "test/assets/test-gem"
21
22
 
23
+ group :ide, optional: true do
24
+ gem "ruby-debug-ide"
25
+ end
data/README.md CHANGED
@@ -46,7 +46,7 @@ module ChatApp
46
46
  def initialize: (name: String) -> void
47
47
 
48
48
  def each_member: () { (User | Bot) -> void } -> void # `{` and `}` means block.
49
- | () -> Enumerable[User | Bot, void] # Method can be overloaded.
49
+ | () -> Enumerator[User | Bot, void] # Method can be overloaded.
50
50
  end
51
51
  end
52
52
  ```
@@ -74,7 +74,7 @@ $ rbs method Object then
74
74
 
75
75
  ## Library
76
76
 
77
- There are two important concepts, _environment_ and _definition_.
77
+ There are two important concepts, _environment_ and _definition_.
78
78
 
79
79
  An _environment_ is a dictionary that keeps track of all declarations. What is the declaration associated with `String` class? An _environment_ will give you the answer.
80
80
 
@@ -104,8 +104,14 @@ builder = RBS::DefinitionBuilder.new(env: environment)
104
104
 
105
105
  # Definition of instance of String
106
106
  instance = builder.build_instance(string)
107
- # Print the types of `gsub` method
107
+
108
+ # Print the types of `gsub` method:
108
109
  puts instance.methods[:gsub].method_types.join("\n")
110
+ # Ouputs =>
111
+ # (::Regexp | ::string pattern, ::string replacement) -> ::String
112
+ # (::Regexp | ::string pattern, ::Hash[::String, ::String] hash) -> ::String
113
+ # (::Regexp | ::string pattern) { (::String match) -> ::_ToS } -> ::String
114
+ # (::Regexp | ::string pattern) -> ::Enumerator[::String, self]
109
115
 
110
116
  # Definition of singleton of String
111
117
  singleton = builder.build_singleton(string)
data/Rakefile CHANGED
@@ -29,7 +29,14 @@ task :validate => :parser do
29
29
 
30
30
  FileList["stdlib/*"].each do |path|
31
31
  next if path =~ %r{stdlib/builtin}
32
- sh "#{ruby} #{rbs} -r#{File.basename(path)} validate --silent"
32
+
33
+ lib = [File.basename(path).to_s]
34
+
35
+ if lib == ["bigdecimal-math"]
36
+ lib << "bigdecimal"
37
+ end
38
+
39
+ sh "#{ruby} #{rbs} #{lib.map {|l| "-r #{l}"}.join(" ")} validate --silent"
33
40
  end
34
41
  end
35
42
 
@@ -53,6 +60,12 @@ task :test => :parser
53
60
  task :stdlib_test => :parser
54
61
  task :build => :parser
55
62
 
63
+ task :confirm_parser do
64
+ puts "Testing if parser.rb is updated with respect to parser.y"
65
+ sh "racc -v -o lib/rbs/parser.rb lib/rbs/parser.y"
66
+ sh "git diff --exit-code lib/rbs/parser.rb"
67
+ end
68
+
56
69
  namespace :generate do
57
70
  task :stdlib_test, [:class] do |_task, args|
58
71
  klass = args.fetch(:class) do
data/Steepfile CHANGED
@@ -1,8 +1,8 @@
1
1
  target :lib do
2
2
  signature "sig"
3
3
  check "lib"
4
+ ignore "lib/rbs/parser.rb"
4
5
 
5
- vendor stdlib: "stdlib"
6
6
  library "set", "pathname", "json", "logger"
7
7
  end
8
8
 
@@ -14,7 +14,7 @@ def format_comment(comment)
14
14
  out = RDoc::Markup::Document.new
15
15
  out << comment
16
16
  formatter = RDoc::Markup::ToMarkdown.new
17
- out.accept(formatter)
17
+ out.accept(formatter).lines.map(&:rstrip).join("\n")
18
18
  end
19
19
 
20
20
  def comment_for_constant(decl, stores:)
data/bin/setup CHANGED
@@ -6,5 +6,3 @@ set -vx
6
6
  bundle install --jobs 4 --retry 3
7
7
 
8
8
  # Do any other automated setup that you need to do here
9
-
10
- bundle exec rake parser
@@ -2,6 +2,8 @@
2
2
 
3
3
  $LOAD_PATH << File.join(__dir__, "../lib")
4
4
 
5
+ require "set"
6
+
5
7
  IS_RUBY_27 = Gem::Version.new(RUBY_VERSION).yield_self do |ruby_version|
6
8
  Gem::Version.new('2.7.0') <= ruby_version &&
7
9
  ruby_version <= Gem::Version.new('2.8.0')
@@ -11,6 +13,18 @@ unless IS_RUBY_27
11
13
  STDERR.puts "⚠️⚠️⚠️⚠️ stdlib test assumes Ruby 2.7 but RUBY_VERSION==#{RUBY_VERSION} ⚠️⚠️⚠️⚠️"
12
14
  end
13
15
 
16
+ KNOWN_FAILS = %w(dbm).map do |lib|
17
+ /cannot load such file -- #{lib}/
18
+ end
19
+
14
20
  ARGV.each do |arg|
15
- load arg
21
+ begin
22
+ load arg
23
+ rescue LoadError => exn
24
+ if KNOWN_FAILS.any? {|pat| pat =~ exn.message }
25
+ STDERR.puts "Loading #{arg} failed, ignoring it: #{exn.inspect}"
26
+ else
27
+ raise
28
+ end
29
+ end
16
30
  end
@@ -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]
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]