rbs 3.0.2 → 3.0.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/CHANGELOG.md +14 -0
- data/Gemfile.lock +2 -2
- data/Rakefile +11 -1
- data/lib/rbs/collection/config/lockfile_generator.rb +6 -4
- data/lib/rbs/definition_builder/ancestor_builder.rb +31 -13
- data/lib/rbs/definition_builder.rb +23 -12
- data/lib/rbs/version.rb +1 -1
- data/sig/ancestor_builder.rbs +4 -0
- data/sig/definition.rbs +3 -2
- data/sig/definition_builder.rbs +4 -0
- 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: 7a5d2a9cd76c2802e303f61813f418c15a2fc131b23f1eb8e90a92f409efcf37
|
4
|
+
data.tar.gz: d008724c5628a0c21b153a6ae99dadf7604ee90ad4caa210e07bbad974f91894
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 4c903cc9f9b536281e0632aff0cae6d520856152bdf33b1d8fc34b2dd8e5caab93af6aaa1387eb7433b430d2d90dafcd5557c7aeba0b043d6ab340bc22d36dcb
|
7
|
+
data.tar.gz: 1913b79a1bb5b6510734aaca4aee8fa1759dae851486662ee5055040b8d70554b9466d061cc53c971ade8d76d75312486fe39cea5b1f4c7d3bfa333501fb56da
|
data/CHANGELOG.md
CHANGED
@@ -2,6 +2,20 @@
|
|
2
2
|
|
3
3
|
## master
|
4
4
|
|
5
|
+
## 3.0.3 (2023-03-07)
|
6
|
+
|
7
|
+
### Library changes
|
8
|
+
|
9
|
+
* Fix `DefinitionBuilder` ([\#1268](https://github.com/ruby/rbs/pull/1268))
|
10
|
+
|
11
|
+
#### rbs collection
|
12
|
+
|
13
|
+
* Skip dependencies not included in `Gemfile.lock` ([\#1266](https://github.com/ruby/rbs/pull/1266))
|
14
|
+
|
15
|
+
### Miscellaneous
|
16
|
+
|
17
|
+
* Skip RBS validation on Ruby CI ([\#1264](https://github.com/ruby/rbs/pull/1264), [\#1263](https://github.com/ruby/rbs/pull/1263))
|
18
|
+
|
5
19
|
## 3.0.2 (2023-03-01)
|
6
20
|
|
7
21
|
### Library changes
|
data/Gemfile.lock
CHANGED
data/Rakefile
CHANGED
@@ -59,7 +59,17 @@ task :validate => :compile do
|
|
59
59
|
sh "#{ruby} #{rbs} validate --silent"
|
60
60
|
|
61
61
|
libs = FileList["stdlib/*"].map {|path| File.basename(path).to_s }
|
62
|
-
|
62
|
+
|
63
|
+
# Skip RBS validation because Ruby CI runs without rubygems
|
64
|
+
case skip_rbs_validation = ENV["SKIP_RBS_VALIDATION"]
|
65
|
+
when nil
|
66
|
+
libs << "rbs"
|
67
|
+
when "true"
|
68
|
+
# Skip
|
69
|
+
else
|
70
|
+
STDERR.puts "🚨🚨🚨🚨 SKIP_RBS_VALIDATION is expected to be `true` or unset, given `#{skip_rbs_validation}` 🚨🚨🚨🚨"
|
71
|
+
libs << "rbs"
|
72
|
+
end
|
63
73
|
|
64
74
|
libs.each do |lib|
|
65
75
|
sh "#{ruby} #{rbs} -r #{lib} validate --silent"
|
@@ -75,8 +75,9 @@ module RBS
|
|
75
75
|
next
|
76
76
|
end
|
77
77
|
|
78
|
-
spec = gem_hash[dep.name]
|
79
|
-
|
78
|
+
if spec = gem_hash[dep.name]
|
79
|
+
assign_gem(name: dep.name, version: spec.version, ignored_gems: ignored_gems, src_data: nil)
|
80
|
+
end
|
80
81
|
end
|
81
82
|
|
82
83
|
lockfile.lockfile_path.write(YAML.dump(lockfile.to_lockfile))
|
@@ -131,8 +132,9 @@ module RBS
|
|
131
132
|
end
|
132
133
|
|
133
134
|
gem_hash[name].dependencies.each do |dep|
|
134
|
-
spec = gem_hash[dep.name]
|
135
|
-
|
135
|
+
if spec = gem_hash[dep.name]
|
136
|
+
assign_gem(name: dep.name, version: spec.version, src_data: nil, ignored_gems: ignored_gems)
|
137
|
+
end
|
136
138
|
end
|
137
139
|
end
|
138
140
|
|
@@ -432,8 +432,9 @@ module RBS
|
|
432
432
|
super_name = super_class.name
|
433
433
|
super_args = super_class.args
|
434
434
|
|
435
|
-
super_ancestors = instance_ancestors(super_name, building_ancestors: building_ancestors)
|
436
|
-
|
435
|
+
super_ancestors = instance_ancestors(super_name, building_ancestors: building_ancestors).apply(super_args, location: entry.primary.decl.location)
|
436
|
+
super_ancestors.map! {|ancestor| fill_ancestor_source(ancestor, name: super_name, source: :super) }
|
437
|
+
ancestors.unshift(*super_ancestors)
|
437
438
|
end
|
438
439
|
end
|
439
440
|
|
@@ -450,8 +451,9 @@ module RBS
|
|
450
451
|
included_modules.each do |mod|
|
451
452
|
name = mod.name
|
452
453
|
arg_types = mod.args
|
453
|
-
mod_ancestors = instance_ancestors(name, building_ancestors: building_ancestors)
|
454
|
-
|
454
|
+
mod_ancestors = instance_ancestors(name, building_ancestors: building_ancestors).apply(arg_types, location: entry.primary.decl.location)
|
455
|
+
mod_ancestors.map! {|ancestor| fill_ancestor_source(ancestor, name: name, source: mod.source) }
|
456
|
+
ancestors.unshift(*mod_ancestors)
|
455
457
|
end
|
456
458
|
end
|
457
459
|
|
@@ -461,8 +463,9 @@ module RBS
|
|
461
463
|
prepended_modules.each do |mod|
|
462
464
|
name = mod.name
|
463
465
|
arg_types = mod.args
|
464
|
-
mod_ancestors = instance_ancestors(name, building_ancestors: building_ancestors)
|
465
|
-
|
466
|
+
mod_ancestors = instance_ancestors(name, building_ancestors: building_ancestors).apply(arg_types, location: entry.primary.decl.location)
|
467
|
+
mod_ancestors.map! {|ancestor| fill_ancestor_source(ancestor, name: name, source: mod.source) }
|
468
|
+
ancestors.unshift(*mod_ancestors)
|
466
469
|
end
|
467
470
|
end
|
468
471
|
|
@@ -495,8 +498,9 @@ module RBS
|
|
495
498
|
super_name = super_class.name
|
496
499
|
super_args = super_class.args
|
497
500
|
|
498
|
-
super_ancestors = instance_ancestors(super_name, building_ancestors: building_ancestors)
|
499
|
-
|
501
|
+
super_ancestors = instance_ancestors(super_name, building_ancestors: building_ancestors).apply(super_args, location: entry.primary.decl.location)
|
502
|
+
super_ancestors.map! {|ancestor| fill_ancestor_source(ancestor, name: super_name, source: :super) }
|
503
|
+
ancestors.unshift(*super_ancestors)
|
500
504
|
|
501
505
|
when Definition::Ancestor::Singleton
|
502
506
|
super_name = super_class.name
|
@@ -509,8 +513,9 @@ module RBS
|
|
509
513
|
extended_modules.each do |mod|
|
510
514
|
name = mod.name
|
511
515
|
args = mod.args
|
512
|
-
mod_ancestors = instance_ancestors(name, building_ancestors: building_ancestors)
|
513
|
-
|
516
|
+
mod_ancestors = instance_ancestors(name, building_ancestors: building_ancestors).apply(args, location: entry.primary.decl.location)
|
517
|
+
mod_ancestors.map! {|ancestor| fill_ancestor_source(ancestor, name: name, source: mod.source) }
|
518
|
+
ancestors.unshift(*mod_ancestors)
|
514
519
|
end
|
515
520
|
|
516
521
|
ancestors.unshift(self_ancestor)
|
@@ -541,9 +546,9 @@ module RBS
|
|
541
546
|
|
542
547
|
included_interfaces = one_ancestors.included_interfaces or raise
|
543
548
|
included_interfaces.each do |a|
|
544
|
-
included_ancestors = interface_ancestors(a.name, building_ancestors: building_ancestors)
|
545
|
-
|
546
|
-
ancestors.unshift(*included_ancestors
|
549
|
+
included_ancestors = interface_ancestors(a.name, building_ancestors: building_ancestors).apply(a.args, location: entry.decl.location)
|
550
|
+
included_ancestors.map! {|ancestor| fill_ancestor_source(ancestor, name: a.name, source: a.source) }
|
551
|
+
ancestors.unshift(*included_ancestors)
|
547
552
|
end
|
548
553
|
|
549
554
|
ancestors.unshift(self_ancestor)
|
@@ -555,6 +560,19 @@ module RBS
|
|
555
560
|
ancestors: ancestors
|
556
561
|
)
|
557
562
|
end
|
563
|
+
|
564
|
+
def fill_ancestor_source(ancestor, name:, source:, &block)
|
565
|
+
case ancestor
|
566
|
+
when Definition::Ancestor::Instance
|
567
|
+
if ancestor.name == name && !ancestor.source
|
568
|
+
Definition::Ancestor::Instance.new(name: ancestor.name, args: ancestor.args, source: source)
|
569
|
+
else
|
570
|
+
ancestor
|
571
|
+
end
|
572
|
+
else
|
573
|
+
ancestor
|
574
|
+
end
|
575
|
+
end
|
558
576
|
end
|
559
577
|
end
|
560
578
|
end
|
@@ -31,9 +31,10 @@ module RBS
|
|
31
31
|
end
|
32
32
|
|
33
33
|
def define_interface(definition, type_name, subst)
|
34
|
-
included_interfaces = ancestor_builder.
|
35
|
-
|
34
|
+
included_interfaces = ancestor_builder.interface_ancestors(type_name).ancestors #: Array[Definition::Ancestor::Instance]
|
35
|
+
included_interfaces = included_interfaces.reject {|ancestor| ancestor.source == nil }
|
36
36
|
|
37
|
+
interface_methods = interface_methods(included_interfaces)
|
37
38
|
methods = method_builder.build_interface(type_name)
|
38
39
|
|
39
40
|
import_methods(definition, type_name, methods, interface_methods, subst)
|
@@ -55,7 +56,6 @@ module RBS
|
|
55
56
|
Definition.new(type_name: type_name, entry: entry, self_type: self_type, ancestors: ancestors).tap do |definition|
|
56
57
|
methods = method_builder.build_interface(type_name)
|
57
58
|
one_ancestors = ancestor_builder.one_interface_ancestors(type_name)
|
58
|
-
|
59
59
|
validate_type_params(definition, methods: methods, ancestors: one_ancestors)
|
60
60
|
|
61
61
|
define_interface(definition, type_name, subst)
|
@@ -94,7 +94,12 @@ module RBS
|
|
94
94
|
define_instance(definition, mod.name, subst + tapp_subst(mod.name, mod.args))
|
95
95
|
end
|
96
96
|
|
97
|
-
|
97
|
+
all_interfaces = one_ancestors.each_included_interface.flat_map do |interface|
|
98
|
+
other_interfaces = ancestor_builder.interface_ancestors(interface.name).ancestors #: Array[Definition::Ancestor::Instance]
|
99
|
+
other_interfaces = other_interfaces.select {|ancestor| ancestor.source }
|
100
|
+
[interface, *other_interfaces]
|
101
|
+
end
|
102
|
+
interface_methods = interface_methods(all_interfaces)
|
98
103
|
import_methods(definition, type_name, methods, interface_methods, subst)
|
99
104
|
|
100
105
|
one_ancestors.each_prepended_module do |mod|
|
@@ -219,6 +224,7 @@ module RBS
|
|
219
224
|
|
220
225
|
Definition.new(type_name: type_name, entry: entry, self_type: self_type, ancestors: ancestors).tap do |definition|
|
221
226
|
one_ancestors = ancestor_builder.one_singleton_ancestors(type_name)
|
227
|
+
methods = method_builder.build_singleton(type_name)
|
222
228
|
|
223
229
|
if super_class = one_ancestors.super_class
|
224
230
|
case super_class
|
@@ -233,8 +239,13 @@ module RBS
|
|
233
239
|
definition.class_variables.merge!(defn.class_variables)
|
234
240
|
end
|
235
241
|
|
236
|
-
|
237
|
-
|
242
|
+
all_interfaces = one_ancestors.each_extended_interface.flat_map do |interface|
|
243
|
+
other_interfaces = ancestor_builder.interface_ancestors(interface.name).ancestors #: Array[Definition::Ancestor::Instance]
|
244
|
+
other_interfaces = other_interfaces.select {|ancestor| ancestor.source }
|
245
|
+
[interface, *other_interfaces]
|
246
|
+
end
|
247
|
+
interface_methods = interface_methods(all_interfaces)
|
248
|
+
import_methods(definition, type_name, methods, interface_methods, Substitution.new)
|
238
249
|
|
239
250
|
one_ancestors.each_extended_module do |mod|
|
240
251
|
mod.args.each do |arg|
|
@@ -279,7 +290,7 @@ module RBS
|
|
279
290
|
|
280
291
|
def build_singleton(type_name)
|
281
292
|
type_name = env.normalize_module_name(type_name)
|
282
|
-
|
293
|
+
|
283
294
|
try_cache type_name, cache: singleton_cache do
|
284
295
|
entry = env.class_decls[type_name] or raise "Unknown name for build_singleton: #{type_name}"
|
285
296
|
ensure_namespace!(type_name.namespace, location: entry.decls[0].decl.location)
|
@@ -683,8 +694,8 @@ module RBS
|
|
683
694
|
Definition::Method::TypeDef.new(
|
684
695
|
type: method_type,
|
685
696
|
member: original,
|
686
|
-
defined_in:
|
687
|
-
implemented_in:
|
697
|
+
defined_in: defined_in,
|
698
|
+
implemented_in: implemented_in
|
688
699
|
)
|
689
700
|
],
|
690
701
|
accessibility: method.accessibility,
|
@@ -713,7 +724,7 @@ module RBS
|
|
713
724
|
method_definition = Definition::Method.new(
|
714
725
|
super_method: super_method,
|
715
726
|
defs: existing_method.defs.map do |defn|
|
716
|
-
defn.update(implemented_in:
|
727
|
+
defn.update(implemented_in: implemented_in)
|
717
728
|
end,
|
718
729
|
accessibility: existing_method.accessibility,
|
719
730
|
alias_of: existing_method.alias_of
|
@@ -725,8 +736,8 @@ module RBS
|
|
725
736
|
type_def = Definition::Method::TypeDef.new(
|
726
737
|
type: subst.empty? ? overload.method_type : overload.method_type.sub(subst),
|
727
738
|
member: overloading_def,
|
728
|
-
defined_in:
|
729
|
-
implemented_in:
|
739
|
+
defined_in: defined_in,
|
740
|
+
implemented_in: implemented_in
|
730
741
|
)
|
731
742
|
|
732
743
|
method_definition.defs.unshift(type_def)
|
data/lib/rbs/version.rb
CHANGED
data/sig/ancestor_builder.rbs
CHANGED
@@ -154,6 +154,10 @@ module RBS
|
|
154
154
|
prepended_modules: Array[Definition::Ancestor::Instance]?,
|
155
155
|
extended_modules: Array[Definition::Ancestor::Instance]?,
|
156
156
|
extended_interfaces: Array[Definition::Ancestor::Instance]?) -> void
|
157
|
+
|
158
|
+
# Fill `#source` of instance ancestor if `ancestor.name == name` and its `source` is `nil`
|
159
|
+
#
|
160
|
+
def fill_ancestor_source: (Definition::Ancestor::t, name: TypeName, source: Definition::Ancestor::Instance::source) -> Definition::Ancestor::t
|
157
161
|
end
|
158
162
|
end
|
159
163
|
end
|
data/sig/definition.rbs
CHANGED
@@ -83,8 +83,9 @@ module RBS
|
|
83
83
|
type t = Instance | Singleton
|
84
84
|
|
85
85
|
class Instance
|
86
|
-
type source = :super
|
87
|
-
|
|
86
|
+
type source = :super # Inheritance
|
87
|
+
| nil # Itself
|
88
|
+
| AST::Members::Include | AST::Members::Extend | AST::Members::Prepend # AST
|
88
89
|
| AST::Declarations::Module::Self
|
89
90
|
|
90
91
|
attr_reader name: TypeName
|
data/sig/definition_builder.rbs
CHANGED
@@ -142,6 +142,10 @@ module RBS
|
|
142
142
|
#
|
143
143
|
def define_instance: (Definition definition, TypeName type_name, Substitution subst) -> void
|
144
144
|
|
145
|
+
# Updates `definition` with methods defined in an interface `type_name`
|
146
|
+
#
|
147
|
+
# It processes includes recursively
|
148
|
+
#
|
145
149
|
def define_interface: (Definition definition, TypeName type_name, Substitution subst) -> void
|
146
150
|
|
147
151
|
# Returns a substitution that corresponds to type application
|
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: 3.0.
|
4
|
+
version: 3.0.3
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Soutaro Matsumoto
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2023-03-
|
11
|
+
date: 2023-03-07 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.
|