rbs 0.6.0 → 0.7.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +7 -0
- data/lib/rbs/constant_table.rb +1 -1
- data/lib/rbs/definition_builder.rb +250 -95
- data/lib/rbs/environment.rb +1 -1
- data/lib/rbs/errors.rb +25 -0
- data/lib/rbs/parser.y +1 -1
- data/lib/rbs/prototype/rb.rb +1 -1
- data/lib/rbs/substitution.rb +6 -2
- data/lib/rbs/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: d175f17e9f1226e0cb0d37c2167b3b52b0e736661d1406937922194c68adfd54
|
4
|
+
data.tar.gz: 204d38937da751f3ea15dfd64370e379689e54f264b63be54e6c4843c4827579
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 242ffa432db2a94a59636be87e261411c0bf465ac170b6f5b52955cb671d2c70e6eaed7dc74b489868117fcaa360df33c16ed6e2e472edd96663491c1211d793
|
7
|
+
data.tar.gz: 6ccb639e3a73a7e4794f906e9e125dd173d0406198a11511592e3c3492126c31a5ff1798010087fb19d4eb053ba46140e42f869b913ae3b7aaee20303ef3f92c
|
data/CHANGELOG.md
CHANGED
@@ -2,6 +2,13 @@
|
|
2
2
|
|
3
3
|
## master
|
4
4
|
|
5
|
+
## 0.7.0 (2020-07-20)
|
6
|
+
|
7
|
+
* Add `DefinitionBuilder#one_instance_ancestors` and `DefinitionBuilder#one_singleton_ancestors` [#341](https://github.com/ruby/rbs/pull/341)
|
8
|
+
* Bug fix in ConstantTable [#340](https://github.com/ruby/rbs/pull/340)
|
9
|
+
* Make `rbs validate` faster [#338](https://github.com/ruby/rbs/pull/338)
|
10
|
+
* Dedup methods generated by `rbs prototype rb` [#334](https://github.com/ruby/rbs/pull/334)
|
11
|
+
|
5
12
|
## 0.6.0 (2020-07-12)
|
6
13
|
|
7
14
|
* Signature update for `Logger`.
|
data/lib/rbs/constant_table.rb
CHANGED
@@ -13,6 +13,77 @@ module RBS
|
|
13
13
|
attr_reader :instance_ancestors_cache
|
14
14
|
attr_reader :singleton_ancestor_cache
|
15
15
|
|
16
|
+
attr_reader :one_instance_ancestors_cache
|
17
|
+
attr_reader :one_singleton_ancestors_cache
|
18
|
+
|
19
|
+
class OneAncestors
|
20
|
+
attr_reader :type_name
|
21
|
+
attr_reader :params
|
22
|
+
attr_reader :super_class
|
23
|
+
attr_reader :self_types
|
24
|
+
attr_reader :included_modules
|
25
|
+
attr_reader :prepended_modules
|
26
|
+
attr_reader :extended_modules
|
27
|
+
|
28
|
+
def initialize(type_name:, params:, super_class:, self_types:, included_modules:, prepended_modules:, extended_modules:)
|
29
|
+
@type_name = type_name
|
30
|
+
@params = params
|
31
|
+
@super_class = super_class
|
32
|
+
@self_types = self_types
|
33
|
+
@included_modules = included_modules
|
34
|
+
@prepended_modules = prepended_modules
|
35
|
+
@extended_modules = extended_modules
|
36
|
+
end
|
37
|
+
|
38
|
+
def each_ancestor(&block)
|
39
|
+
if block_given?
|
40
|
+
yield super_class if super_class
|
41
|
+
self_types&.each(&block)
|
42
|
+
included_modules&.each(&block)
|
43
|
+
prepended_modules&.each(&block)
|
44
|
+
extended_modules&.each(&block)
|
45
|
+
else
|
46
|
+
enum_for :each_ancestor
|
47
|
+
end
|
48
|
+
end
|
49
|
+
|
50
|
+
def self.class_instance(type_name:, params:, super_class:)
|
51
|
+
new(
|
52
|
+
type_name: type_name,
|
53
|
+
params: params,
|
54
|
+
super_class: super_class,
|
55
|
+
self_types: nil,
|
56
|
+
included_modules: [],
|
57
|
+
prepended_modules: [],
|
58
|
+
extended_modules: nil
|
59
|
+
)
|
60
|
+
end
|
61
|
+
|
62
|
+
def self.singleton(type_name:, super_class:)
|
63
|
+
new(
|
64
|
+
type_name: type_name,
|
65
|
+
params: nil,
|
66
|
+
super_class: super_class,
|
67
|
+
self_types: nil,
|
68
|
+
included_modules: nil,
|
69
|
+
prepended_modules: nil,
|
70
|
+
extended_modules: []
|
71
|
+
)
|
72
|
+
end
|
73
|
+
|
74
|
+
def self.module_instance(type_name:, params:)
|
75
|
+
new(
|
76
|
+
type_name: type_name,
|
77
|
+
params: params,
|
78
|
+
self_types: [],
|
79
|
+
included_modules: [],
|
80
|
+
prepended_modules: [],
|
81
|
+
super_class: nil,
|
82
|
+
extended_modules: nil
|
83
|
+
)
|
84
|
+
end
|
85
|
+
end
|
86
|
+
|
16
87
|
def initialize(env:)
|
17
88
|
@env = env
|
18
89
|
@type_name_resolver = TypeNameResolver.from_env(env)
|
@@ -26,6 +97,9 @@ module RBS
|
|
26
97
|
|
27
98
|
@instance_ancestors_cache = {}
|
28
99
|
@singleton_ancestor_cache = {}
|
100
|
+
|
101
|
+
@one_instance_ancestors_cache = {}
|
102
|
+
@one_singleton_ancestors_cache = {}
|
29
103
|
end
|
30
104
|
|
31
105
|
def validate_super_class!(type_name, entry)
|
@@ -45,30 +119,19 @@ module RBS
|
|
45
119
|
raise SuperclassMismatchError.new(name: type_name, super_classes: super_types, entry: entry)
|
46
120
|
end
|
47
121
|
|
48
|
-
def
|
49
|
-
as =
|
122
|
+
def one_instance_ancestors(type_name)
|
123
|
+
as = one_instance_ancestors_cache[type_name] and return as
|
50
124
|
|
51
|
-
entry = env.class_decls[type_name] or raise "Unknown name for
|
125
|
+
entry = env.class_decls[type_name] or raise "Unknown name for one_instance_ancestors: #{type_name}"
|
52
126
|
params = entry.type_params.each.map(&:name)
|
53
|
-
args = Types::Variable.build(params)
|
54
|
-
self_ancestor = Definition::Ancestor::Instance.new(name: type_name, args: args)
|
55
|
-
|
56
|
-
RecursiveAncestorError.check!(self_ancestor,
|
57
|
-
ancestors: building_ancestors,
|
58
|
-
location: entry.primary.decl.location)
|
59
|
-
building_ancestors.push self_ancestor
|
60
|
-
|
61
|
-
ancestors = []
|
62
127
|
|
63
128
|
case entry
|
64
129
|
when Environment::ClassEntry
|
65
130
|
validate_super_class!(type_name, entry)
|
131
|
+
primary = entry.primary
|
132
|
+
super_class = primary.decl.super_class
|
66
133
|
|
67
|
-
|
68
|
-
if self_ancestor.name != BuiltinNames::BasicObject.name
|
69
|
-
primary = entry.primary
|
70
|
-
super_class = primary.decl.super_class
|
71
|
-
|
134
|
+
if type_name != BuiltinNames::BasicObject.name
|
72
135
|
if super_class
|
73
136
|
super_name = super_class.name
|
74
137
|
super_args = super_class.args
|
@@ -79,46 +142,49 @@ module RBS
|
|
79
142
|
|
80
143
|
NoSuperclassFoundError.check!(super_name, env: env, location: primary.decl.location)
|
81
144
|
|
82
|
-
|
83
|
-
|
145
|
+
ancestors = OneAncestors.class_instance(
|
146
|
+
type_name: type_name,
|
147
|
+
params: params,
|
148
|
+
super_class: Definition::Ancestor::Instance.new(name: super_name, args: super_args)
|
149
|
+
)
|
150
|
+
else
|
151
|
+
ancestors = OneAncestors.class_instance(
|
152
|
+
type_name: type_name,
|
153
|
+
params: params,
|
154
|
+
super_class: nil
|
155
|
+
)
|
84
156
|
end
|
85
|
-
|
86
|
-
build_ancestors_mixin_self(self_ancestor, entry, ancestors: ancestors, building_ancestors: building_ancestors)
|
87
|
-
|
88
157
|
when Environment::ModuleEntry
|
89
|
-
|
158
|
+
ancestors = OneAncestors.module_instance(type_name: type_name, params: params)
|
90
159
|
|
160
|
+
entry.self_types.each do |module_self|
|
161
|
+
NoSelfTypeFoundError.check!(module_self, env: env)
|
162
|
+
ancestors.self_types.push Definition::Ancestor::Instance.new(name: module_self.name, args: module_self.args)
|
163
|
+
end
|
164
|
+
else
|
165
|
+
raise "Unexpected entry for: #{type_name}"
|
91
166
|
end
|
92
167
|
|
93
|
-
|
168
|
+
mixin_ancestors(entry,
|
169
|
+
included_modules: ancestors.included_modules,
|
170
|
+
prepended_modules: ancestors.prepended_modules,
|
171
|
+
extended_modules: nil)
|
94
172
|
|
95
|
-
|
96
|
-
type_name: type_name,
|
97
|
-
params: params,
|
98
|
-
ancestors: ancestors
|
99
|
-
)
|
173
|
+
one_instance_ancestors_cache[type_name] = ancestors
|
100
174
|
end
|
101
175
|
|
102
|
-
def
|
103
|
-
as =
|
104
|
-
|
105
|
-
entry = env.class_decls[type_name] or raise "Unknown name for singleton_ancestors: #{type_name}"
|
106
|
-
self_ancestor = Definition::Ancestor::Singleton.new(name: type_name)
|
107
|
-
|
108
|
-
RecursiveAncestorError.check!(self_ancestor,
|
109
|
-
ancestors: building_ancestors,
|
110
|
-
location: entry.primary.decl.location)
|
111
|
-
building_ancestors.push self_ancestor
|
176
|
+
def one_singleton_ancestors(type_name)
|
177
|
+
as = one_singleton_ancestors_cache[type_name] and return as
|
112
178
|
|
113
|
-
|
179
|
+
entry = env.class_decls[type_name] or raise "Unknown name for one_singleton_ancestors: #{type_name}"
|
114
180
|
|
115
181
|
case entry
|
116
182
|
when Environment::ClassEntry
|
117
|
-
|
118
|
-
|
119
|
-
|
120
|
-
super_class = primary.decl.super_class
|
183
|
+
validate_super_class!(type_name, entry)
|
184
|
+
primary = entry.primary
|
185
|
+
super_class = primary.decl.super_class
|
121
186
|
|
187
|
+
if type_name != BuiltinNames::BasicObject.name
|
122
188
|
if super_class
|
123
189
|
super_name = super_class.name
|
124
190
|
else
|
@@ -127,47 +193,35 @@ module RBS
|
|
127
193
|
|
128
194
|
NoSuperclassFoundError.check!(super_name, env: env, location: primary.decl.location)
|
129
195
|
|
130
|
-
|
131
|
-
|
196
|
+
ancestors = OneAncestors.singleton(
|
197
|
+
type_name: type_name,
|
198
|
+
super_class: Definition::Ancestor::Singleton.new(name: super_name)
|
199
|
+
)
|
132
200
|
else
|
133
|
-
|
134
|
-
|
201
|
+
ancestors = OneAncestors.singleton(
|
202
|
+
type_name: type_name,
|
203
|
+
super_class: Definition::Ancestor::Instance.new(name: BuiltinNames::Class.name, args: [])
|
204
|
+
)
|
135
205
|
end
|
136
|
-
|
137
206
|
when Environment::ModuleEntry
|
138
|
-
|
139
|
-
|
140
|
-
|
141
|
-
|
142
|
-
# Extend comes next
|
143
|
-
entry.decls.each do |d|
|
144
|
-
decl = d.decl
|
145
|
-
|
146
|
-
decl.each_mixin do |member|
|
147
|
-
case member
|
148
|
-
when AST::Members::Extend
|
149
|
-
if member.name.class?
|
150
|
-
NoMixinFoundError.check!(member.name, env: env, member: member)
|
207
|
+
ancestors = OneAncestors.singleton(
|
208
|
+
type_name: type_name,
|
209
|
+
super_class: Definition::Ancestor::Instance.new(name: BuiltinNames::Module.name, args: [])
|
210
|
+
)
|
151
211
|
|
152
|
-
|
153
|
-
|
154
|
-
end
|
155
|
-
end
|
156
|
-
end
|
212
|
+
else
|
213
|
+
raise "Unexpected entry for: #{type_name}"
|
157
214
|
end
|
158
215
|
|
159
|
-
|
216
|
+
mixin_ancestors(entry,
|
217
|
+
included_modules: nil,
|
218
|
+
prepended_modules: nil,
|
219
|
+
extended_modules: ancestors.extended_modules)
|
160
220
|
|
161
|
-
|
162
|
-
|
163
|
-
singleton_ancestor_cache[type_name] = Definition::SingletonAncestors.new(
|
164
|
-
type_name: type_name,
|
165
|
-
ancestors: ancestors
|
166
|
-
)
|
221
|
+
one_singleton_ancestors_cache[type_name] = ancestors
|
167
222
|
end
|
168
223
|
|
169
|
-
def
|
170
|
-
# Include comes next
|
224
|
+
def mixin_ancestors(entry, included_modules:, extended_modules:, prepended_modules:)
|
171
225
|
entry.decls.each do |d|
|
172
226
|
decl = d.decl
|
173
227
|
|
@@ -179,42 +233,143 @@ module RBS
|
|
179
233
|
decl.each_mixin do |member|
|
180
234
|
case member
|
181
235
|
when AST::Members::Include
|
182
|
-
if
|
236
|
+
if included_modules
|
237
|
+
NoMixinFoundError.check!(member.name, env: env, member: member)
|
238
|
+
|
239
|
+
module_name = member.name
|
240
|
+
module_args = member.args.map {|type| type.sub(align_params) }
|
241
|
+
|
242
|
+
included_modules << Definition::Ancestor::Instance.new(name: module_name, args: module_args)
|
243
|
+
end
|
244
|
+
|
245
|
+
when AST::Members::Prepend
|
246
|
+
if prepended_modules
|
183
247
|
NoMixinFoundError.check!(member.name, env: env, member: member)
|
184
248
|
|
185
249
|
module_name = member.name
|
186
250
|
module_args = member.args.map {|type| type.sub(align_params) }
|
187
251
|
|
188
|
-
|
189
|
-
|
252
|
+
prepended_modules << Definition::Ancestor::Instance.new(name: module_name, args: module_args)
|
253
|
+
end
|
254
|
+
|
255
|
+
when AST::Members::Extend
|
256
|
+
if extended_modules
|
257
|
+
NoMixinFoundError.check!(member.name, env: env, member: member)
|
258
|
+
|
259
|
+
module_name = member.name
|
260
|
+
module_args = member.args
|
261
|
+
|
262
|
+
extended_modules << Definition::Ancestor::Instance.new(name: module_name, args: module_args)
|
190
263
|
end
|
191
264
|
end
|
192
265
|
end
|
193
266
|
end
|
267
|
+
end
|
268
|
+
|
269
|
+
def instance_ancestors(type_name, building_ancestors: [])
|
270
|
+
as = instance_ancestors_cache[type_name] and return as
|
271
|
+
|
272
|
+
entry = env.class_decls[type_name] or raise "Unknown name for instance_ancestors: #{type_name}"
|
273
|
+
params = entry.type_params.each.map(&:name)
|
274
|
+
args = Types::Variable.build(params)
|
275
|
+
self_ancestor = Definition::Ancestor::Instance.new(name: type_name, args: args)
|
276
|
+
|
277
|
+
RecursiveAncestorError.check!(self_ancestor,
|
278
|
+
ancestors: building_ancestors,
|
279
|
+
location: entry.primary.decl.location)
|
280
|
+
building_ancestors.push self_ancestor
|
281
|
+
|
282
|
+
one_ancestors = one_instance_ancestors(type_name)
|
283
|
+
|
284
|
+
ancestors = []
|
285
|
+
|
286
|
+
case entry
|
287
|
+
when Environment::ClassEntry
|
288
|
+
if one_ancestors.super_class
|
289
|
+
super_name = one_ancestors.super_class.name
|
290
|
+
super_args = one_ancestors.super_class.args
|
291
|
+
|
292
|
+
super_ancestors = instance_ancestors(super_name, building_ancestors: building_ancestors)
|
293
|
+
ancestors.unshift(*super_ancestors.apply(super_args, location: entry.primary.decl.location))
|
294
|
+
end
|
295
|
+
end
|
296
|
+
|
297
|
+
one_ancestors.included_modules.each do |mod|
|
298
|
+
if mod.name.class?
|
299
|
+
name = mod.name
|
300
|
+
args = mod.args
|
301
|
+
mod_ancestors = instance_ancestors(name, building_ancestors: building_ancestors)
|
302
|
+
ancestors.unshift(*mod_ancestors.apply(args, location: entry.primary.decl.location))
|
303
|
+
end
|
304
|
+
end
|
194
305
|
|
195
|
-
# Self
|
196
306
|
ancestors.unshift(self_ancestor)
|
197
307
|
|
198
|
-
|
199
|
-
|
200
|
-
|
308
|
+
one_ancestors.prepended_modules.each do |mod|
|
309
|
+
if mod.name.class?
|
310
|
+
name = mod.name
|
311
|
+
args = mod.args
|
312
|
+
mod_ancestors = instance_ancestors(name, building_ancestors: building_ancestors)
|
313
|
+
ancestors.unshift(*mod_ancestors.apply(args, location: entry.primary.decl.location))
|
314
|
+
end
|
315
|
+
end
|
201
316
|
|
202
|
-
|
203
|
-
Types::Variable.build(entry.type_params.each.map(&:name)))
|
317
|
+
building_ancestors.pop
|
204
318
|
|
205
|
-
|
206
|
-
|
207
|
-
|
208
|
-
|
319
|
+
instance_ancestors_cache[type_name] = Definition::InstanceAncestors.new(
|
320
|
+
type_name: type_name,
|
321
|
+
params: params,
|
322
|
+
ancestors: ancestors
|
323
|
+
)
|
324
|
+
end
|
209
325
|
|
210
|
-
|
211
|
-
|
326
|
+
def singleton_ancestors(type_name, building_ancestors: [])
|
327
|
+
as = singleton_ancestor_cache[type_name] and return as
|
212
328
|
|
213
|
-
|
214
|
-
|
215
|
-
|
329
|
+
entry = env.class_decls[type_name] or raise "Unknown name for singleton_ancestors: #{type_name}"
|
330
|
+
self_ancestor = Definition::Ancestor::Singleton.new(name: type_name)
|
331
|
+
|
332
|
+
RecursiveAncestorError.check!(self_ancestor,
|
333
|
+
ancestors: building_ancestors,
|
334
|
+
location: entry.primary.decl.location)
|
335
|
+
building_ancestors.push self_ancestor
|
336
|
+
|
337
|
+
one_ancestors = one_singleton_ancestors(type_name)
|
338
|
+
|
339
|
+
ancestors = []
|
340
|
+
|
341
|
+
case one_ancestors.super_class
|
342
|
+
when Definition::Ancestor::Instance
|
343
|
+
super_name = one_ancestors.super_class.name
|
344
|
+
super_args = one_ancestors.super_class.args
|
345
|
+
|
346
|
+
super_ancestors = instance_ancestors(super_name, building_ancestors: building_ancestors)
|
347
|
+
ancestors.unshift(*super_ancestors.apply(super_args, location: entry.primary.decl.location))
|
348
|
+
|
349
|
+
when Definition::Ancestor::Singleton
|
350
|
+
super_name = one_ancestors.super_class.name
|
351
|
+
|
352
|
+
super_ancestors = singleton_ancestors(super_name, building_ancestors: [])
|
353
|
+
ancestors.unshift(*super_ancestors.ancestors)
|
354
|
+
end
|
355
|
+
|
356
|
+
one_ancestors.extended_modules.each do |mod|
|
357
|
+
if mod.name.class?
|
358
|
+
name = mod.name
|
359
|
+
args = mod.args
|
360
|
+
mod_ancestors = instance_ancestors(name, building_ancestors: building_ancestors)
|
361
|
+
ancestors.unshift(*mod_ancestors.apply(args, location: entry.primary.decl.location))
|
216
362
|
end
|
217
363
|
end
|
364
|
+
|
365
|
+
ancestors.unshift(self_ancestor)
|
366
|
+
|
367
|
+
building_ancestors.pop
|
368
|
+
|
369
|
+
singleton_ancestor_cache[type_name] = Definition::SingletonAncestors.new(
|
370
|
+
type_name: type_name,
|
371
|
+
ancestors: ancestors
|
372
|
+
)
|
218
373
|
end
|
219
374
|
|
220
375
|
def each_member_with_accessibility(members, accessibility: :public)
|
@@ -838,7 +993,7 @@ module RBS
|
|
838
993
|
methods[name] = Definition::Method.new(
|
839
994
|
super_method: super_method,
|
840
995
|
accessibility: method.accessibility,
|
841
|
-
defs: method.defs.map {|defn| defn.update(type: defn.type.sub(sub)) }
|
996
|
+
defs: sub.mapping.empty? ? method.defs : method.defs.map {|defn| defn.update(type: defn.type.sub(sub)) }
|
842
997
|
)
|
843
998
|
end
|
844
999
|
|
data/lib/rbs/environment.rb
CHANGED
@@ -126,7 +126,7 @@ module RBS
|
|
126
126
|
|
127
127
|
def cache_name(cache, name:, decl:, outer:)
|
128
128
|
if cache.key?(name)
|
129
|
-
raise DuplicatedDeclarationError.new(name, decl, cache[name])
|
129
|
+
raise DuplicatedDeclarationError.new(name, decl, cache[name].decl)
|
130
130
|
end
|
131
131
|
|
132
132
|
cache[name] = SingleEntry.new(name: name, decl: decl, outer: outer)
|
data/lib/rbs/errors.rb
CHANGED
@@ -141,6 +141,31 @@ module RBS
|
|
141
141
|
end
|
142
142
|
end
|
143
143
|
|
144
|
+
class NoSelfTypeFoundError < StandardError
|
145
|
+
attr_reader :type_name
|
146
|
+
attr_reader :location
|
147
|
+
|
148
|
+
def initialize(type_name:, location:)
|
149
|
+
@type_name = type_name
|
150
|
+
@location = location
|
151
|
+
|
152
|
+
super "#{Location.to_string location}: Could not find self type: #{type_name}"
|
153
|
+
end
|
154
|
+
|
155
|
+
def self.check!(self_type, env:)
|
156
|
+
type_name = self_type.name
|
157
|
+
|
158
|
+
dic = case
|
159
|
+
when type_name.class?
|
160
|
+
env.class_decls
|
161
|
+
when type_name.interface?
|
162
|
+
env.interface_decls
|
163
|
+
end
|
164
|
+
|
165
|
+
dic.key?(type_name) or raise new(type_name: type_name, location: self_type.location)
|
166
|
+
end
|
167
|
+
end
|
168
|
+
|
144
169
|
class NoMixinFoundError < StandardError
|
145
170
|
attr_reader :type_name
|
146
171
|
attr_reader :member
|
data/lib/rbs/parser.y
CHANGED
@@ -520,7 +520,7 @@ rule
|
|
520
520
|
|
521
521
|
method_name:
|
522
522
|
tOPERATOR
|
523
|
-
| kAMP | kHAT | kSTAR | kLT | kEXCLAMATION | kSTAR2 | kBAR
|
523
|
+
| kAMP | kHAT | kSTAR | kLT | kEXCLAMATION | kSTAR2 | kBAR
|
524
524
|
| method_name0
|
525
525
|
| method_name0 kQUESTION {
|
526
526
|
unless val[0].location.pred?(val[1].location)
|
data/lib/rbs/prototype/rb.rb
CHANGED
data/lib/rbs/substitution.rb
CHANGED
@@ -11,7 +11,7 @@ module RBS
|
|
11
11
|
mapping[from] = to
|
12
12
|
end
|
13
13
|
|
14
|
-
def self.build(variables, types, instance_type:
|
14
|
+
def self.build(variables, types, instance_type: nil, &block)
|
15
15
|
unless variables.size == types.size
|
16
16
|
raise "Broken substitution: variables=#{variables}, types=#{types}"
|
17
17
|
end
|
@@ -33,7 +33,11 @@ module RBS
|
|
33
33
|
when Types::Variable
|
34
34
|
mapping[ty.name] || ty
|
35
35
|
when Types::Bases::Instance
|
36
|
-
instance_type
|
36
|
+
if instance_type
|
37
|
+
instance_type
|
38
|
+
else
|
39
|
+
ty
|
40
|
+
end
|
37
41
|
else
|
38
42
|
ty
|
39
43
|
end
|
data/lib/rbs/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: rbs
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.7.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Soutaro Matsumoto
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2020-07-
|
11
|
+
date: 2020-07-20 00:00:00.000000000 Z
|
12
12
|
dependencies: []
|
13
13
|
description: RBS is the language for type signatures for Ruby and standard library
|
14
14
|
definitions.
|