rbs 3.1.0 → 3.1.2
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 +28 -0
- data/Gemfile +1 -1
- data/Gemfile.lock +15 -13
- data/core/file.rbs +104 -0
- data/core/gc.rbs +0 -7
- data/core/process.rbs +3 -0
- data/lib/rbs/collection/config/lockfile_generator.rb +7 -3
- data/lib/rbs/definition_builder.rb +4 -3
- data/lib/rbs/environment.rb +73 -30
- data/lib/rbs/errors.rb +4 -4
- data/lib/rbs/resolver/type_name_resolver.rb +39 -6
- data/lib/rbs/type_alias_dependency.rb +12 -2
- data/lib/rbs/type_alias_regularity.rb +18 -11
- data/lib/rbs/validator.rb +29 -28
- data/lib/rbs/variance_calculator.rb +25 -22
- data/lib/rbs/version.rb +1 -1
- data/lib/rdoc/discover.rb +1 -1
- data/sig/definition_builder.rbs +4 -0
- data/sig/environment.rbs +27 -0
- data/sig/errors.rbs +6 -0
- data/sig/resolver/type_name_resolver.rbs +5 -1
- data/sig/shims/rubygems.rbs +4 -0
- data/sig/type_alias_dependency.rbs +31 -0
- data/sig/type_alias_regularity.rbs +6 -0
- data/sig/validator.rbs +2 -2
- data/sig/variance_calculator.rbs +2 -0
- metadata +3 -3
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 7b7971d4b64c169d220fe2c0895630a36ebc6505b68689fba0660be24bcd24c0
|
|
4
|
+
data.tar.gz: 2f6b8a68c5817d25c3ba179eb3965751f0b406c7dcf2d0812fe41d96bbac6e7c
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 4647a2dce17379807dae65a355d0fb2174d18062dbeb98d51c0c06f125d19d665ff32e3528c7326925ba11abed838b0ffff35e3708a25931fa1c4ea8c25d5eae
|
|
7
|
+
data.tar.gz: 68e20554c2941971aa99015343ef59768a653ed23fc0d6b59eeb64223dff56e8c0aa61846402f28d5f8f9e5ce33763e116cdf08cb8ca9dcfb07177d1eeab9d68
|
data/CHANGELOG.md
CHANGED
|
@@ -2,6 +2,34 @@
|
|
|
2
2
|
|
|
3
3
|
## master
|
|
4
4
|
|
|
5
|
+
## 3.1.2 (2023-07-27)
|
|
6
|
+
|
|
7
|
+
⚠️ Note that this patch level release may report additional validation errors that is caused by fix of type name resolution ([#1373](https://github.com/ruby/rbs/pull/1373)).
|
|
8
|
+
|
|
9
|
+
### Library changes
|
|
10
|
+
|
|
11
|
+
* Make `TypeNameResolver` more compatible with Ruby ([#1373](https://github.com/ruby/rbs/pull/1373))
|
|
12
|
+
* Fix module alias normalizations ([#1393](https://github.com/ruby/rbs/pull/1393))
|
|
13
|
+
|
|
14
|
+
## 3.1.1 (2023-07-18)
|
|
15
|
+
|
|
16
|
+
### Signature updates
|
|
17
|
+
|
|
18
|
+
* Removed `GC.verify_transient_heap_internal_consistency` ([#1374](https://github.com/ruby/rbs/pull/1374))
|
|
19
|
+
|
|
20
|
+
### Library changes
|
|
21
|
+
|
|
22
|
+
* Relax rdoc version requirement in RDoc plugin ([#1333](https://github.com/ruby/rbs/pull/1333))
|
|
23
|
+
|
|
24
|
+
#### rbs collection
|
|
25
|
+
|
|
26
|
+
* Spec may be missing when rbs_collection.yaml declares dependency ([#1378](https://github.com/ruby/rbs/pull/1378))
|
|
27
|
+
|
|
28
|
+
### Miscellaneous
|
|
29
|
+
|
|
30
|
+
* Handle connection error with Resolv_test.rb ([#1356](https://github.com/ruby/rbs/pull/1356))
|
|
31
|
+
* Fix broken CI ([#1353](https://github.com/ruby/rbs/pull/1353))
|
|
32
|
+
|
|
5
33
|
## 3.1.0 (2023-04-26)
|
|
6
34
|
|
|
7
35
|
### Signature updates
|
data/Gemfile
CHANGED
data/Gemfile.lock
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
PATH
|
|
2
2
|
remote: .
|
|
3
3
|
specs:
|
|
4
|
-
rbs (3.1.
|
|
4
|
+
rbs (3.1.2)
|
|
5
5
|
|
|
6
6
|
PATH
|
|
7
7
|
remote: test/assets/test-gem
|
|
@@ -17,7 +17,7 @@ GEM
|
|
|
17
17
|
dbm (1.1.0)
|
|
18
18
|
debase (0.2.5.beta2)
|
|
19
19
|
debase-ruby_core_source (>= 0.10.12)
|
|
20
|
-
debase-ruby_core_source (3.2.
|
|
20
|
+
debase-ruby_core_source (3.2.1)
|
|
21
21
|
diff-lcs (1.5.0)
|
|
22
22
|
digest (3.1.1)
|
|
23
23
|
forwardable (1.3.2)
|
|
@@ -31,23 +31,25 @@ GEM
|
|
|
31
31
|
addressable (>= 2.8)
|
|
32
32
|
marcel (1.0.2)
|
|
33
33
|
minitest (5.18.0)
|
|
34
|
-
parallel (1.
|
|
35
|
-
parser (3.2.2.
|
|
34
|
+
parallel (1.23.0)
|
|
35
|
+
parser (3.2.2.3)
|
|
36
36
|
ast (~> 2.4.1)
|
|
37
|
-
|
|
37
|
+
racc
|
|
38
|
+
power_assert (2.0.3)
|
|
38
39
|
prime (0.1.2)
|
|
39
40
|
forwardable
|
|
40
41
|
singleton
|
|
41
42
|
psych (4.0.6)
|
|
42
43
|
stringio
|
|
43
44
|
public_suffix (5.0.1)
|
|
45
|
+
racc (1.7.1)
|
|
44
46
|
rainbow (3.1.1)
|
|
45
47
|
rake (13.0.6)
|
|
46
|
-
rake-compiler (1.2.
|
|
48
|
+
rake-compiler (1.2.2)
|
|
47
49
|
rake
|
|
48
50
|
rdoc (6.4.0)
|
|
49
51
|
psych (>= 4.0.0)
|
|
50
|
-
regexp_parser (2.8.
|
|
52
|
+
regexp_parser (2.8.1)
|
|
51
53
|
rexml (3.2.5)
|
|
52
54
|
rspec (3.12.0)
|
|
53
55
|
rspec-core (~> 3.12.0)
|
|
@@ -62,17 +64,17 @@ GEM
|
|
|
62
64
|
diff-lcs (>= 1.2.0, < 2.0)
|
|
63
65
|
rspec-support (~> 3.12.0)
|
|
64
66
|
rspec-support (3.12.0)
|
|
65
|
-
rubocop (1.
|
|
67
|
+
rubocop (1.52.1)
|
|
66
68
|
json (~> 2.3)
|
|
67
69
|
parallel (~> 1.10)
|
|
68
|
-
parser (>= 3.2.
|
|
70
|
+
parser (>= 3.2.2.3)
|
|
69
71
|
rainbow (>= 2.2.2, < 4.0)
|
|
70
72
|
regexp_parser (>= 1.8, < 3.0)
|
|
71
73
|
rexml (>= 3.2.5, < 4.0)
|
|
72
74
|
rubocop-ast (>= 1.28.0, < 2.0)
|
|
73
75
|
ruby-progressbar (~> 1.7)
|
|
74
76
|
unicode-display_width (>= 2.4.0, < 3.0)
|
|
75
|
-
rubocop-ast (1.
|
|
77
|
+
rubocop-ast (1.29.0)
|
|
76
78
|
parser (>= 3.2.1.0)
|
|
77
79
|
rubocop-rubycw (0.1.6)
|
|
78
80
|
rubocop (~> 1.0)
|
|
@@ -81,10 +83,10 @@ GEM
|
|
|
81
83
|
ruby-progressbar (1.13.0)
|
|
82
84
|
singleton (0.1.1)
|
|
83
85
|
stackprof (0.2.25)
|
|
84
|
-
stringio (3.0.
|
|
86
|
+
stringio (3.0.7)
|
|
85
87
|
strong_json (2.1.2)
|
|
86
88
|
tempfile (0.1.3)
|
|
87
|
-
test-unit (3.5.
|
|
89
|
+
test-unit (3.5.9)
|
|
88
90
|
power_assert
|
|
89
91
|
unicode-display_width (2.4.2)
|
|
90
92
|
|
|
@@ -105,7 +107,7 @@ DEPENDENCIES
|
|
|
105
107
|
rake-compiler
|
|
106
108
|
rbs!
|
|
107
109
|
rbs-amber!
|
|
108
|
-
rdoc (
|
|
110
|
+
rdoc (~> 6.4.0)
|
|
109
111
|
rspec
|
|
110
112
|
rubocop
|
|
111
113
|
rubocop-rubycw
|
data/core/file.rbs
CHANGED
|
@@ -1971,67 +1971,171 @@ File::SEPARATOR: String
|
|
|
1971
1971
|
#
|
|
1972
1972
|
File::Separator: String
|
|
1973
1973
|
|
|
1974
|
+
# <!-- rdoc-file=file.c -->
|
|
1975
|
+
# File::Constants provides file-related constants. All possible file constants
|
|
1976
|
+
# are listed in the documentation but they may not all be present on your
|
|
1977
|
+
# platform.
|
|
1978
|
+
#
|
|
1979
|
+
# If the underlying platform doesn't define a constant the corresponding Ruby
|
|
1980
|
+
# constant is not defined.
|
|
1981
|
+
#
|
|
1982
|
+
# Your platform documentations (e.g. man open(2)) may describe more detailed
|
|
1983
|
+
# information.
|
|
1984
|
+
#
|
|
1974
1985
|
module File::Constants
|
|
1975
1986
|
end
|
|
1976
1987
|
|
|
1988
|
+
# <!-- rdoc-file=file.c -->
|
|
1989
|
+
# append on each write
|
|
1990
|
+
#
|
|
1977
1991
|
File::Constants::APPEND: Integer
|
|
1978
1992
|
|
|
1993
|
+
# <!-- rdoc-file=file.c -->
|
|
1994
|
+
# disable line code conversion
|
|
1995
|
+
#
|
|
1979
1996
|
File::Constants::BINARY: Integer
|
|
1980
1997
|
|
|
1998
|
+
# <!-- rdoc-file=file.c -->
|
|
1999
|
+
# create file if it does not exist
|
|
2000
|
+
#
|
|
1981
2001
|
File::Constants::CREAT: Integer
|
|
1982
2002
|
|
|
2003
|
+
# <!-- rdoc-file=file.c -->
|
|
2004
|
+
# Try to minimize cache effects of the I/O to and from this file.
|
|
2005
|
+
#
|
|
1983
2006
|
File::Constants::DIRECT: Integer
|
|
1984
2007
|
|
|
2008
|
+
# <!-- rdoc-file=file.c -->
|
|
2009
|
+
# any write operation perform synchronously except some meta data
|
|
2010
|
+
#
|
|
1985
2011
|
File::Constants::DSYNC: Integer
|
|
1986
2012
|
|
|
2013
|
+
# <!-- rdoc-file=file.c -->
|
|
2014
|
+
# error if CREAT and the file exists
|
|
2015
|
+
#
|
|
1987
2016
|
File::Constants::EXCL: Integer
|
|
1988
2017
|
|
|
2018
|
+
# <!-- rdoc-file=dir.c -->
|
|
2019
|
+
# Makes File.fnmatch patterns case insensitive (but not Dir.glob patterns).
|
|
2020
|
+
#
|
|
1989
2021
|
File::Constants::FNM_CASEFOLD: Integer
|
|
1990
2022
|
|
|
2023
|
+
# <!-- rdoc-file=dir.c -->
|
|
2024
|
+
# The '*' wildcard matches filenames starting with "." in File.fnmatch and
|
|
2025
|
+
# Dir.glob patterns
|
|
2026
|
+
#
|
|
1991
2027
|
File::Constants::FNM_DOTMATCH: Integer
|
|
1992
2028
|
|
|
2029
|
+
# <!-- rdoc-file=dir.c -->
|
|
2030
|
+
# Allows file globbing through "{a,b}" in File.fnmatch patterns.
|
|
2031
|
+
#
|
|
1993
2032
|
File::Constants::FNM_EXTGLOB: Integer
|
|
1994
2033
|
|
|
2034
|
+
# <!-- rdoc-file=dir.c -->
|
|
2035
|
+
# Disables escapes in File.fnmatch and Dir.glob patterns
|
|
2036
|
+
#
|
|
1995
2037
|
File::Constants::FNM_NOESCAPE: Integer
|
|
1996
2038
|
|
|
2039
|
+
# <!-- rdoc-file=dir.c -->
|
|
2040
|
+
# Wildcards in File.fnmatch and Dir.glob patterns do not match directory
|
|
2041
|
+
# separators
|
|
2042
|
+
#
|
|
1997
2043
|
File::Constants::FNM_PATHNAME: Integer
|
|
1998
2044
|
|
|
2045
|
+
# <!-- rdoc-file=dir.c -->
|
|
2046
|
+
# Makes patterns to match short names if existing. Valid only on Microsoft
|
|
2047
|
+
# Windows.
|
|
2048
|
+
#
|
|
1999
2049
|
File::Constants::FNM_SHORTNAME: Integer
|
|
2000
2050
|
|
|
2051
|
+
# <!-- rdoc-file=dir.c -->
|
|
2052
|
+
# System default case insensitiveness, equals to FNM_CASEFOLD or 0.
|
|
2053
|
+
#
|
|
2001
2054
|
File::Constants::FNM_SYSCASE: Integer
|
|
2002
2055
|
|
|
2056
|
+
# <!-- rdoc-file=file.c -->
|
|
2057
|
+
# exclusive lock. see File#flock
|
|
2058
|
+
#
|
|
2003
2059
|
File::Constants::LOCK_EX: Integer
|
|
2004
2060
|
|
|
2061
|
+
# <!-- rdoc-file=file.c -->
|
|
2062
|
+
# non-blocking lock. used with LOCK_SH or LOCK_EX. see File#flock
|
|
2063
|
+
#
|
|
2005
2064
|
File::Constants::LOCK_NB: Integer
|
|
2006
2065
|
|
|
2066
|
+
# <!-- rdoc-file=file.c -->
|
|
2067
|
+
# shared lock. see File#flock
|
|
2068
|
+
#
|
|
2007
2069
|
File::Constants::LOCK_SH: Integer
|
|
2008
2070
|
|
|
2071
|
+
# <!-- rdoc-file=file.c -->
|
|
2072
|
+
# unlock. see File#flock
|
|
2073
|
+
#
|
|
2009
2074
|
File::Constants::LOCK_UN: Integer
|
|
2010
2075
|
|
|
2076
|
+
# <!-- rdoc-file=file.c -->
|
|
2077
|
+
# do not change atime
|
|
2078
|
+
#
|
|
2011
2079
|
File::Constants::NOATIME: Integer
|
|
2012
2080
|
|
|
2081
|
+
# <!-- rdoc-file=file.c -->
|
|
2082
|
+
# not to make opened IO the controlling terminal device
|
|
2083
|
+
#
|
|
2013
2084
|
File::Constants::NOCTTY: Integer
|
|
2014
2085
|
|
|
2086
|
+
# <!-- rdoc-file=file.c -->
|
|
2087
|
+
# do not follow symlinks
|
|
2088
|
+
#
|
|
2015
2089
|
File::Constants::NOFOLLOW: Integer
|
|
2016
2090
|
|
|
2091
|
+
# <!-- rdoc-file=file.c -->
|
|
2092
|
+
# do not block on open or for data to become available
|
|
2093
|
+
#
|
|
2017
2094
|
File::Constants::NONBLOCK: Integer
|
|
2018
2095
|
|
|
2096
|
+
# <!-- rdoc-file=file.c -->
|
|
2097
|
+
# Name of the null device
|
|
2098
|
+
#
|
|
2019
2099
|
File::Constants::NULL: String
|
|
2020
2100
|
|
|
2101
|
+
# <!-- rdoc-file=file.c -->
|
|
2102
|
+
# open for reading only
|
|
2103
|
+
#
|
|
2021
2104
|
File::Constants::RDONLY: Integer
|
|
2022
2105
|
|
|
2106
|
+
# <!-- rdoc-file=file.c -->
|
|
2107
|
+
# open for reading and writing
|
|
2108
|
+
#
|
|
2023
2109
|
File::Constants::RDWR: Integer
|
|
2024
2110
|
|
|
2111
|
+
# <!-- rdoc-file=file.c -->
|
|
2112
|
+
# any read operation perform synchronously. used with SYNC or DSYNC.
|
|
2113
|
+
#
|
|
2025
2114
|
File::Constants::RSYNC: Integer
|
|
2026
2115
|
|
|
2116
|
+
# <!-- rdoc-file=file.c -->
|
|
2117
|
+
# can delete opened file
|
|
2118
|
+
#
|
|
2027
2119
|
File::Constants::SHARE_DELETE: Integer
|
|
2028
2120
|
|
|
2121
|
+
# <!-- rdoc-file=file.c -->
|
|
2122
|
+
# any write operation perform synchronously
|
|
2123
|
+
#
|
|
2029
2124
|
File::Constants::SYNC: Integer
|
|
2030
2125
|
|
|
2126
|
+
# <!-- rdoc-file=file.c -->
|
|
2127
|
+
# Create an unnamed temporary file
|
|
2128
|
+
#
|
|
2031
2129
|
File::Constants::TMPFILE: Integer
|
|
2032
2130
|
|
|
2131
|
+
# <!-- rdoc-file=file.c -->
|
|
2132
|
+
# truncate size to 0
|
|
2133
|
+
#
|
|
2033
2134
|
File::Constants::TRUNC: Integer
|
|
2034
2135
|
|
|
2136
|
+
# <!-- rdoc-file=file.c -->
|
|
2137
|
+
# open for writing only
|
|
2138
|
+
#
|
|
2035
2139
|
File::Constants::WRONLY: Integer
|
|
2036
2140
|
|
|
2037
2141
|
# <!-- rdoc-file=file.c -->
|
data/core/gc.rbs
CHANGED
|
@@ -234,13 +234,6 @@ module GC
|
|
|
234
234
|
#
|
|
235
235
|
def self.verify_internal_consistency: () -> nil
|
|
236
236
|
|
|
237
|
-
# <!--
|
|
238
|
-
# rdoc-file=gc.c
|
|
239
|
-
# - verify_transient_heap_internal_consistency()
|
|
240
|
-
# -->
|
|
241
|
-
#
|
|
242
|
-
def self.verify_transient_heap_internal_consistency: () -> nil
|
|
243
|
-
|
|
244
237
|
# <!--
|
|
245
238
|
# rdoc-file=gc.rb
|
|
246
239
|
# - GC.latest_gc_info -> hash
|
data/core/process.rbs
CHANGED
|
@@ -133,10 +133,14 @@ module RBS
|
|
|
133
133
|
end
|
|
134
134
|
end
|
|
135
135
|
|
|
136
|
-
gem_hash
|
|
137
|
-
|
|
138
|
-
|
|
136
|
+
if spec = gem_hash.fetch(name, nil)
|
|
137
|
+
spec.dependencies.each do |dep|
|
|
138
|
+
if dep_spec = gem_hash[dep.name]
|
|
139
|
+
assign_gem(name: dep.name, version: dep_spec.version, src_data: nil, ignored_gems: ignored_gems)
|
|
140
|
+
end
|
|
139
141
|
end
|
|
142
|
+
else
|
|
143
|
+
RBS.logger.warn "Cannot find `#{name}` gem. Using incorrect Bundler context? (#{definition.lockfile})"
|
|
140
144
|
end
|
|
141
145
|
end
|
|
142
146
|
|
|
@@ -753,12 +753,14 @@ module RBS
|
|
|
753
753
|
end
|
|
754
754
|
|
|
755
755
|
def expand_alias1(type_name)
|
|
756
|
+
type_name = env.normalize_type_name(type_name)
|
|
756
757
|
entry = env.type_alias_decls[type_name] or raise "Unknown alias name: #{type_name}"
|
|
757
758
|
as = entry.decl.type_params.each.map { Types::Bases::Any.new(location: nil) }
|
|
758
759
|
expand_alias2(type_name, as)
|
|
759
760
|
end
|
|
760
761
|
|
|
761
762
|
def expand_alias2(type_name, args)
|
|
763
|
+
type_name = env.normalize_type_name(type_name)
|
|
762
764
|
entry = env.type_alias_decls[type_name] or raise "Unknown alias name: #{type_name}"
|
|
763
765
|
|
|
764
766
|
ensure_namespace!(type_name.namespace, location: entry.decl.location)
|
|
@@ -811,9 +813,8 @@ module RBS
|
|
|
811
813
|
end
|
|
812
814
|
|
|
813
815
|
def validate_type_name(name, location)
|
|
814
|
-
name = name.absolute!
|
|
815
|
-
|
|
816
|
-
return if env.type_name?(name)
|
|
816
|
+
name = name.absolute! unless name.absolute?
|
|
817
|
+
return if env.type_name?(env.normalize_type_name(name))
|
|
817
818
|
|
|
818
819
|
raise NoTypeFoundError.new(type_name: name, location: location)
|
|
819
820
|
end
|
data/lib/rbs/environment.rb
CHANGED
|
@@ -275,53 +275,96 @@ module RBS
|
|
|
275
275
|
class_entry(type_name) || module_entry(type_name) || constant_decls[type_name]
|
|
276
276
|
end
|
|
277
277
|
|
|
278
|
+
def normalize_type_name?(name)
|
|
279
|
+
if name.class?
|
|
280
|
+
normalize_module_name?(name)
|
|
281
|
+
else
|
|
282
|
+
unless name.namespace.empty?
|
|
283
|
+
parent = name.namespace.to_type_name
|
|
284
|
+
parent = normalize_module_name?(parent)
|
|
285
|
+
return parent unless parent
|
|
286
|
+
|
|
287
|
+
TypeName.new(namespace: parent.to_namespace, name: name.name)
|
|
288
|
+
else
|
|
289
|
+
name
|
|
290
|
+
end
|
|
291
|
+
end
|
|
292
|
+
end
|
|
293
|
+
|
|
294
|
+
def normalize_type_name!(name)
|
|
295
|
+
result = normalize_type_name?(name)
|
|
296
|
+
|
|
297
|
+
case result
|
|
298
|
+
when TypeName
|
|
299
|
+
result
|
|
300
|
+
when false
|
|
301
|
+
raise "Type name `#{name}` cannot be normalized because it's a cyclic definition"
|
|
302
|
+
when nil
|
|
303
|
+
raise "Type name `#{name}` cannot be normalized because of unknown type name in the path"
|
|
304
|
+
end
|
|
305
|
+
end
|
|
306
|
+
|
|
307
|
+
def normalized_type_name?(type_name)
|
|
308
|
+
case
|
|
309
|
+
when type_name.interface?
|
|
310
|
+
interface_decls.key?(type_name)
|
|
311
|
+
when type_name.class?
|
|
312
|
+
class_decls.key?(type_name)
|
|
313
|
+
when type_name.alias?
|
|
314
|
+
type_alias_decls.key?(type_name)
|
|
315
|
+
else
|
|
316
|
+
false
|
|
317
|
+
end
|
|
318
|
+
end
|
|
319
|
+
|
|
320
|
+
def normalized_type_name!(name)
|
|
321
|
+
normalized_type_name?(name) or raise "Normalized type name is expected but given `#{name}`, which is normalized to `#{normalize_type_name?(name)}`"
|
|
322
|
+
name
|
|
323
|
+
end
|
|
324
|
+
|
|
325
|
+
def normalize_type_name(name)
|
|
326
|
+
normalize_type_name?(name) || name
|
|
327
|
+
end
|
|
328
|
+
|
|
278
329
|
def normalize_module_name(name)
|
|
279
330
|
normalize_module_name?(name) or name
|
|
280
331
|
end
|
|
281
332
|
|
|
282
333
|
def normalize_module_name?(name)
|
|
283
334
|
raise "Class/module name is expected: #{name}" unless name.class?
|
|
284
|
-
name = name.absolute!
|
|
335
|
+
name = name.absolute! unless name.absolute?
|
|
285
336
|
|
|
286
337
|
if @normalize_module_name_cache.key?(name)
|
|
287
338
|
return @normalize_module_name_cache[name]
|
|
288
339
|
end
|
|
289
340
|
|
|
341
|
+
unless name.namespace.empty?
|
|
342
|
+
parent = name.namespace.to_type_name
|
|
343
|
+
if normalized_parent = normalize_module_name?(parent)
|
|
344
|
+
type_name = TypeName.new(namespace: normalized_parent.to_namespace, name: name.name)
|
|
345
|
+
else
|
|
346
|
+
@normalize_module_name_cache[name] = nil
|
|
347
|
+
return
|
|
348
|
+
end
|
|
349
|
+
else
|
|
350
|
+
type_name = name
|
|
351
|
+
end
|
|
352
|
+
|
|
290
353
|
@normalize_module_name_cache[name] = false
|
|
291
354
|
|
|
292
|
-
entry = constant_entry(
|
|
293
|
-
case entry
|
|
294
|
-
when ClassEntry, ModuleEntry
|
|
295
|
-
@normalize_module_name_cache[name] = entry.name
|
|
296
|
-
entry.name
|
|
355
|
+
entry = constant_entry(type_name)
|
|
297
356
|
|
|
298
|
-
|
|
299
|
-
|
|
300
|
-
|
|
301
|
-
|
|
357
|
+
normalized_type_name =
|
|
358
|
+
case entry
|
|
359
|
+
when ClassEntry, ModuleEntry
|
|
360
|
+
type_name
|
|
361
|
+
when ClassAliasEntry, ModuleAliasEntry
|
|
362
|
+
normalize_module_name?(entry.decl.old_name)
|
|
302
363
|
else
|
|
303
|
-
|
|
304
|
-
|
|
305
|
-
if normalized_parent = normalize_module_name?(parent)
|
|
306
|
-
@normalize_module_name_cache[name] =
|
|
307
|
-
if normalized_parent == parent
|
|
308
|
-
normalize_module_name?(old_name)
|
|
309
|
-
else
|
|
310
|
-
normalize_module_name?(
|
|
311
|
-
TypeName.new(name: old_name.name, namespace: normalized_parent.to_namespace)
|
|
312
|
-
)
|
|
313
|
-
end
|
|
314
|
-
else
|
|
315
|
-
@normalize_module_name_cache[name] = nil
|
|
316
|
-
end
|
|
364
|
+
nil
|
|
317
365
|
end
|
|
318
366
|
|
|
319
|
-
|
|
320
|
-
raise "#{name} is a constant name"
|
|
321
|
-
|
|
322
|
-
else
|
|
323
|
-
@normalize_module_name_cache[name] = nil
|
|
324
|
-
end
|
|
367
|
+
@normalize_module_name_cache[name] = normalized_type_name
|
|
325
368
|
end
|
|
326
369
|
|
|
327
370
|
def insert_decl(decl, outer:, namespace:)
|
data/lib/rbs/errors.rb
CHANGED
|
@@ -185,7 +185,8 @@ module RBS
|
|
|
185
185
|
end
|
|
186
186
|
|
|
187
187
|
def self.check!(super_decl, env:)
|
|
188
|
-
|
|
188
|
+
super_name = env.normalize_type_name(super_decl.name)
|
|
189
|
+
return if env.class_decl?(super_name) || env.class_alias?(super_name)
|
|
189
190
|
|
|
190
191
|
raise new(super_decl)
|
|
191
192
|
end
|
|
@@ -205,9 +206,8 @@ module RBS
|
|
|
205
206
|
end
|
|
206
207
|
|
|
207
208
|
def self.check!(self_type, env:)
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
(env.module_name?(type_name) || env.interface_name?(type_name)) or raise new(type_name: type_name, location: self_type.location)
|
|
209
|
+
self_name = env.normalize_type_name(self_type.name)
|
|
210
|
+
(env.module_name?(self_name) || env.interface_name?(self_name)) or raise new(type_name: self_type.name, location: self_type.location)
|
|
211
211
|
end
|
|
212
212
|
end
|
|
213
213
|
|
|
@@ -5,10 +5,12 @@ module RBS
|
|
|
5
5
|
class TypeNameResolver
|
|
6
6
|
attr_reader :all_names
|
|
7
7
|
attr_reader :cache
|
|
8
|
+
attr_reader :env
|
|
8
9
|
|
|
9
10
|
def initialize(env)
|
|
10
11
|
@all_names = Set[]
|
|
11
12
|
@cache = {}
|
|
13
|
+
@env = env
|
|
12
14
|
|
|
13
15
|
all_names.merge(env.class_decls.keys)
|
|
14
16
|
all_names.merge(env.interface_decls.keys)
|
|
@@ -29,22 +31,53 @@ module RBS
|
|
|
29
31
|
end
|
|
30
32
|
|
|
31
33
|
try_cache([type_name, context]) do
|
|
32
|
-
|
|
34
|
+
head, tail = partition(type_name)
|
|
35
|
+
|
|
36
|
+
head = resolve_in(head, context)
|
|
37
|
+
|
|
38
|
+
if head
|
|
39
|
+
if tail
|
|
40
|
+
absolute_name = tail.with_prefix(head.to_namespace)
|
|
41
|
+
if env.normalize_type_name?(absolute_name)
|
|
42
|
+
absolute_name
|
|
43
|
+
end
|
|
44
|
+
else
|
|
45
|
+
head
|
|
46
|
+
end
|
|
47
|
+
end
|
|
48
|
+
end
|
|
49
|
+
end
|
|
50
|
+
|
|
51
|
+
def partition(type_name)
|
|
52
|
+
if type_name.namespace.empty?
|
|
53
|
+
head = type_name.name
|
|
54
|
+
tail = nil
|
|
55
|
+
else
|
|
56
|
+
head, *tail = type_name.namespace.path
|
|
57
|
+
|
|
58
|
+
head or raise
|
|
59
|
+
|
|
60
|
+
tail = TypeName.new(
|
|
61
|
+
name: type_name.name,
|
|
62
|
+
namespace: Namespace.new(absolute: false, path: tail)
|
|
63
|
+
)
|
|
33
64
|
end
|
|
65
|
+
|
|
66
|
+
[head, tail]
|
|
34
67
|
end
|
|
35
68
|
|
|
36
|
-
def resolve_in(
|
|
69
|
+
def resolve_in(head, context)
|
|
37
70
|
if context
|
|
38
71
|
parent, child = context
|
|
39
72
|
case child
|
|
40
73
|
when false
|
|
41
|
-
resolve_in(
|
|
74
|
+
resolve_in(head, parent)
|
|
42
75
|
when TypeName
|
|
43
|
-
name =
|
|
44
|
-
has_name?(name) || resolve_in(
|
|
76
|
+
name = TypeName.new(name: head, namespace: child.to_namespace)
|
|
77
|
+
has_name?(name) || resolve_in(head, parent)
|
|
45
78
|
end
|
|
46
79
|
else
|
|
47
|
-
has_name?(
|
|
80
|
+
has_name?(TypeName.new(name: head, namespace: Namespace.root))
|
|
48
81
|
end
|
|
49
82
|
end
|
|
50
83
|
|
|
@@ -20,7 +20,7 @@ module RBS
|
|
|
20
20
|
# Construct transitive closure, if not constructed already
|
|
21
21
|
transitive_closure() unless @dependencies
|
|
22
22
|
|
|
23
|
-
|
|
23
|
+
alias_name = env.normalize_type_name!(alias_name)
|
|
24
24
|
@dependencies[alias_name][alias_name]
|
|
25
25
|
end
|
|
26
26
|
|
|
@@ -49,6 +49,16 @@ module RBS
|
|
|
49
49
|
end
|
|
50
50
|
end
|
|
51
51
|
|
|
52
|
+
def direct_dependencies_of(name)
|
|
53
|
+
name = env.normalize_type_name!(name)
|
|
54
|
+
@direct_dependencies[name]
|
|
55
|
+
end
|
|
56
|
+
|
|
57
|
+
def dependencies_of(name)
|
|
58
|
+
name = env.normalize_type_name!(name)
|
|
59
|
+
@dependencies[name].each_key.to_set
|
|
60
|
+
end
|
|
61
|
+
|
|
52
62
|
private
|
|
53
63
|
|
|
54
64
|
# Constructs directed graph recursively
|
|
@@ -61,7 +71,7 @@ module RBS
|
|
|
61
71
|
end
|
|
62
72
|
when RBS::Types::Alias
|
|
63
73
|
# Append type name if the type is an alias
|
|
64
|
-
result << type.name
|
|
74
|
+
result << env.normalize_type_name(type.name)
|
|
65
75
|
end
|
|
66
76
|
|
|
67
77
|
result
|
|
@@ -37,10 +37,12 @@ module RBS
|
|
|
37
37
|
end
|
|
38
38
|
|
|
39
39
|
def validate_alias_type(alias_type, names, types)
|
|
40
|
-
|
|
41
|
-
|
|
40
|
+
alias_name = env.normalize_type_name?(alias_type.name) or return
|
|
41
|
+
|
|
42
|
+
if names.include?(alias_name)
|
|
43
|
+
if ex_type = types[alias_name]
|
|
42
44
|
unless compatible_args?(ex_type.args, alias_type.args)
|
|
43
|
-
diagnostics[
|
|
45
|
+
diagnostics[alias_name] ||=
|
|
44
46
|
Diagnostic.new(type_name: alias_type.name, nonregular_type: alias_type)
|
|
45
47
|
end
|
|
46
48
|
|
|
@@ -49,7 +51,7 @@ module RBS
|
|
|
49
51
|
types[alias_type.name] = alias_type
|
|
50
52
|
end
|
|
51
53
|
|
|
52
|
-
expanded = builder.expand_alias2(
|
|
54
|
+
expanded = builder.expand_alias2(alias_name, alias_type.args)
|
|
53
55
|
each_alias_type(expanded) do |at|
|
|
54
56
|
validate_alias_type(at, names, types)
|
|
55
57
|
end
|
|
@@ -75,22 +77,27 @@ module RBS
|
|
|
75
77
|
end
|
|
76
78
|
|
|
77
79
|
def nonregular?(type_name)
|
|
78
|
-
diagnostics[type_name]
|
|
80
|
+
diagnostics[env.normalize_type_name!(type_name)]
|
|
79
81
|
end
|
|
80
82
|
|
|
81
83
|
def each_mutual_alias_defs(&block)
|
|
82
|
-
# @type var each_node:
|
|
83
|
-
each_node =
|
|
84
|
+
# @type var each_node: ^() { (TypeName) -> void } -> void
|
|
85
|
+
each_node = -> (&block) do
|
|
84
86
|
env.type_alias_decls.each_value do |decl|
|
|
85
|
-
|
|
87
|
+
if normalized = env.normalize_type_name?(decl.name)
|
|
88
|
+
block[normalized]
|
|
89
|
+
end
|
|
86
90
|
end
|
|
87
91
|
end
|
|
88
|
-
|
|
89
|
-
each_child
|
|
92
|
+
|
|
93
|
+
# @type var each_child: ^(TypeName) { (TypeName) -> void } -> void
|
|
94
|
+
each_child = -> (name, &block) do
|
|
90
95
|
if env.type_alias_decls.key?(name)
|
|
91
96
|
type = builder.expand_alias1(name)
|
|
92
97
|
each_alias_type(type) do |ty|
|
|
93
|
-
|
|
98
|
+
if normalized = env.normalize_type_name?(ty.name)
|
|
99
|
+
block[normalized]
|
|
100
|
+
end
|
|
94
101
|
end
|
|
95
102
|
end
|
|
96
103
|
end
|
data/lib/rbs/validator.rb
CHANGED
|
@@ -12,9 +12,9 @@ module RBS
|
|
|
12
12
|
@definition_builder = DefinitionBuilder.new(env: env)
|
|
13
13
|
end
|
|
14
14
|
|
|
15
|
-
def absolute_type(type, context
|
|
15
|
+
def absolute_type(type, context:, &block)
|
|
16
16
|
type.map_type_name do |type_name, _, type|
|
|
17
|
-
resolver.resolve(type_name, context: context) || yield(type)
|
|
17
|
+
resolver.resolve(type_name, context: context) || (block ? yield(type) : type_name)
|
|
18
18
|
end
|
|
19
19
|
end
|
|
20
20
|
|
|
@@ -22,33 +22,34 @@ module RBS
|
|
|
22
22
|
def validate_type(type, context:)
|
|
23
23
|
case type
|
|
24
24
|
when Types::ClassInstance, Types::Interface, Types::Alias
|
|
25
|
-
|
|
26
|
-
if type.name.namespace.relative?
|
|
27
|
-
type = _ = absolute_type(type, context: context) do |_|
|
|
28
|
-
NoTypeFoundError.check!(type.name.absolute!, env: env, location: type.location)
|
|
29
|
-
end
|
|
30
|
-
end
|
|
25
|
+
type = absolute_type(type, context: context) #: Types::ClassInstance | Types::Interface | Types::Alias
|
|
31
26
|
|
|
32
27
|
definition_builder.validate_type_name(type.name, type.location)
|
|
33
28
|
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
29
|
+
normalized_type_name = env.normalize_type_name?(type.name)
|
|
30
|
+
|
|
31
|
+
if normalized_type_name
|
|
32
|
+
type_params =
|
|
33
|
+
case type
|
|
34
|
+
when Types::ClassInstance
|
|
35
|
+
entry = env.class_decls[normalized_type_name] or raise
|
|
36
|
+
entry.type_params
|
|
37
|
+
when Types::Interface
|
|
38
|
+
env.interface_decls[normalized_type_name].decl.type_params
|
|
39
|
+
when Types::Alias
|
|
40
|
+
env.type_alias_decls[normalized_type_name].decl.type_params
|
|
41
|
+
end
|
|
42
|
+
|
|
43
|
+
InvalidTypeApplicationError.check!(
|
|
44
|
+
type_name: type.name,
|
|
45
|
+
args: type.args,
|
|
46
|
+
params: type_params.each.map(&:name),
|
|
47
|
+
location: type.location
|
|
48
|
+
)
|
|
49
|
+
end
|
|
50
50
|
|
|
51
51
|
when Types::ClassSingleton
|
|
52
|
+
type = absolute_type(type, context: context) #: Types::ClassSingleton
|
|
52
53
|
definition_builder.validate_type_presence(type)
|
|
53
54
|
end
|
|
54
55
|
|
|
@@ -115,14 +116,14 @@ module RBS
|
|
|
115
116
|
end
|
|
116
117
|
|
|
117
118
|
def validate_type_params(params, type_name: , method_name: nil, location:)
|
|
118
|
-
# @type var each_node:
|
|
119
|
-
each_node =
|
|
119
|
+
# @type var each_node: ^() { (Symbol) -> void } -> void
|
|
120
|
+
each_node = -> (&block) do
|
|
120
121
|
params.each do |param|
|
|
121
122
|
block[param.name]
|
|
122
123
|
end
|
|
123
124
|
end
|
|
124
|
-
# @type var each_child:
|
|
125
|
-
each_child =
|
|
125
|
+
# @type var each_child: ^(Symbol) { (Symbol) -> void } -> void
|
|
126
|
+
each_child = -> (name, &block) do
|
|
126
127
|
if param = params.find {|p| p.name == name }
|
|
127
128
|
if b = param.upper_bound
|
|
128
129
|
b.free_variables.each do |tv|
|
|
@@ -108,8 +108,11 @@ module RBS
|
|
|
108
108
|
end
|
|
109
109
|
|
|
110
110
|
def in_type_alias(name:)
|
|
111
|
+
env.normalized_type_name!(name)
|
|
112
|
+
|
|
111
113
|
decl = env.type_alias_decls[name].decl or raise
|
|
112
114
|
variables = decl.type_params.each.map(&:name)
|
|
115
|
+
|
|
113
116
|
Result.new(variables: variables).tap do |result|
|
|
114
117
|
type(decl.type, result: result, context: :covariant)
|
|
115
118
|
end
|
|
@@ -129,30 +132,30 @@ module RBS
|
|
|
129
132
|
end
|
|
130
133
|
end
|
|
131
134
|
when Types::ClassInstance, Types::Interface, Types::Alias
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
when :contravariant
|
|
153
|
-
type(ty, result: result, context: negate(context))
|
|
135
|
+
if type_name = env.normalize_type_name?(type.name)
|
|
136
|
+
type_params = case type
|
|
137
|
+
when Types::ClassInstance
|
|
138
|
+
env.class_decls[type_name].type_params
|
|
139
|
+
when Types::Interface
|
|
140
|
+
env.interface_decls[type_name].decl.type_params
|
|
141
|
+
when Types::Alias
|
|
142
|
+
env.type_alias_decls[type_name].decl.type_params
|
|
143
|
+
end
|
|
144
|
+
|
|
145
|
+
type.args.each.with_index do |ty, i|
|
|
146
|
+
if var = type_params[i]
|
|
147
|
+
case var.variance
|
|
148
|
+
when :invariant
|
|
149
|
+
type(ty, result: result, context: :invariant)
|
|
150
|
+
when :covariant
|
|
151
|
+
type(ty, result: result, context: context)
|
|
152
|
+
when :contravariant
|
|
153
|
+
type(ty, result: result, context: negate(context))
|
|
154
|
+
end
|
|
154
155
|
end
|
|
155
156
|
end
|
|
157
|
+
else
|
|
158
|
+
raise NoTypeFoundError.new(type_name: type.name, location: type.location)
|
|
156
159
|
end
|
|
157
160
|
when Types::Proc
|
|
158
161
|
function(type.type, result: result, context: context)
|
data/lib/rbs/version.rb
CHANGED
data/lib/rdoc/discover.rb
CHANGED
data/sig/definition_builder.rbs
CHANGED
|
@@ -71,12 +71,16 @@ module RBS
|
|
|
71
71
|
# Assumes the type names are already resolved.
|
|
72
72
|
# Raises NoTypeFoundError in case of failure.
|
|
73
73
|
#
|
|
74
|
+
# Normalizes type names in the given type automatically.
|
|
75
|
+
#
|
|
74
76
|
def validate_type_presence: (Types::t) -> void
|
|
75
77
|
|
|
76
78
|
# Validates presence of an absolute type name
|
|
77
79
|
#
|
|
78
80
|
# Raises NoTypeFoundError in case of error.
|
|
79
81
|
#
|
|
82
|
+
# Normalizes the given type name automatically.
|
|
83
|
+
#
|
|
80
84
|
def validate_type_name: (TypeName, Location[untyped, untyped]?) -> void
|
|
81
85
|
|
|
82
86
|
# Returns a new DefinitionBuilder with updated Environment, AncestorBuilder, and exceptions
|
data/sig/environment.rbs
CHANGED
|
@@ -224,6 +224,33 @@ module RBS
|
|
|
224
224
|
#
|
|
225
225
|
def normalize_module_name: (TypeName) -> TypeName
|
|
226
226
|
|
|
227
|
+
# Returns a normalized module/class name or a type name with a normalized namespace
|
|
228
|
+
#
|
|
229
|
+
# * Calls `#absolute!` for relative module names
|
|
230
|
+
# * Returns `nil` if the typename cannot be found
|
|
231
|
+
# * Returns `false` if the name is cyclic
|
|
232
|
+
#
|
|
233
|
+
def normalize_type_name?: (TypeName) -> (TypeName | nil | false)
|
|
234
|
+
|
|
235
|
+
# Normalize the type name or raises an error
|
|
236
|
+
#
|
|
237
|
+
def normalize_type_name!: (TypeName) -> TypeName
|
|
238
|
+
|
|
239
|
+
# Returns a normalized module/class name or a type name with a normalized namespace
|
|
240
|
+
#
|
|
241
|
+
# * Calls `#absolute!` for relative module names
|
|
242
|
+
# * Returns the typename itself if the name cannot be normalized
|
|
243
|
+
#
|
|
244
|
+
def normalize_type_name: (TypeName) -> TypeName
|
|
245
|
+
|
|
246
|
+
# Returns `true` if given type name is normalized
|
|
247
|
+
#
|
|
248
|
+
def normalized_type_name?: (TypeName) -> bool
|
|
249
|
+
|
|
250
|
+
# Returns the given type name if it's normalized, or raises
|
|
251
|
+
#
|
|
252
|
+
def normalized_type_name!: (TypeName) -> TypeName
|
|
253
|
+
|
|
227
254
|
# Runs generics type params validation over each class definitions
|
|
228
255
|
def validate_type_params: () -> void
|
|
229
256
|
|
data/sig/errors.rbs
CHANGED
|
@@ -90,6 +90,8 @@ module RBS
|
|
|
90
90
|
|
|
91
91
|
def initialize: (type_name: TypeName, location: Location[untyped, untyped]?) -> void
|
|
92
92
|
|
|
93
|
+
# The type name in `self` is automatically normalized
|
|
94
|
+
#
|
|
93
95
|
def self.check!: (AST::Declarations::Module::Self, env: Environment) -> void
|
|
94
96
|
end
|
|
95
97
|
|
|
@@ -244,6 +246,10 @@ module RBS
|
|
|
244
246
|
|
|
245
247
|
def location: () -> Location[untyped, untyped]?
|
|
246
248
|
|
|
249
|
+
# Confirms if `super` inherits specifies a class
|
|
250
|
+
#
|
|
251
|
+
# Automatically normalize the name of super.
|
|
252
|
+
#
|
|
247
253
|
def self.check!: (AST::Declarations::Class::Super, env: Environment) -> void
|
|
248
254
|
end
|
|
249
255
|
|
|
@@ -17,6 +17,8 @@ module RBS
|
|
|
17
17
|
|
|
18
18
|
private
|
|
19
19
|
|
|
20
|
+
attr_reader env: Environment
|
|
21
|
+
|
|
20
22
|
attr_reader all_names: Set[TypeName]
|
|
21
23
|
|
|
22
24
|
attr_reader cache: Hash[query, TypeName?]
|
|
@@ -25,7 +27,9 @@ module RBS
|
|
|
25
27
|
|
|
26
28
|
def try_cache: (query) { () -> TypeName? } -> TypeName?
|
|
27
29
|
|
|
28
|
-
def resolve_in: (
|
|
30
|
+
def resolve_in: (Symbol, context) -> TypeName?
|
|
31
|
+
|
|
32
|
+
def partition: (TypeName) -> [Symbol, TypeName?]
|
|
29
33
|
end
|
|
30
34
|
end
|
|
31
35
|
end
|
data/sig/shims/rubygems.rbs
CHANGED
|
@@ -1,14 +1,45 @@
|
|
|
1
1
|
module RBS
|
|
2
|
+
# TypeAliasDependency calculates the dependnecies between type aliases
|
|
3
|
+
#
|
|
4
|
+
# The dependencies are normalized automatically.
|
|
5
|
+
#
|
|
2
6
|
class TypeAliasDependency
|
|
3
7
|
attr_reader env: Environment
|
|
4
8
|
|
|
9
|
+
# A hash table from type alias name to it's direct dependencies
|
|
10
|
+
#
|
|
11
|
+
# The source type name and dependencies are normalized.
|
|
12
|
+
#
|
|
5
13
|
attr_reader direct_dependencies: Hash[TypeName, Set[TypeName]]
|
|
14
|
+
|
|
15
|
+
# A hash table from type alias name to a hash name with keys of transitive dependnecies
|
|
16
|
+
#
|
|
17
|
+
# The source type name and dependencies are normalized.
|
|
18
|
+
#
|
|
6
19
|
attr_reader dependencies: Hash[TypeName, Hash[TypeName, bool]]
|
|
7
20
|
|
|
8
21
|
def initialize: (env: Environment) -> void
|
|
9
22
|
|
|
23
|
+
# Returns `true` if given type alias is circular
|
|
24
|
+
#
|
|
25
|
+
# Normalized given type name automatically.
|
|
26
|
+
#
|
|
10
27
|
def circular_definition?: (TypeName alias_name) -> bool
|
|
11
28
|
|
|
29
|
+
# Returns the set of direct dependencies from the given type name
|
|
30
|
+
#
|
|
31
|
+
# Given type name will be normalized automatically.
|
|
32
|
+
# Returns normalized type names.
|
|
33
|
+
#
|
|
34
|
+
def direct_dependencies_of: (TypeName) -> Set[TypeName]
|
|
35
|
+
|
|
36
|
+
# Returns the set of dependencies from the given type name
|
|
37
|
+
#
|
|
38
|
+
# Given type name will be normalized automatically.
|
|
39
|
+
# Returns normalized type names.
|
|
40
|
+
#
|
|
41
|
+
def dependencies_of: (TypeName) -> Set[TypeName]
|
|
42
|
+
|
|
12
43
|
def build_dependencies: () -> void
|
|
13
44
|
|
|
14
45
|
def transitive_closure: () -> void
|
|
@@ -36,6 +36,9 @@ module RBS
|
|
|
36
36
|
|
|
37
37
|
attr_reader builder: DefinitionBuilder
|
|
38
38
|
|
|
39
|
+
# Diagnostics of each type aliases.
|
|
40
|
+
# The type names are normalized.
|
|
41
|
+
#
|
|
39
42
|
attr_reader diagnostics: Hash[TypeName, Diagnostic]
|
|
40
43
|
|
|
41
44
|
# `Diagnostic` represents an non-regular type alias declaration error.
|
|
@@ -70,6 +73,8 @@ module RBS
|
|
|
70
73
|
# Returns `Diagnostic` instance if the alias type is nonregular.
|
|
71
74
|
# Regurns `nil` if the alias type is regular.
|
|
72
75
|
#
|
|
76
|
+
# Normalizes the given type name automatically.
|
|
77
|
+
#
|
|
73
78
|
def nonregular?: (TypeName) -> Diagnostic?
|
|
74
79
|
|
|
75
80
|
def validate: () -> void
|
|
@@ -87,6 +92,7 @@ module RBS
|
|
|
87
92
|
|
|
88
93
|
def each_alias_type: (Types::t) { (Types::Alias) -> void } -> void
|
|
89
94
|
|
|
95
|
+
# Yields set of normalized type names
|
|
90
96
|
def each_mutual_alias_defs: () { (Set[TypeName]) -> void } -> void
|
|
91
97
|
end
|
|
92
98
|
end
|
data/sig/validator.rbs
CHANGED
|
@@ -46,7 +46,7 @@ module RBS
|
|
|
46
46
|
#
|
|
47
47
|
# - The right hand side can be normalized
|
|
48
48
|
# - No mixing alias declaration between class and modules
|
|
49
|
-
#
|
|
49
|
+
#
|
|
50
50
|
def validate_class_alias: (entry: Environment::ClassAliasEntry | Environment::ModuleAliasEntry) -> void
|
|
51
51
|
|
|
52
52
|
private
|
|
@@ -54,6 +54,6 @@ module RBS
|
|
|
54
54
|
# Resolves relative type names to absolute type names in given context.
|
|
55
55
|
# Yields the type when the type name resolution using `#resolver` fails.
|
|
56
56
|
#
|
|
57
|
-
def absolute_type: (Types::t, context: Resolver::context) { (Types::t) -> TypeName } -> Types::t
|
|
57
|
+
def absolute_type: (Types::t, context: Resolver::context) ?{ (Types::t) -> TypeName } -> Types::t
|
|
58
58
|
end
|
|
59
59
|
end
|
data/sig/variance_calculator.rbs
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: 3.1.
|
|
4
|
+
version: 3.1.2
|
|
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-
|
|
11
|
+
date: 2023-07-27 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.
|
|
@@ -451,7 +451,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
|
451
451
|
- !ruby/object:Gem::Version
|
|
452
452
|
version: '0'
|
|
453
453
|
requirements: []
|
|
454
|
-
rubygems_version: 3.4.
|
|
454
|
+
rubygems_version: 3.4.10
|
|
455
455
|
signing_key:
|
|
456
456
|
specification_version: 4
|
|
457
457
|
summary: Type signature for Ruby.
|