rbs 1.8.0 → 1.8.1
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 +7 -0
- data/lib/rbs/collection/sources/git.rb +9 -7
- data/lib/rbs/definition_builder.rb +29 -0
- data/lib/rbs/validator.rb +6 -10
- data/lib/rbs/version.rb +1 -1
- data/sig/collection/collections.rbs +2 -2
- data/sig/definition_builder.rbs +7 -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: df1527cdbc750871d430d1c69bd4c9188b8814af7f3163d62adc5f9c1297e0dc
|
4
|
+
data.tar.gz: 3d0cc66c78d043e5fd98b86b342a7e8944c1cee8bf31f8f876530caba4cd9bc9
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 5c7f150ac87495a3ef064b5b499a5ef72c13eeb23985b84def107c111c6973a02ce6c3984bf22d1389882adf6d02f70fc82773d78383dd3992a2d7dbe58a7e59
|
7
|
+
data.tar.gz: f99bd7edbf1b4cf1cb5f018538345fe8ea50653ad6fa908aa3cd98c46d45b095aabb0cc2314cfae064997c0db2c6a31c6f9ab4fda1b15d2890a6b9be8dc8244a
|
data/CHANGELOG.md
CHANGED
@@ -2,6 +2,13 @@
|
|
2
2
|
|
3
3
|
## master
|
4
4
|
|
5
|
+
## 1.8.1 (2021-12-13)
|
6
|
+
|
7
|
+
### Library changes
|
8
|
+
|
9
|
+
* Validate `extend` arguments ([\#840](https://github.com/ruby/rbs/pull/840))
|
10
|
+
* Allow a relative path as git remote in collection ([\#839](https://github.com/ruby/rbs/pull/839))
|
11
|
+
|
5
12
|
## 1.8.0 (2021-12-02)
|
6
13
|
|
7
14
|
RBS 1.8.0 ships with a language feature enchancement, _generic type alias_.
|
@@ -104,9 +104,9 @@ module RBS
|
|
104
104
|
else
|
105
105
|
begin
|
106
106
|
# git v2.27.0 or greater
|
107
|
-
git 'clone', '--filter=blob:none', remote, git_dir.to_s
|
107
|
+
git 'clone', '--filter=blob:none', remote, git_dir.to_s, chdir: nil
|
108
108
|
rescue CommandError
|
109
|
-
git 'clone', remote, git_dir.to_s
|
109
|
+
git 'clone', remote, git_dir.to_s, chdir: nil
|
110
110
|
end
|
111
111
|
end
|
112
112
|
|
@@ -131,7 +131,8 @@ module RBS
|
|
131
131
|
private def git_dir
|
132
132
|
@git_dir ||= (
|
133
133
|
base = Pathname(ENV['XDG_CACHE_HOME'] || File.expand_path("~/.cache"))
|
134
|
-
|
134
|
+
cache_key = remote.start_with?('.') ? "#{remote}\0#{Dir.pwd}" : remote
|
135
|
+
dir = base.join('rbs', Digest::SHA256.hexdigest(cache_key))
|
135
136
|
dir.mkpath
|
136
137
|
dir
|
137
138
|
)
|
@@ -149,13 +150,14 @@ module RBS
|
|
149
150
|
git('rev-parse', 'HEAD').chomp
|
150
151
|
end
|
151
152
|
|
152
|
-
private def git(*cmd)
|
153
|
-
sh! 'git', *cmd
|
153
|
+
private def git(*cmd, **opt)
|
154
|
+
sh! 'git', *cmd, **opt
|
154
155
|
end
|
155
156
|
|
156
|
-
private def sh!(*cmd)
|
157
|
+
private def sh!(*cmd, **opt)
|
157
158
|
RBS.logger.debug "$ #{cmd.join(' ')}"
|
158
|
-
|
159
|
+
opt = { chdir: git_dir }.merge(opt).compact
|
160
|
+
(__skip__ = Open3.capture3(*cmd, **opt)).then do |out, err, status|
|
159
161
|
raise CommandError, "Unexpected status #{status.exitstatus}\n\n#{err}" unless status.success?
|
160
162
|
|
161
163
|
out
|
@@ -291,6 +291,10 @@ module RBS
|
|
291
291
|
end
|
292
292
|
|
293
293
|
one_ancestors.each_extended_module do |mod|
|
294
|
+
mod.args.each do |arg|
|
295
|
+
validate_type_presence(arg)
|
296
|
+
end
|
297
|
+
|
294
298
|
mod_defn = build_instance(mod.name, no_self_types: true)
|
295
299
|
merge_definition(src: mod_defn,
|
296
300
|
dest: definition,
|
@@ -299,6 +303,10 @@ module RBS
|
|
299
303
|
|
300
304
|
interface_methods = {}
|
301
305
|
one_ancestors.each_extended_interface do |mod|
|
306
|
+
mod.args.each do |arg|
|
307
|
+
validate_type_presence(arg)
|
308
|
+
end
|
309
|
+
|
302
310
|
mod_defn = build_interface(mod.name)
|
303
311
|
subst = Substitution.build(mod_defn.type_params, mod.args)
|
304
312
|
|
@@ -831,5 +839,26 @@ module RBS
|
|
831
839
|
end
|
832
840
|
end
|
833
841
|
end
|
842
|
+
|
843
|
+
def validate_type_presence(type)
|
844
|
+
case type
|
845
|
+
when Types::ClassInstance, Types::ClassSingleton, Types::Interface, Types::Alias
|
846
|
+
validate_type_name(type.name, type.location)
|
847
|
+
end
|
848
|
+
|
849
|
+
type.each_type do |type|
|
850
|
+
validate_type_presence(type)
|
851
|
+
end
|
852
|
+
end
|
853
|
+
|
854
|
+
def validate_type_name(name, location)
|
855
|
+
name = name.absolute!
|
856
|
+
|
857
|
+
return if name.class? && env.class_decls.key?(name)
|
858
|
+
return if name.interface? && env.interface_decls.key?(name)
|
859
|
+
return if name.alias? && env.alias_decls.key?(name)
|
860
|
+
|
861
|
+
raise NoTypeFoundError.new(type_name: name, location: location)
|
862
|
+
end
|
834
863
|
end
|
835
864
|
end
|
data/lib/rbs/validator.rb
CHANGED
@@ -27,19 +27,17 @@ module RBS
|
|
27
27
|
end
|
28
28
|
end
|
29
29
|
|
30
|
+
definition_builder.validate_type_name(type.name, type.location)
|
31
|
+
|
30
32
|
type_params = case type
|
31
33
|
when Types::ClassInstance
|
32
|
-
env.class_decls[type.name]
|
34
|
+
env.class_decls[type.name].type_params
|
33
35
|
when Types::Interface
|
34
|
-
env.interface_decls[type.name]
|
36
|
+
env.interface_decls[type.name].decl.type_params
|
35
37
|
when Types::Alias
|
36
|
-
env.alias_decls[type.name]
|
38
|
+
env.alias_decls[type.name].decl.type_params
|
37
39
|
end
|
38
40
|
|
39
|
-
unless type_params
|
40
|
-
raise NoTypeFoundError.new(type_name: type.name, location: type.location)
|
41
|
-
end
|
42
|
-
|
43
41
|
InvalidTypeApplicationError.check!(
|
44
42
|
type_name: type.name,
|
45
43
|
args: type.args,
|
@@ -48,9 +46,7 @@ module RBS
|
|
48
46
|
)
|
49
47
|
|
50
48
|
when Types::ClassSingleton
|
51
|
-
|
52
|
-
type = _ = absolute_type(type, context: context) { type.name.absolute! }
|
53
|
-
NoTypeFoundError.check!(type.name, env: env, location: type.location)
|
49
|
+
definition_builder.validate_type_presence(type)
|
54
50
|
end
|
55
51
|
|
56
52
|
type.each_type do |type|
|
data/lib/rbs/version.rb
CHANGED
@@ -62,9 +62,9 @@ module RBS
|
|
62
62
|
|
63
63
|
def resolve_revision: () -> String
|
64
64
|
|
65
|
-
def git: (*String cmd) -> String
|
65
|
+
def git: (*String cmd, **untyped opt) -> String
|
66
66
|
|
67
|
-
def sh!: (*String cmd) -> String
|
67
|
+
def sh!: (*String cmd, **untyped opt) -> String
|
68
68
|
|
69
69
|
def format_config_entry: (Config::gem_entry) -> String
|
70
70
|
end
|
data/sig/definition_builder.rbs
CHANGED
@@ -43,6 +43,13 @@ module RBS
|
|
43
43
|
|
44
44
|
def define_methods: (Definition, interface_methods: Hash[Symbol, Definition::Method], methods: MethodBuilder::Methods, super_interface_method: bool) -> void
|
45
45
|
|
46
|
+
# Validates presence of type names recursively.
|
47
|
+
# Assumes the type names are already resolved.
|
48
|
+
#
|
49
|
+
def validate_type_presence: (Types::t) -> void
|
50
|
+
|
51
|
+
def validate_type_name: (TypeName, Location[untyped, untyped]?) -> void
|
52
|
+
|
46
53
|
# Expand a type alias of given name without type arguments.
|
47
54
|
# Raises an error if the type alias requires arguments.
|
48
55
|
#
|
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: 1.8.
|
4
|
+
version: 1.8.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Soutaro Matsumoto
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2021-12-
|
11
|
+
date: 2021-12-13 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.
|