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
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 5f566c8a8b046574b66d406b1d049d982867b31e551e3faf85a3afde6ed85916
4
- data.tar.gz: 0aa60fd17edfe999f4c9d8460d0aaed46a24424cdde490ac767ee6b54d192d26
3
+ metadata.gz: 5348f41dbf169228104d4ba79ad88098ec3e8e83656b48b0b1c5877fab2e8cb7
4
+ data.tar.gz: c79ce48144a85642f974b0973e22f8ed97a072d98ce98e2b62aebf639c8d04f7
5
5
  SHA512:
6
- metadata.gz: 997754b8a0f57c831357f08e37ef93219bf75c60d1ce270232989c7c485a42c42fc5f2fdf88ecf002e2d78b56ccdccdd60ec437dc0e0a6616d15a492cf77af23
7
- data.tar.gz: f1fe9f1e6a33b259e4e8eb407bcd6019a24b40eed427992658ff728d5cad9d68b26054058de7840caa589dc796dc44f10003823ff8752d28827b26f27a44ca76
6
+ metadata.gz: efb99d0e6476b83dbd1994a71526adab4b5b6aab2fc231a1685407739bb9a3e2f1268fb3effcbe701fa033608a0b872fd3f0011d046c599457bf47a3c3fcdb97
7
+ data.tar.gz: 87d13112f6abce7b7ead4e95302978d17c7c08eaf94485bf27c00c5d91e08f8c10458344661b73d518caff095787323d3694512d76796f2d20da8c2bad2e101f
@@ -12,7 +12,7 @@ jobs:
12
12
  strategy:
13
13
  matrix:
14
14
  container_tag:
15
- - master-nightly-bionic
15
+ - master-nightly-bionic
16
16
  - 2.6.5-bionic
17
17
  - 2.7.0-bionic
18
18
  job:
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,6 +2,37 @@
2
2
 
3
3
  ## master
4
4
 
5
+ ## 0.15.0 (2020-11-2)
6
+
7
+ * 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))
8
+ * Add helper interfaces ([#434](https://github.com/ruby/rbs/pull/434), [#428](https://github.com/ruby/rbs/pull/428))
9
+ * Change `bool` type semantics ([#456](https://github.com/ruby/rbs/pull/456))
10
+ * Support alias in `rbs prototype rb` ([#457](https://github.com/ruby/rbs/pull/457))
11
+ * 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))
12
+ * Fix proc type parsing ([#451](https://github.com/ruby/rbs/pull/451))
13
+ * Fix type variable parsing ([#442](https://github.com/ruby/rbs/pull/442))
14
+
15
+
16
+ ## 0.14.0 (2020-10-17)
17
+
18
+ * Allow keyword names ending with `?` and `!` ([#417](https://github.com/ruby/rbs/pull/417))
19
+ * Make `Range[T]` covariant ([#418](https://github.com/ruby/rbs/pull/418))
20
+
21
+ ## 0.13.1 (2020-10-09)
22
+
23
+ * Fix test for CI of ruby/ruby ([#412](https://github.com/ruby/rbs/pull/412))
24
+
25
+ ## 0.13.0 (2020-10-09)
26
+
27
+ * Signature updates for `URI` classes.
28
+ * Fix tests ([#410](https://github.com/ruby/rbs/pull/410))
29
+ * Add `--silent` option for `rbs validate` ([#411](https://github.com/ruby/rbs/pull/411))
30
+
31
+ ## 0.12.2 (2020-09-17)
32
+
33
+ * Minor signature update for `pty`
34
+ * Fix `PTY` stdlib test
35
+
5
36
  ## 0.12.1 (2020-09-16)
6
37
 
7
38
  This version is to improve Ruby 3 testing compatibility. Nothing changed for users.
data/Gemfile CHANGED
@@ -19,3 +19,6 @@ gem "goodcheck"
19
19
  # Test gems
20
20
  gem "rbs-amber", path: "test/assets/test-gem"
21
21
 
22
+ group :ide, optional: true do
23
+ gem "ruby-debug-ide"
24
+ end
data/README.md CHANGED
@@ -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
@@ -25,11 +25,11 @@ task :test_doc => :parser do
25
25
  end
26
26
 
27
27
  task :validate => :parser do
28
- sh "#{ruby} #{rbs} validate"
28
+ sh "#{ruby} #{rbs} validate --silent"
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"
32
+ sh "#{ruby} #{rbs} -r#{File.basename(path)} validate --silent"
33
33
  end
34
34
  end
35
35
 
data/Steepfile CHANGED
@@ -1,6 +1,7 @@
1
1
  target :lib do
2
2
  signature "sig"
3
3
  check "lib"
4
+ ignore "lib/rbs/parser.rb"
4
5
 
5
6
  vendor stdlib: "stdlib"
6
7
  library "set", "pathname", "json", "logger"
@@ -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
@@ -17,6 +17,7 @@
17
17
  - Use `rbs prototype runtime --merge CLASS_NAME` command to generate the missing method definitions.
18
18
  - Committing the auto generated signatures is recommended.
19
19
  5. Annotate with RDoc.
20
+ - You'll need RDoc installed. Rvm users should use `rvm docs generate` first.
20
21
  - Use `bin/annotate-with-rdoc stdlib/path/to/signature.rbs` to annotate the RBS files.
21
22
  - Committing the generated annotations is recommended.
22
23
  6. Fix method types and comments.
@@ -179,7 +179,7 @@ Proc type denotes type of procedures, `Proc` instances.
179
179
 
180
180
  `instance` denotes the type of instance of the class. `class` is the singleton of the class.
181
181
 
182
- `bool` is an abstract type for truth value.
182
+ `bool` is an alias of `true | false`.
183
183
 
184
184
  `untyped` is for _a type without type checking_. It is `?` in gradual typing, _dynamic_ in some languages like C#, and _any_ in TypeScript. It is both subtype _and_ supertype of all of the types. (The type was `any` but renamed to `untyped`.)
185
185
 
@@ -193,15 +193,34 @@ Proc type denotes type of procedures, `Proc` instances.
193
193
 
194
194
  We recommend using `nil`.
195
195
 
196
- #### `bool` or `TrueClass | FalseClass`
196
+ #### `bool` or `boolish`
197
197
 
198
- We recommend using `bool` because it is more close to Ruby's semantics. If the type of a parameter of a method is `bool`, we usually pass `true` and `false`, and also `nil` or any other values. `TrueClass | FalseClass` rejects other values than `true` and `false`.
198
+ We have a builtin type alias called `boolish`.
199
+ It is an alias of `top` type, and you can use `boolish` if we want to allow any object of any type.
199
200
 
200
- #### `void`, `bool`, or `top`?
201
+ We can see an example at the definition of `Enumerable#find`:
202
+
203
+ ```
204
+ module Enumerable[Elem, Return]
205
+ def find: () { (Elem) -> boolish } -> Elem?
206
+ ...
207
+ end
208
+ ```
209
+
210
+ We want to write something like:
211
+
212
+ ```
213
+ array.find {|x| x && x.some_test? } # The block will return (bool | nil)
214
+ ```
215
+
216
+ We recommend using `boolish` for method arguments and block return values, if you only use the values for conditions.
217
+ You can write `bool` if you strictly want `true | false`.
218
+
219
+ #### `void`, `boolish`, or `top`?
201
220
 
202
221
  They are all equivalent for the type system; they are all _top type_.
203
222
 
204
- `void` tells developers a hint that _the value should not be used_. `bool` implies the value is used as a truth value. `top` is anything else.
223
+ `void` tells developers a hint that _the value should not be used_. `boolish` implies the value is used as a truth value. `top` is anything else.
205
224
 
206
225
  ## Method Types
207
226
 
@@ -433,8 +452,10 @@ _global-name_ ::= /$[a-zA-Z]\w+/ | ...
433
452
  _module-type-parameters_ ::= # Empty
434
453
  | `[` _module-type-parameter_ `,` ... `]`
435
454
 
436
- _module-type-parameter_ ::= _variance_ _type-variable_
455
+ _module-type-parameter_ ::= _check_ _variance_ _type-variable_
437
456
  _variance_ ::= `out` | `in`
457
+ _check_ ::= # Empty
458
+ | `unchecked`
438
459
  ```
439
460
 
440
461
  ### Class declaration
@@ -448,6 +469,29 @@ class Ref[A] < Object
448
469
  end
449
470
  ```
450
471
 
472
+ For classes with type parameters, you may specify if they are "invariant" (default), "covariant" (`out`) or "contravariant" (`in`). See [this definition of covariance and contravariance](https://en.wikipedia.org/wiki/Covariance_and_contravariance_(computer_science)).
473
+
474
+ For example, an `Array` of `String` can almost be considered to be an `Array` of `Object`, but not the reverse, so we can think of:
475
+
476
+ ```
477
+ class Array[out T]
478
+ # ...
479
+ end
480
+ ```
481
+
482
+ There's a limitation with this is for mutable objects (like arrays): a mutation could invalidate this.
483
+ If an array of String is passed to a method as an array of Objects, and that method adds an Integer to the array, the promise is broken.
484
+
485
+ In those cases, one must use the `unchecked` keyword:
486
+
487
+ ```
488
+ class Array[unchecked out T]
489
+ # ...
490
+ end
491
+ ```
492
+
493
+ This is how `Array` is actually defined in RBS.
494
+
451
495
  ### Module declaration
452
496
 
453
497
  Module declaration takes optional _self type_ parameter, which defines a constraint about a class when the module is mixed.
@@ -6,12 +6,12 @@ rules:
6
6
  - "stdlib/**/*.rbs"
7
7
  fail:
8
8
  - |
9
- # arglists 💪👽🚨 << Delete this section
10
- # File.absolute_path?(file_name) -> true or false
9
+ # arglists 💪👽🚨 << Delete this section
10
+ # File.absolute_path?(file_name) -> true or false
11
11
  #
12
12
 
13
13
  - id: rbs.no_arg
14
- pattern:
14
+ pattern:
15
15
  regexp: arg\d+
16
16
  message: |
17
17
  Stop using parameter names like `arg0` or `arg1`
@@ -23,7 +23,7 @@ rules:
23
23
  - Documents (comments) may contain that pattern.
24
24
  glob:
25
25
  - "stdlib/**/*.rbs"
26
- fail:
26
+ fail:
27
27
  - "def `send`: (String | Symbol arg0, *untyped arg1) -> untyped"
28
28
  pass:
29
29
  - "def `send`: (String | Symbol, *untyped) -> untyped"
@@ -62,4 +62,21 @@ rules:
62
62
  end
63
63
  end
64
64
 
65
-
65
+ - id: no_trailing_whitespace
66
+ pattern:
67
+ regexp: '[ \t]+$'
68
+ message: |
69
+ Trim trailing whitespaces
70
+ glob:
71
+ - '**/*.rb'
72
+ - '**/*.rbs'
73
+ - '**/*.md'
74
+ justification:
75
+ - Let the maintainers know if it is an autogenerated files.
76
+ pass:
77
+ - "Hello world"
78
+ - "Hello\nworld"
79
+ - "Hello\n\nworld"
80
+ fail:
81
+ - "Hello world "
82
+ - "Hello \nworld"
@@ -23,7 +23,7 @@ module RBS
23
23
  { string: string, location: location }.to_json(*a)
24
24
  end
25
25
 
26
- def concat(string:, location:)
26
+ def concat(string:, location:)
27
27
  @string.concat string
28
28
 
29
29
  if loc = @location
@@ -1,3 +1,4 @@
1
+ require "open3"
1
2
  require "optparse"
2
3
  require "shellwords"
3
4
 
@@ -383,6 +384,11 @@ Examples:
383
384
 
384
385
  $ rbs validate
385
386
  EOU
387
+
388
+ opts.on("--silent") do
389
+ require "stringio"
390
+ @stdout = StringIO.new
391
+ end
386
392
  end.parse!(args)
387
393
 
388
394
  loader = EnvironmentLoader.new()
@@ -488,7 +494,7 @@ Show paths to directories where the RBS files are loaded from.
488
494
  Examples:
489
495
 
490
496
  $ rbs paths
491
- $ tbs -r set paths
497
+ $ rbs -r set paths
492
498
  EOU
493
499
  end.parse!(args)
494
500
 
@@ -543,7 +549,7 @@ EOU
543
549
  Usage: rbs prototype runtime [options...] [pattern...]
544
550
 
545
551
  Generate RBS prototype based on runtime introspection.
546
- It loads Ruby code specified in [options] and generates RBS prototypes for classes matches to [pattern].
552
+ It loads Ruby code specified in [options] and generates RBS prototypes for classes matches to [pattern].
547
553
 
548
554
  Examples:
549
555
 
@@ -808,8 +814,10 @@ EOB
808
814
  'RBS_TEST_TARGET' => (targets.join(',') unless targets.empty?)
809
815
  }
810
816
 
811
- system(env_hash, *args)
812
- $?
817
+ out, err, status = Open3.capture3(env_hash, *args)
818
+ stdout.print(out)
819
+ stderr.print(err)
820
+ status
813
821
  end
814
822
  end
815
823
  end
@@ -2,7 +2,7 @@ module RBS
2
2
  class Constant
3
3
  attr_reader :name
4
4
  attr_reader :type
5
- attr_reader :declaration
5
+ attr_reader :entry
6
6
 
7
7
  def initialize(name:, type:, entry:)
8
8
  @name = name
@@ -47,6 +47,8 @@ module RBS
47
47
 
48
48
  head, *tail = split_name(name)
49
49
 
50
+ raise unless head
51
+
50
52
  head_constant = case
51
53
  when name.absolute?
52
54
  name_to_constant(TypeName.new(name: head, namespace: Namespace.root))
@@ -57,11 +59,13 @@ module RBS
57
59
  resolve_constant_reference_inherit(head, scopes: constant_scopes(context.first.to_type_name))
58
60
  end
59
61
 
60
- if head_constant
61
- tail.inject(head_constant) do |constant, name|
62
- resolve_constant_reference_inherit name,
63
- scopes: constant_scopes(constant.name),
64
- no_object: constant.name != BuiltinNames::Object.name
62
+ tail.inject(head_constant) do |constant, name|
63
+ if constant
64
+ resolve_constant_reference_inherit(
65
+ name,
66
+ scopes: constant_scopes(constant.name),
67
+ no_object: constant.name != BuiltinNames::Object.name
68
+ )
65
69
  end
66
70
  end
67
71
  end
@@ -150,9 +154,6 @@ module RBS
150
154
  when Environment::ModuleEntry
151
155
  constant_scopes0 BuiltinNames::Module.name, scopes: scopes
152
156
  constant_scopes_module name, scopes: scopes
153
-
154
- else
155
- raise "Unexpected declaration: #{name} (#{entry.class})"
156
157
  end
157
158
 
158
159
  scopes
@@ -40,7 +40,7 @@ module RBS
40
40
  if s = super_class
41
41
  yield s
42
42
  end
43
-
43
+
44
44
  self_types&.each(&block)
45
45
  included_modules&.each(&block)
46
46
  prepended_modules&.each(&block)
@@ -303,7 +303,7 @@ module RBS
303
303
  mod_ancestors = instance_ancestors(name, building_ancestors: building_ancestors)
304
304
  ancestors.unshift(*mod_ancestors.apply(arg_types, location: entry.primary.decl.location))
305
305
  end
306
- end
306
+ end
307
307
  end
308
308
 
309
309
  ancestors.unshift(self_ancestor)
@@ -316,7 +316,7 @@ module RBS
316
316
  mod_ancestors = instance_ancestors(name, building_ancestors: building_ancestors)
317
317
  ancestors.unshift(*mod_ancestors.apply(arg_types, location: entry.primary.decl.location))
318
318
  end
319
- end
319
+ end
320
320
  end
321
321
 
322
322
  building_ancestors.pop
@@ -814,8 +814,7 @@ module RBS
814
814
 
815
815
  methods.each do |name, method|
816
816
  method.method_types.each do |method_type|
817
- case method_type
818
- when MethodType
817
+ unless name == :initialize
819
818
  result = calculator.in_method_type(method_type: method_type, variables: param_names)
820
819
 
821
820
  validate_params_with type_params, result: result do |param|
@@ -941,8 +940,8 @@ module RBS
941
940
  Definition::Method::TypeDef.new(
942
941
  type: method_type,
943
942
  member: initialize_def.member,
944
- defined_in: nil,
945
- implemented_in: nil
943
+ defined_in: initialize_def.defined_in,
944
+ implemented_in: initialize_def.implemented_in
946
945
  )
947
946
  end,
948
947
  accessibility: :public,
@@ -13,7 +13,7 @@ module RBS
13
13
  def context
14
14
  @context ||= begin
15
15
  (outer + [decl]).each.with_object([Namespace.root]) do |decl, array|
16
- first = array.first or raise
16
+ first = array.first or raise
17
17
  array.unshift(first + decl.name.to_namespace)
18
18
  end
19
19
  end
@@ -258,6 +258,8 @@ module RBS
258
258
  outer: outer_,
259
259
  prefix: prefix_
260
260
  )
261
+ else
262
+ raise
261
263
  end
262
264
  end,
263
265
  location: decl.location,
@@ -288,6 +290,8 @@ module RBS
288
290
  outer: outer_,
289
291
  prefix: prefix_
290
292
  )
293
+ else
294
+ raise
291
295
  end
292
296
  end,
293
297
  location: decl.location,