rbs 3.6.1 → 3.9.5
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/.github/workflows/comments.yml +2 -2
- data/.github/workflows/dependabot.yml +1 -1
- data/.github/workflows/ruby.yml +34 -10
- data/.github/workflows/windows.yml +20 -3
- data/.gitignore +1 -0
- data/.rubocop.yml +26 -1
- data/CHANGELOG.md +241 -0
- data/Rakefile +54 -4
- data/config.yml +317 -0
- data/core/array.rbs +1756 -1591
- data/core/basic_object.rbs +38 -35
- data/core/comparable.rbs +1 -1
- data/core/complex.rbs +166 -94
- data/core/data.rbs +2 -2
- data/core/dir.rbs +2 -18
- data/core/encoding.rbs +12 -32
- data/core/enumerable.rbs +270 -266
- data/core/enumerator.rbs +14 -4
- data/core/env.rbs +1 -1
- data/core/errno.rbs +33 -16
- data/core/errors.rbs +6 -2
- data/core/exception.rbs +342 -167
- data/core/fiber.rbs +3 -2
- data/core/file.rbs +26 -75
- data/core/float.rbs +125 -72
- data/core/gc.rbs +158 -42
- data/core/hash.rbs +122 -143
- data/core/integer.rbs +79 -50
- data/core/io/buffer.rbs +49 -43
- data/core/io.rbs +108 -151
- data/core/kernel.rbs +341 -209
- data/core/match_data.rbs +76 -2
- data/core/math.rbs +0 -36
- data/core/method.rbs +2 -2
- data/core/module.rbs +32 -27
- data/core/nil_class.rbs +2 -2
- data/core/numeric.rbs +101 -104
- data/core/object.rbs +1 -5
- data/core/object_space/weak_key_map.rbs +3 -4
- data/core/object_space.rbs +3 -3
- data/core/proc.rbs +82 -14
- data/core/process.rbs +110 -58
- data/core/ractor.rbs +57 -4
- data/core/range.rbs +114 -87
- data/core/rational.rbs +0 -2
- data/core/rbs/unnamed/argf.rbs +237 -36
- data/core/rbs/unnamed/env_class.rbs +35 -53
- data/core/rbs/unnamed/random.rbs +1 -2
- data/core/regexp.rbs +10 -56
- data/core/ruby_vm.rbs +88 -9
- data/core/rubygems/config_file.rbs +3 -0
- data/core/rubygems/errors.rbs +3 -6
- data/core/rubygems/platform.rbs +0 -9
- data/core/rubygems/rubygems.rbs +3 -6
- data/core/rubygems/version.rbs +8 -8
- data/core/set.rbs +4 -16
- data/core/string.rbs +271 -264
- data/core/struct.rbs +6 -18
- data/core/symbol.rbs +14 -21
- data/core/thread.rbs +32 -35
- data/core/time.rbs +131 -50
- data/core/trace_point.rbs +124 -113
- data/core/true_class.rbs +0 -1
- data/core/unbound_method.rbs +1 -1
- data/core/warning.rbs +9 -2
- data/docs/architecture.md +1 -1
- data/docs/syntax.md +17 -10
- data/ext/rbs_extension/extconf.rb +11 -0
- data/ext/rbs_extension/location.c +61 -29
- data/ext/rbs_extension/location.h +4 -3
- data/ext/rbs_extension/main.c +23 -1
- data/ext/rbs_extension/parser.c +506 -517
- data/ext/rbs_extension/parserstate.c +109 -30
- data/ext/rbs_extension/parserstate.h +6 -4
- data/ext/rbs_extension/rbs_extension.h +1 -10
- data/{ext/rbs_extension → include/rbs}/constants.h +21 -19
- data/include/rbs/ruby_objs.h +72 -0
- data/include/rbs/util/rbs_constant_pool.h +219 -0
- data/include/rbs.h +7 -0
- data/lib/rbs/annotate/annotations.rb +3 -3
- data/lib/rbs/annotate/rdoc_source.rb +2 -2
- data/lib/rbs/ast/declarations.rb +9 -4
- data/lib/rbs/ast/directives.rb +10 -0
- data/lib/rbs/ast/members.rb +2 -0
- data/lib/rbs/ast/type_param.rb +2 -12
- data/lib/rbs/cli/diff.rb +3 -3
- data/lib/rbs/cli/validate.rb +2 -1
- data/lib/rbs/cli.rb +16 -16
- data/lib/rbs/collection/config/lockfile_generator.rb +58 -8
- data/lib/rbs/collection/config.rb +5 -3
- data/lib/rbs/collection/sources/rubygems.rb +1 -1
- data/lib/rbs/collection.rb +1 -0
- data/lib/rbs/definition.rb +51 -34
- data/lib/rbs/definition_builder/ancestor_builder.rb +5 -3
- data/lib/rbs/definition_builder.rb +83 -24
- data/lib/rbs/environment.rb +33 -18
- data/lib/rbs/environment_loader.rb +6 -1
- data/lib/rbs/errors.rb +24 -0
- data/lib/rbs/locator.rb +2 -0
- data/lib/rbs/method_type.rb +2 -0
- data/lib/rbs/namespace.rb +1 -0
- data/lib/rbs/parser_aux.rb +40 -3
- data/lib/rbs/prototype/rb.rb +20 -12
- data/lib/rbs/prototype/rbi.rb +11 -6
- data/lib/rbs/prototype/runtime/value_object_generator.rb +7 -5
- data/lib/rbs/prototype/runtime.rb +7 -5
- data/lib/rbs/subtractor.rb +3 -3
- data/lib/rbs/test/hook.rb +47 -42
- data/lib/rbs/test/type_check.rb +7 -5
- data/lib/rbs/type_name.rb +14 -9
- data/lib/rbs/types.rb +63 -14
- data/lib/rbs/unit_test/spy.rb +4 -2
- data/lib/rbs/unit_test/type_assertions.rb +19 -13
- data/lib/rbs/unit_test/with_aliases.rb +3 -1
- data/lib/rbs/validator.rb +7 -1
- data/lib/rbs/version.rb +1 -1
- data/lib/rbs/writer.rb +10 -5
- data/lib/rbs.rb +1 -0
- data/lib/rdoc_plugin/parser.rb +2 -2
- data/rbs.gemspec +6 -2
- data/sig/ancestor_graph.rbs +5 -5
- data/sig/annotate/rdoc_source.rbs +2 -0
- data/sig/cli.rbs +2 -0
- data/sig/collection/config/lockfile_generator.rbs +9 -1
- data/sig/declarations.rbs +10 -3
- data/sig/definition.rbs +80 -12
- data/sig/definition_builder.rbs +18 -4
- data/sig/directives.rbs +17 -1
- data/sig/environment.rbs +3 -1
- data/sig/errors.rbs +19 -0
- data/sig/namespace.rbs +2 -3
- data/sig/parser.rbs +5 -1
- data/sig/prototype/rb.rbs +1 -1
- data/sig/resolver/constant_resolver.rbs +2 -2
- data/sig/resolver/context.rbs +1 -1
- data/sig/subtractor.rbs +1 -1
- data/sig/test/type_check.rbs +2 -2
- data/sig/type_alias_dependency.rbs +2 -2
- data/sig/type_alias_regularity.rbs +6 -6
- data/sig/type_param.rbs +4 -4
- data/sig/typename.rbs +8 -5
- data/sig/types.rbs +1 -1
- data/sig/unit_test/spy.rbs +2 -0
- data/sig/unit_test/type_assertions.rbs +2 -0
- data/sig/use_map.rbs +1 -1
- data/sig/validator.rbs +6 -2
- data/sig/vendorer.rbs +1 -1
- data/sig/writer.rbs +1 -1
- data/{ext/rbs_extension → src}/constants.c +35 -36
- data/src/ruby_objs.c +799 -0
- data/src/util/rbs_constant_pool.c +342 -0
- data/stdlib/base64/0/base64.rbs +0 -9
- data/stdlib/benchmark/0/benchmark.rbs +11 -2
- data/stdlib/bigdecimal/0/big_decimal.rbs +26 -182
- data/stdlib/cgi/0/core.rbs +60 -3
- data/stdlib/cgi/0/manifest.yaml +1 -0
- data/stdlib/coverage/0/coverage.rbs +0 -3
- data/stdlib/csv/0/csv.rbs +18 -58
- data/stdlib/csv/0/manifest.yaml +1 -0
- data/stdlib/date/0/date.rbs +27 -42
- data/stdlib/did_you_mean/0/did_you_mean.rbs +1 -6
- data/stdlib/digest/0/digest.rbs +25 -2
- data/stdlib/erb/0/erb.rbs +0 -1
- data/stdlib/etc/0/etc.rbs +51 -34
- data/stdlib/fileutils/0/fileutils.rbs +3 -44
- data/stdlib/io-console/0/io-console.rbs +69 -15
- data/stdlib/ipaddr/0/ipaddr.rbs +16 -4
- data/stdlib/json/0/json.rbs +107 -120
- data/stdlib/logger/0/log_device.rbs +1 -1
- data/stdlib/logger/0/logger.rbs +3 -18
- data/stdlib/minitest/0/kernel.rbs +2 -2
- data/stdlib/minitest/0/minitest/abstract_reporter.rbs +4 -1
- data/stdlib/minitest/0/minitest/assertion.rbs +1 -0
- data/stdlib/minitest/0/minitest/assertions.rbs +58 -13
- data/stdlib/minitest/0/minitest/backtrace_filter.rbs +7 -0
- data/stdlib/minitest/0/minitest/bench_spec.rbs +8 -8
- data/stdlib/minitest/0/minitest/benchmark.rbs +17 -16
- data/stdlib/minitest/0/minitest/compress.rbs +13 -0
- data/stdlib/minitest/0/minitest/error_on_warning.rbs +3 -0
- data/stdlib/minitest/0/minitest/mock.rbs +9 -5
- data/stdlib/minitest/0/minitest/parallel/executor.rbs +4 -0
- data/stdlib/minitest/0/minitest/parallel/test/class_methods.rbs +0 -1
- data/stdlib/minitest/0/minitest/pride_io.rbs +8 -0
- data/stdlib/minitest/0/minitest/pride_lol.rbs +2 -0
- data/stdlib/minitest/0/minitest/progress_reporter.rbs +1 -1
- data/stdlib/minitest/0/minitest/reportable.rbs +2 -0
- data/stdlib/minitest/0/minitest/runnable.rbs +33 -1
- data/stdlib/minitest/0/minitest/spec/dsl/instance_methods.rbs +1 -1
- data/stdlib/minitest/0/minitest/spec/dsl.rbs +10 -6
- data/stdlib/minitest/0/minitest/spec.rbs +1 -1
- data/stdlib/minitest/0/minitest/statistics_reporter.rbs +5 -0
- data/stdlib/minitest/0/minitest/summary_reporter.rbs +0 -7
- data/stdlib/minitest/0/minitest/test/lifecycle_hooks.rbs +1 -1
- data/stdlib/minitest/0/minitest/test.rbs +7 -14
- data/stdlib/minitest/0/minitest/unexpected_error.rbs +2 -0
- data/stdlib/minitest/0/minitest/unexpected_warning.rbs +6 -0
- data/stdlib/minitest/0/minitest/unit.rbs +1 -2
- data/stdlib/minitest/0/minitest.rbs +41 -892
- data/stdlib/monitor/0/monitor.rbs +13 -4
- data/stdlib/net-http/0/net-http.rbs +42 -109
- data/stdlib/nkf/0/nkf.rbs +30 -0
- data/stdlib/objspace/0/objspace.rbs +1 -2
- data/stdlib/observable/0/observable.rbs +1 -1
- data/stdlib/open-uri/0/manifest.yaml +1 -0
- data/stdlib/open-uri/0/open-uri.rbs +52 -0
- data/stdlib/open3/0/open3.rbs +0 -8
- data/stdlib/openssl/0/manifest.yaml +1 -0
- data/stdlib/openssl/0/openssl.rbs +235 -143
- data/stdlib/optparse/0/optparse.rbs +58 -18
- data/stdlib/pathname/0/pathname.rbs +2 -8
- data/stdlib/pp/0/pp.rbs +3 -1
- data/stdlib/prettyprint/0/prettyprint.rbs +0 -4
- data/stdlib/pstore/0/pstore.rbs +0 -6
- data/stdlib/psych/0/core_ext.rbs +12 -0
- data/stdlib/psych/0/psych.rbs +15 -4
- data/stdlib/pty/0/pty.rbs +46 -4
- data/stdlib/rdoc/0/code_object.rbs +0 -4
- data/stdlib/rdoc/0/markup.rbs +10 -12
- data/stdlib/rdoc/0/rdoc.rbs +13 -8
- data/stdlib/resolv/0/resolv.rbs +21 -12
- data/stdlib/ripper/0/ripper.rbs +0 -2
- data/stdlib/securerandom/0/securerandom.rbs +7 -2
- data/stdlib/shellwords/0/shellwords.rbs +11 -12
- data/stdlib/singleton/0/singleton.rbs +0 -1
- data/stdlib/socket/0/addrinfo.rbs +1 -2
- data/stdlib/socket/0/basic_socket.rbs +0 -5
- data/stdlib/socket/0/socket.rbs +32 -27
- data/stdlib/socket/0/tcp_server.rbs +0 -3
- data/stdlib/socket/0/tcp_socket.rbs +36 -3
- data/stdlib/socket/0/udp_socket.rbs +0 -1
- data/stdlib/socket/0/unix_server.rbs +0 -3
- data/stdlib/socket/0/unix_socket.rbs +4 -2
- data/{core/string_io.rbs → stdlib/stringio/0/stringio.rbs} +1 -1
- data/stdlib/strscan/0/string_scanner.rbs +1265 -422
- data/stdlib/tempfile/0/tempfile.rbs +135 -28
- data/stdlib/time/0/time.rbs +48 -35
- data/stdlib/timeout/0/timeout.rbs +11 -8
- data/stdlib/tmpdir/0/tmpdir.rbs +10 -3
- data/stdlib/tsort/0/tsort.rbs +0 -4
- data/stdlib/uri/0/common.rbs +28 -30
- data/stdlib/uri/0/ftp.rbs +1 -1
- data/stdlib/uri/0/generic.rbs +22 -18
- data/stdlib/uri/0/http.rbs +2 -2
- data/stdlib/uri/0/rfc2396_parser.rbs +3 -0
- data/stdlib/zlib/0/buf_error.rbs +1 -70
- data/stdlib/zlib/0/data_error.rbs +1 -70
- data/stdlib/zlib/0/deflate.rbs +8 -72
- data/stdlib/zlib/0/error.rbs +1 -70
- data/stdlib/zlib/0/gzip_file/crc_error.rbs +2 -105
- data/stdlib/zlib/0/gzip_file/error.rbs +2 -105
- data/stdlib/zlib/0/gzip_file/length_error.rbs +2 -105
- data/stdlib/zlib/0/gzip_file/no_footer.rbs +2 -105
- data/stdlib/zlib/0/gzip_file.rbs +1 -71
- data/stdlib/zlib/0/gzip_reader.rbs +3 -74
- data/stdlib/zlib/0/gzip_writer.rbs +1 -70
- data/stdlib/zlib/0/inflate.rbs +4 -71
- data/stdlib/zlib/0/mem_error.rbs +1 -70
- data/stdlib/zlib/0/need_dict.rbs +1 -70
- data/stdlib/zlib/0/stream_end.rbs +1 -70
- data/stdlib/zlib/0/stream_error.rbs +1 -70
- data/stdlib/zlib/0/version_error.rbs +1 -70
- data/stdlib/zlib/0/zlib.rbs +0 -2
- data/stdlib/zlib/0/zstream.rbs +4 -72
- metadata +17 -13
- data/ext/rbs_extension/ruby_objs.c +0 -602
- data/ext/rbs_extension/ruby_objs.h +0 -51
- data/stdlib/minitest/0/manifest.yaml +0 -2
data/lib/rdoc_plugin/parser.rb
CHANGED
@@ -108,7 +108,7 @@ module RBS
|
|
108
108
|
|
109
109
|
def parse_include_decl(decl:, context:, outer_name: nil)
|
110
110
|
name = decl.name.to_s
|
111
|
-
outer_names = outer_name ? outer_name.to_s.split("::") : []
|
111
|
+
outer_names = outer_name ? outer_name.to_s.split("::") : [] #: Array[String]
|
112
112
|
qualified_name = ''
|
113
113
|
outer_names.each do |namespace|
|
114
114
|
qualified_name += namespace
|
@@ -124,7 +124,7 @@ module RBS
|
|
124
124
|
|
125
125
|
def parse_extend_decl(decl:, context:, outer_name: nil)
|
126
126
|
name = decl.name.to_s
|
127
|
-
outer_names = outer_name ? outer_name.to_s.split("::") : []
|
127
|
+
outer_names = outer_name ? outer_name.to_s.split("::") : [] #: Array[String]
|
128
128
|
qualified_name = ''
|
129
129
|
outer_names.each do |namespace|
|
130
130
|
qualified_name += namespace
|
data/rbs.gemspec
CHANGED
@@ -30,16 +30,20 @@ Gem::Specification.new do |spec|
|
|
30
30
|
spec.files = Dir.chdir(File.expand_path('..', __FILE__)) do
|
31
31
|
`git ls-files -z`.split("\x0").reject do |f|
|
32
32
|
[
|
33
|
-
%r{^(test|spec|features|bin|steep|benchmark)/},
|
33
|
+
%r{^(test|spec|features|bin|steep|benchmark|templates)/},
|
34
34
|
/Gemfile/
|
35
35
|
].any? {|r| f.match(r) }
|
36
36
|
end
|
37
37
|
end
|
38
38
|
spec.extensions = %w{ext/rbs_extension/extconf.rb}
|
39
39
|
|
40
|
+
if false
|
41
|
+
spec.required_ruby_version = ">= 3.3"
|
42
|
+
end
|
43
|
+
|
40
44
|
spec.bindir = "exe"
|
41
45
|
spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
|
42
46
|
spec.require_paths = ["lib"]
|
43
|
-
spec.required_ruby_version = ">= 3.
|
47
|
+
spec.required_ruby_version = ">= 3.1"
|
44
48
|
spec.add_dependency "logger"
|
45
49
|
end
|
data/sig/ancestor_graph.rbs
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
module RBS
|
2
|
-
# AncestorGraph is a utility class that helps iterating through ancestors and
|
2
|
+
# AncestorGraph is a utility class that helps iterating through ancestors and descendants of a class/module
|
3
3
|
#
|
4
4
|
# ```ruby
|
5
5
|
# graph = AncestorGraph.new(env: env, ancestor_builder: ancestor_builder)
|
6
6
|
#
|
7
|
-
# graph.each_parent(AncestorGraph::InstanceNode.new(type_name: TypeName("::Object")))
|
8
|
-
# graph.each_ancestor(AncestorGraph::InstanceNode.new(type_name: TypeName("::Object")))
|
7
|
+
# graph.each_parent(AncestorGraph::InstanceNode.new(type_name: TypeName.parse("::Object")))
|
8
|
+
# graph.each_ancestor(AncestorGraph::InstanceNode.new(type_name: TypeName.parse("::Object")))
|
9
9
|
#
|
10
|
-
# graph.each_child(AncestorGraph::InstanceNode.new(type_name: TypeName("::Object")))
|
11
|
-
# graph.each_descendant(AncestorGraph::InstanceNode.new(type_name: TypeName("::Object")))
|
10
|
+
# graph.each_child(AncestorGraph::InstanceNode.new(type_name: TypeName.parse("::Object")))
|
11
|
+
# graph.each_descendant(AncestorGraph::InstanceNode.new(type_name: TypeName.parse("::Object")))
|
12
12
|
# ```
|
13
13
|
#
|
14
14
|
# Note that the class works for class/module declarations.
|
@@ -25,6 +25,8 @@ module RBS
|
|
25
25
|
| (TypeName, singleton_method: Symbol) -> Array[RDoc::AnyMethod]?
|
26
26
|
|
27
27
|
def find_attribute: (TypeName, Symbol, singleton: bool) -> Array[RDoc::Attr]?
|
28
|
+
|
29
|
+
def class_docs: (TypeName) -> Array[::RDoc::Markup::Document | ::RDoc::Comment | ::String]?
|
28
30
|
end
|
29
31
|
end
|
30
32
|
end
|
data/sig/cli.rbs
CHANGED
@@ -2,6 +2,10 @@ module RBS
|
|
2
2
|
module Collection
|
3
3
|
class Config
|
4
4
|
class LockfileGenerator
|
5
|
+
# Name of stdlibs that was rbs-bundled stdlib but is now a gem.
|
6
|
+
#
|
7
|
+
ALUMNI_STDLIBS: Hash[String, String?]
|
8
|
+
|
5
9
|
class GemfileLockMismatchError < StandardError
|
6
10
|
@expected: Pathname
|
7
11
|
|
@@ -43,7 +47,11 @@ module RBS
|
|
43
47
|
#
|
44
48
|
def assign_gem: (name: String, version: String?, ?skip: bool) -> void
|
45
49
|
|
46
|
-
|
50
|
+
# Assign a gem from stdlib to lockfile
|
51
|
+
#
|
52
|
+
# `from_gem` is a String when the stdlib is assigned through the `dependencies:` in `manifest.yaml` of a gem.
|
53
|
+
#
|
54
|
+
def assign_stdlib: (name: String, ?from_gem: String) -> void
|
47
55
|
|
48
56
|
# Find a source of a gem from ones registered in `config.sources`
|
49
57
|
#
|
data/sig/declarations.rbs
CHANGED
@@ -205,8 +205,10 @@ module RBS
|
|
205
205
|
attr_reader type: Types::t
|
206
206
|
attr_reader location: loc?
|
207
207
|
attr_reader comment: Comment?
|
208
|
+
attr_reader annotations: Array[Annotation]
|
208
209
|
|
209
|
-
def initialize: (name: TypeName, type: Types::t, location: loc?, comment: Comment
|
210
|
+
def initialize: (name: TypeName, type: Types::t, location: loc?, comment: Comment?, annotations: Array[Annotation]) -> void
|
211
|
+
| %a{deprecated} (name: TypeName, type: Types::t, location: loc?, comment: Comment?) -> void
|
210
212
|
|
211
213
|
include _HashEqual
|
212
214
|
include _ToJson
|
@@ -223,8 +225,10 @@ module RBS
|
|
223
225
|
attr_reader type: Types::t
|
224
226
|
attr_reader location: loc?
|
225
227
|
attr_reader comment: Comment?
|
228
|
+
attr_reader annotations: Array[Annotation]
|
226
229
|
|
227
|
-
def initialize: (name: Symbol, type: Types::t, location: loc?, comment: Comment
|
230
|
+
def initialize: (name: Symbol, type: Types::t, location: loc?, comment: Comment?, annotations: Array[Annotation]) -> void
|
231
|
+
| %a{deprecated} (name: Symbol, type: Types::t, location: loc?, comment: Comment?) -> void
|
228
232
|
|
229
233
|
include _HashEqual
|
230
234
|
include _ToJson
|
@@ -250,7 +254,10 @@ module RBS
|
|
250
254
|
|
251
255
|
attr_reader comment: Comment?
|
252
256
|
|
253
|
-
|
257
|
+
attr_reader annotations: Array[Annotation]
|
258
|
+
|
259
|
+
def initialize: (new_name: TypeName, old_name: TypeName, location: loc?, comment: Comment?, annotations: Array[Annotation]) -> void
|
260
|
+
| %a{deprecated} (new_name: TypeName, old_name: TypeName, location: loc?, comment: Comment?) -> void
|
254
261
|
|
255
262
|
include _HashEqual
|
256
263
|
end
|
data/sig/definition.rbs
CHANGED
@@ -6,8 +6,15 @@ module RBS
|
|
6
6
|
attr_reader parent_variable: Variable?
|
7
7
|
attr_reader type: Types::t
|
8
8
|
attr_reader declared_in: TypeName
|
9
|
+
type source = AST::Members::AttrAccessor
|
10
|
+
| AST::Members::AttrReader
|
11
|
+
| AST::Members::AttrWriter
|
12
|
+
| AST::Members::InstanceVariable
|
13
|
+
| AST::Members::ClassVariable
|
14
|
+
| AST::Members::ClassInstanceVariable
|
15
|
+
attr_reader source: source
|
9
16
|
|
10
|
-
def initialize: (parent_variable: Variable?, type: Types::t, declared_in: TypeName) -> void
|
17
|
+
def initialize: (parent_variable: Variable?, type: Types::t, declared_in: TypeName, source: source) -> void
|
11
18
|
|
12
19
|
def sub: (Substitution) -> Variable
|
13
20
|
end
|
@@ -21,34 +28,94 @@ module RBS
|
|
21
28
|
attr_reader defined_in: TypeName
|
22
29
|
attr_reader implemented_in: TypeName?
|
23
30
|
|
24
|
-
|
31
|
+
# Annotations given to the method definition syntax
|
32
|
+
#
|
33
|
+
# If the method have multiple syntaxes, union of the annotations to the member will be included, without dedup.
|
34
|
+
#
|
35
|
+
# The value should be updated during setup.
|
36
|
+
#
|
37
|
+
attr_reader member_annotations: Array[AST::Annotation]
|
38
|
+
|
39
|
+
# Annotations given to the overload associated to the method type
|
40
|
+
#
|
41
|
+
# The value should be updated during setup.
|
42
|
+
#
|
43
|
+
attr_reader overload_annotations: Array[AST::Annotation]
|
44
|
+
|
45
|
+
# Always returns an empty array
|
46
|
+
%a{deprecated} attr_reader annotations: Array[AST::Annotation]
|
47
|
+
|
48
|
+
# `overload_annotations` is ignored.
|
49
|
+
def initialize: (
|
50
|
+
type: MethodType,
|
51
|
+
member: method_member,
|
52
|
+
defined_in: TypeName,
|
53
|
+
implemented_in: TypeName?
|
54
|
+
) -> void
|
55
|
+
| %a{deprecated} (
|
56
|
+
type: MethodType,
|
57
|
+
member: method_member,
|
58
|
+
defined_in: TypeName,
|
59
|
+
implemented_in: TypeName?,
|
60
|
+
overload_annotations: nil
|
61
|
+
) -> void
|
25
62
|
|
26
63
|
def comment: () -> AST::Comment?
|
27
64
|
|
28
|
-
def annotations: () -> Array[AST::Annotation]
|
29
|
-
|
30
65
|
def update: (?type: MethodType, ?member: method_member, ?defined_in: TypeName, ?implemented_in: TypeName?) -> TypeDef
|
31
66
|
|
32
67
|
def overload?: () -> bool
|
68
|
+
|
69
|
+
# Yields member and overload annotations, without dedup
|
70
|
+
#
|
71
|
+
# Member annotation yields first.
|
72
|
+
#
|
73
|
+
def each_annotation: () { (AST::Annotation) -> void } -> void
|
74
|
+
| () -> Enumerator[AST::Annotation]
|
33
75
|
end
|
34
76
|
|
35
77
|
attr_reader super_method: Method?
|
36
78
|
attr_reader defs: Array[TypeDef]
|
37
79
|
attr_reader accessibility: accessibility
|
38
|
-
|
80
|
+
|
39
81
|
attr_reader defined_in: TypeName?
|
40
82
|
attr_reader implemented_in: TypeName?
|
41
83
|
attr_reader method_types: Array[MethodType]
|
42
84
|
attr_reader comments: Array[AST::Comment]
|
43
|
-
|
85
|
+
|
44
86
|
attr_reader members: Array[method_member]
|
87
|
+
|
88
|
+
# The original method when the method is defined with `alias` syntax
|
45
89
|
attr_reader alias_of: Method?
|
46
90
|
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
|
91
|
+
# Present if the method is defined with `alias` syntax
|
92
|
+
attr_reader alias_member: AST::Members::Alias?
|
93
|
+
|
94
|
+
# Unused, always returns empty array
|
95
|
+
%a{deprecated} attr_reader extra_annotations: Array[AST::Annotation]
|
96
|
+
|
97
|
+
# Union of annotations given to `def`s and `alias`, not contains annotations given to each overload
|
98
|
+
#
|
99
|
+
# The elements will be updated during `Method` object setup.
|
100
|
+
#
|
101
|
+
attr_reader annotations: Array[AST::Annotation]
|
102
|
+
|
103
|
+
# Note that the annotations given through `annotations:` keyword is ignored.
|
104
|
+
#
|
105
|
+
def initialize: (
|
106
|
+
super_method: Method?,
|
107
|
+
defs: Array[TypeDef],
|
108
|
+
accessibility: accessibility,
|
109
|
+
alias_of: Method?,
|
110
|
+
alias_member: AST::Members::Alias?
|
111
|
+
) -> void
|
112
|
+
| %a{deprecated} (
|
113
|
+
super_method: Method?,
|
114
|
+
defs: Array[TypeDef],
|
115
|
+
accessibility: accessibility,
|
116
|
+
alias_of: Method?,
|
117
|
+
annotations: Array[AST::Annotation]
|
118
|
+
) -> void
|
52
119
|
|
53
120
|
def public?: () -> bool
|
54
121
|
|
@@ -75,7 +142,8 @@ module RBS
|
|
75
142
|
?defs: Array[TypeDef],
|
76
143
|
?accessibility: accessibility,
|
77
144
|
?alias_of: Method?,
|
78
|
-
?annotations: Array[AST::Annotation]
|
145
|
+
?annotations: Array[AST::Annotation],
|
146
|
+
?alias_member: AST::Members::Alias?
|
79
147
|
) -> Method
|
80
148
|
end
|
81
149
|
|
data/sig/definition_builder.rbs
CHANGED
@@ -105,7 +105,15 @@ module RBS
|
|
105
105
|
|
106
106
|
def source_location: (Definition::Ancestor::Instance::source, AST::Declarations::t) -> Location[untyped, untyped]?
|
107
107
|
|
108
|
-
def
|
108
|
+
def validate_variable: (Definition::Variable) -> void
|
109
|
+
|
110
|
+
def insert_variable: (
|
111
|
+
TypeName,
|
112
|
+
Hash[Symbol, Definition::Variable],
|
113
|
+
name: Symbol,
|
114
|
+
type: Types::t,
|
115
|
+
source: Definition::Variable::source
|
116
|
+
) -> void
|
109
117
|
|
110
118
|
# Add method definition to `methods`, which will be merged to `class_definition` after defining all methods at this *level* -- class, module, or interface
|
111
119
|
#
|
@@ -142,11 +150,17 @@ module RBS
|
|
142
150
|
Hash[Symbol, Definition::Method]? self_type_methods,
|
143
151
|
) -> void
|
144
152
|
|
145
|
-
# Updates `definition` with methods and variables of `type_name` that can be a module or a class
|
153
|
+
# Updates `definition` with methods and instance variables of `type_name` that can be a module or a class
|
146
154
|
#
|
147
155
|
# It processes includes and prepends recursively.
|
156
|
+
# If `define_class_vars:` is falsy, it skips inserting class variables.
|
148
157
|
#
|
149
|
-
def define_instance: (
|
158
|
+
def define_instance: (
|
159
|
+
Definition definition,
|
160
|
+
TypeName type_name,
|
161
|
+
Substitution subst,
|
162
|
+
define_class_vars: bool
|
163
|
+
) -> void
|
150
164
|
|
151
165
|
# Updates `definition` with methods defined in an interface `type_name`
|
152
166
|
#
|
@@ -157,7 +171,7 @@ module RBS
|
|
157
171
|
# Returns a substitution that corresponds to type application
|
158
172
|
#
|
159
173
|
# ```
|
160
|
-
# tapp_subst(`::Array`, [`::Integer`]) # =>
|
174
|
+
# tapp_subst(`::Array`, [`::Integer`]) # => Substitution.build([:Elem], [`::Integer`])
|
161
175
|
# ```
|
162
176
|
#
|
163
177
|
def tapp_subst: (TypeName, Array[Types::t]) -> Substitution
|
data/sig/directives.rbs
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
module RBS
|
2
2
|
module AST
|
3
3
|
module Directives
|
4
|
-
type t = Use
|
4
|
+
type t = Use | ResolveTypeNames
|
5
5
|
|
6
6
|
class Base
|
7
7
|
end
|
@@ -56,6 +56,22 @@ module RBS
|
|
56
56
|
|
57
57
|
def initialize: (clauses: Array[clause], location: loc?) -> void
|
58
58
|
end
|
59
|
+
|
60
|
+
class ResolveTypeNames < Base
|
61
|
+
# ```
|
62
|
+
# # resolve-type-names: false
|
63
|
+
# ^^^^^^^^^^^^^^^^^^ keyword
|
64
|
+
# ^ colon
|
65
|
+
# ^^^^^ value
|
66
|
+
# ```
|
67
|
+
type loc = Location[:keyword | :colon | :value, bot]
|
68
|
+
|
69
|
+
attr_reader location: loc?
|
70
|
+
|
71
|
+
attr_reader value: bool
|
72
|
+
|
73
|
+
def initialize: (value: bool, location: loc?) -> void
|
74
|
+
end
|
59
75
|
end
|
60
76
|
end
|
61
77
|
end
|
data/sig/environment.rbs
CHANGED
@@ -141,6 +141,8 @@ module RBS
|
|
141
141
|
#
|
142
142
|
def resolve_type_names: (?only: Set[AST::Declarations::t]?) -> Environment
|
143
143
|
|
144
|
+
def resolve_signature: (Resolver::TypeNameResolver, UseMap::Table, Array[AST::Directives::t], Array[AST::Declarations::t], ?only: Set[AST::Declarations::t]?) -> [Array[AST::Directives::t], Array[AST::Declarations::t]]
|
145
|
+
|
144
146
|
def inspect: () -> String
|
145
147
|
|
146
148
|
def buffers: () -> Array[Buffer]
|
@@ -233,7 +235,7 @@ module RBS
|
|
233
235
|
def normalize_type_name?: (TypeName) -> (TypeName | nil | false)
|
234
236
|
|
235
237
|
# Normalize the type name or raises an error
|
236
|
-
#
|
238
|
+
#
|
237
239
|
def normalize_type_name!: (TypeName) -> TypeName
|
238
240
|
|
239
241
|
# Returns a normalized module/class name or a type name with a normalized namespace
|
data/sig/errors.rbs
CHANGED
@@ -182,6 +182,25 @@ module RBS
|
|
182
182
|
def location: () -> AST::Members::Mixin::loc?
|
183
183
|
end
|
184
184
|
|
185
|
+
class VariableDuplicationError < DefinitionError
|
186
|
+
include DetailedMessageable
|
187
|
+
|
188
|
+
attr_reader type_name: TypeName
|
189
|
+
attr_reader variable_name: Symbol
|
190
|
+
attr_reader location: Location[untyped, untyped]?
|
191
|
+
|
192
|
+
def initialize: (type_name: TypeName, variable_name: Symbol, location: Location[untyped, untyped]?) -> void
|
193
|
+
def kind: () -> String
|
194
|
+
end
|
195
|
+
|
196
|
+
class InstanceVariableDuplicationError < VariableDuplicationError
|
197
|
+
def kind: () -> String
|
198
|
+
end
|
199
|
+
|
200
|
+
class ClassInstanceVariableDuplicationError < VariableDuplicationError
|
201
|
+
def kind: () -> String
|
202
|
+
end
|
203
|
+
|
185
204
|
# The `alias` member declares an alias from unknown method
|
186
205
|
#
|
187
206
|
class UnknownMethodAliasError < DefinitionError
|
data/sig/namespace.rbs
CHANGED
@@ -141,7 +141,6 @@ module RBS
|
|
141
141
|
end
|
142
142
|
|
143
143
|
module Kernel
|
144
|
-
#
|
145
|
-
|
146
|
-
def Namespace: (String) -> RBS::Namespace
|
144
|
+
# Deprecated: Use `RBS::Namespace.parse` instead
|
145
|
+
%a{deprecated} def Namespace: (String) -> RBS::Namespace
|
147
146
|
end
|
data/sig/parser.rbs
CHANGED
@@ -68,6 +68,10 @@ module RBS
|
|
68
68
|
#
|
69
69
|
def self.parse_signature: (Buffer | String) -> [Buffer, Array[AST::Directives::t], Array[AST::Declarations::t]]
|
70
70
|
|
71
|
+
# Returns the magic comment from the buffer
|
72
|
+
#
|
73
|
+
def self.magic_comment: (Buffer) -> AST::Directives::ResolveTypeNames?
|
74
|
+
|
71
75
|
# Parse whole RBS file and return result.
|
72
76
|
#
|
73
77
|
# ```ruby
|
@@ -86,7 +90,7 @@ module RBS
|
|
86
90
|
|
87
91
|
def self._parse_method_type: (Buffer, Integer start_pos, Integer end_pos, Array[Symbol] variables, bool require_eof) -> MethodType?
|
88
92
|
|
89
|
-
def self._parse_signature: (Buffer, Integer end_pos) -> [Array[AST::Directives::t], Array[AST::Declarations::t]]
|
93
|
+
def self._parse_signature: (Buffer, Integer start_pos, Integer end_pos) -> [Array[AST::Directives::t], Array[AST::Declarations::t]]
|
90
94
|
|
91
95
|
def self._lex: (Buffer, Integer end_pos) -> Array[[Symbol, Location[untyped, untyped]]]
|
92
96
|
|
data/sig/prototype/rb.rbs
CHANGED
@@ -44,7 +44,7 @@ module RBS
|
|
44
44
|
# Returns a type name that represents the name of the constant.
|
45
45
|
# `node` must be _constant_ node, `CONST`, `COLON2`, or `COLON3` node.
|
46
46
|
#
|
47
|
-
def const_to_name!: (RubyVM::AbstractSyntaxTree::Node node) -> TypeName
|
47
|
+
def const_to_name!: (RubyVM::AbstractSyntaxTree::Node node, ?context: Context?) -> TypeName
|
48
48
|
|
49
49
|
# Returns a type name that represents the name of the constant.
|
50
50
|
# `node` can be `SELF` for `extend self` pattern.
|
@@ -6,8 +6,8 @@ module RBS
|
|
6
6
|
# ```rb
|
7
7
|
# table = RBS::ConstantResolver::Table.new(env)
|
8
8
|
#
|
9
|
-
# table.children(TypeName("::Object")) # -> { ... } Returns a hash of name and constants.
|
10
|
-
# table.children(TypeName("::File::PATH_SEPARATOR")) # -> nil Returns nil because the constant is not a module.
|
9
|
+
# table.children(TypeName.parse("::Object")) # -> { ... } Returns a hash of name and constants.
|
10
|
+
# table.children(TypeName.parse("::File::PATH_SEPARATOR")) # -> nil Returns nil because the constant is not a module.
|
11
11
|
#
|
12
12
|
# table.toplevel # -> { ... } Returns a hash of top level constants.
|
13
13
|
# ```
|
data/sig/resolver/context.rbs
CHANGED
@@ -9,7 +9,7 @@ module RBS
|
|
9
9
|
#
|
10
10
|
# Note that the `TypeName` must be an absolute type name.
|
11
11
|
#
|
12
|
-
# The following Ruby code has context of `[[nil, TypeName("::Foo")], false]` where
|
12
|
+
# The following Ruby code has context of `[[nil, TypeName.parse("::Foo")], false]` where
|
13
13
|
#
|
14
14
|
# * `Foo` is a class defined in RBS file
|
15
15
|
# * `Bar` is not defined in RBS files
|
data/sig/subtractor.rbs
CHANGED
@@ -24,7 +24,7 @@ module RBS
|
|
24
24
|
|
25
25
|
private def mixin_exist?: (TypeName owner, AST::Members::Include | AST::Members::Extend | AST::Members::Prepend, context: Resolver::context) -> boolish
|
26
26
|
|
27
|
-
private def
|
27
|
+
private def filter_redundant_access_modifiers: (Array[AST::Declarations::t | AST::Members::t]) -> Array[AST::Declarations::t | AST::Members::t]
|
28
28
|
|
29
29
|
private def access_modifier?: (AST::Declarations::t | AST::Members::t?) -> bool
|
30
30
|
|
data/sig/test/type_check.rbs
CHANGED
@@ -7,12 +7,12 @@ module RBS
|
|
7
7
|
#
|
8
8
|
# Returns an array with detected errors.
|
9
9
|
#
|
10
|
-
def method_call: (Symbol, MethodType, CallTrace, errors: Array[Errors::t]) -> Array[Errors::t]
|
10
|
+
def method_call: (Symbol, MethodType, CallTrace, errors: Array[Errors::t], ?annotations: Array[AST::Annotation]) -> Array[Errors::t]
|
11
11
|
|
12
12
|
# Test if given `value` is compatible to type
|
13
13
|
#
|
14
14
|
# Returns `true` if the value has the type.
|
15
|
-
#
|
15
|
+
#
|
16
16
|
def value: (untyped value, Types::t) -> bool
|
17
17
|
end
|
18
18
|
end
|
@@ -1,5 +1,5 @@
|
|
1
1
|
module RBS
|
2
|
-
# TypeAliasDependency calculates the
|
2
|
+
# TypeAliasDependency calculates the dependencies between type aliases
|
3
3
|
#
|
4
4
|
# The dependencies are normalized automatically.
|
5
5
|
#
|
@@ -12,7 +12,7 @@ module RBS
|
|
12
12
|
#
|
13
13
|
attr_reader direct_dependencies: Hash[TypeName, Set[TypeName]]
|
14
14
|
|
15
|
-
# A hash table from type alias name to a hash name with keys of transitive
|
15
|
+
# A hash table from type alias name to a hash name with keys of transitive dependencies
|
16
16
|
#
|
17
17
|
# The source type name and dependencies are normalized.
|
18
18
|
#
|
@@ -20,9 +20,9 @@ module RBS
|
|
20
20
|
# ```rb
|
21
21
|
# validator = RBS::TypeAliasRegularity.validate(env: env)
|
22
22
|
#
|
23
|
-
# validator.nonregular?(TypeName("::foo")) # => nil
|
24
|
-
# validator.nonregular?(TypeName("::bar")) # => nil
|
25
|
-
# validator.nonregular?(TypeName("::baz")) # => TypeAliasRegularity::Diagnostic
|
23
|
+
# validator.nonregular?(TypeName.parse("::foo")) # => nil
|
24
|
+
# validator.nonregular?(TypeName.parse("::bar")) # => nil
|
25
|
+
# validator.nonregular?(TypeName.parse("::baz")) # => TypeAliasRegularity::Diagnostic
|
26
26
|
# ```
|
27
27
|
#
|
28
28
|
# A special case is when the type argument is `untyped`.
|
@@ -51,8 +51,8 @@ module RBS
|
|
51
51
|
# The type `t` is nonregular because it contains `t[T?]` on it's right hand side.
|
52
52
|
#
|
53
53
|
# ```
|
54
|
-
# diagnostic = validator.nonregular?(TypeName("::t"))
|
55
|
-
# diagnostic.type_name # => TypeName("::t")
|
54
|
+
# diagnostic = validator.nonregular?(TypeName.parse("::t"))
|
55
|
+
# diagnostic.type_name # => TypeName.parse("::t")
|
56
56
|
# diagnostic.nonregular_type # => t[T?]
|
57
57
|
# ```
|
58
58
|
#
|
@@ -71,7 +71,7 @@ module RBS
|
|
71
71
|
def initialize: (env: Environment) -> void
|
72
72
|
|
73
73
|
# Returns `Diagnostic` instance if the alias type is nonregular.
|
74
|
-
#
|
74
|
+
# Returns `nil` if the alias type is regular.
|
75
75
|
#
|
76
76
|
# Normalizes the given type name automatically.
|
77
77
|
#
|
data/sig/type_param.rbs
CHANGED
@@ -26,7 +26,7 @@ module RBS
|
|
26
26
|
|
27
27
|
attr_reader default_type: Types::t?
|
28
28
|
|
29
|
-
def initialize: (name: Symbol, variance: variance, upper_bound: Types::t?, location: loc?, ?default_type: Types::t?) -> void
|
29
|
+
def initialize: (name: Symbol, variance: variance, upper_bound: Types::t?, location: loc?, ?default_type: Types::t?, ?unchecked: bool) -> void
|
30
30
|
|
31
31
|
include _ToJson
|
32
32
|
|
@@ -75,7 +75,7 @@ module RBS
|
|
75
75
|
|
76
76
|
def to_s: () -> String
|
77
77
|
|
78
|
-
# Validates TypeParams if it refers another
|
78
|
+
# Validates TypeParams if it refers another optional type params
|
79
79
|
#
|
80
80
|
# * Returns array of TypeParam objects that refers other optional type params
|
81
81
|
# * Returns `nil` if all type params are valid
|
@@ -86,7 +86,7 @@ module RBS
|
|
86
86
|
#
|
87
87
|
def self.application: (Array[TypeParam], Array[Types::t]) -> Substitution?
|
88
88
|
|
89
|
-
# Returns an array of type args, that fills
|
89
|
+
# Returns an array of type args, that fills omitted types with the defaults
|
90
90
|
#
|
91
91
|
# ```rbs
|
92
92
|
# interface _Foo[T, S = untyped]
|
@@ -102,7 +102,7 @@ module RBS
|
|
102
102
|
# _Foo[String, Integer, untyped] # => _Foo[String, Integer, untyped] (Keeping extra args)
|
103
103
|
# ```
|
104
104
|
#
|
105
|
-
# Note that it allows
|
105
|
+
# Note that it allows invalid arities, returning the `args` immediately.
|
106
106
|
#
|
107
107
|
def self.normalize_args: (Array[TypeParam], Array[Types::t]) -> Array[Types::t]
|
108
108
|
end
|
data/sig/typename.rbs
CHANGED
@@ -57,9 +57,9 @@ module RBS
|
|
57
57
|
# Returns a new type name with a namespace appended to given namespace.
|
58
58
|
#
|
59
59
|
# ```rb
|
60
|
-
# TypeName("Hello").with_prefix(Namespace("World")) # => World::Hello
|
61
|
-
# TypeName("Foo::Bar").with_prefix(Namespace("::Hello")) # => ::Hello::Foo::Bar
|
62
|
-
# TypeName("::A::B").with_prefix(Namespace("C")) # => ::A::B
|
60
|
+
# TypeName.parse("Hello").with_prefix(Namespace("World")) # => World::Hello
|
61
|
+
# TypeName.parse("Foo::Bar").with_prefix(Namespace("::Hello")) # => ::Hello::Foo::Bar
|
62
|
+
# TypeName.parse("::A::B").with_prefix(Namespace("C")) # => ::A::B
|
63
63
|
# ```
|
64
64
|
#
|
65
65
|
def with_prefix: (Namespace namespace) -> TypeName
|
@@ -67,10 +67,13 @@ module RBS
|
|
67
67
|
def +: (TypeName) -> TypeName
|
68
68
|
|
69
69
|
def split: () -> Array[Symbol]
|
70
|
+
|
71
|
+
# Returns type name with given string representation.
|
72
|
+
def self.parse: (String name) -> RBS::TypeName
|
70
73
|
end
|
71
74
|
end
|
72
75
|
|
73
76
|
module Kernel
|
74
|
-
#
|
75
|
-
def TypeName: (String name) -> RBS::TypeName
|
77
|
+
# Deprecated: Use `RBS::TypeName.parse` instead
|
78
|
+
%a{deprecated: Use `RBS::TypeName.parse` instead} def TypeName: (String name) -> RBS::TypeName
|
76
79
|
end
|
data/sig/types.rbs
CHANGED
data/sig/unit_test/spy.rbs
CHANGED