rbs 1.8.0 → 2.0.0
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 +82 -4
- data/docs/collection.md +23 -1
- data/docs/syntax.md +94 -41
- data/ext/rbs_extension/constants.c +2 -6
- data/ext/rbs_extension/constants.h +1 -2
- data/ext/rbs_extension/parser.c +212 -178
- data/ext/rbs_extension/parserstate.c +6 -2
- data/ext/rbs_extension/parserstate.h +10 -0
- data/ext/rbs_extension/ruby_objs.c +9 -11
- data/ext/rbs_extension/ruby_objs.h +1 -2
- data/lib/rbs/ast/declarations.rb +0 -97
- data/lib/rbs/ast/type_param.rb +134 -0
- data/lib/rbs/cli.rb +32 -4
- data/lib/rbs/collection/config/lockfile_generator.rb +26 -18
- data/lib/rbs/collection/sources/git.rb +18 -7
- data/lib/rbs/collection/sources/rubygems.rb +7 -0
- data/lib/rbs/collection/sources/stdlib.rb +6 -0
- data/lib/rbs/definition.rb +9 -0
- data/lib/rbs/definition_builder.rb +49 -14
- data/lib/rbs/environment.rb +32 -9
- data/lib/rbs/environment_loader.rb +0 -2
- data/lib/rbs/errors.rb +20 -7
- data/lib/rbs/location_aux.rb +2 -0
- data/lib/rbs/method_type.rb +29 -6
- data/lib/rbs/prototype/rb.rb +3 -3
- data/lib/rbs/prototype/rbi.rb +8 -6
- data/lib/rbs/prototype/runtime.rb +4 -4
- data/lib/rbs/types.rb +89 -0
- data/lib/rbs/validator.rb +62 -11
- data/lib/rbs/variance_calculator.rb +9 -8
- data/lib/rbs/version.rb +1 -1
- data/lib/rbs/writer.rb +1 -13
- data/lib/rbs.rb +1 -0
- data/schema/decls.json +16 -55
- data/schema/methodType.json +1 -1
- data/schema/typeParam.json +36 -0
- data/sig/collection/collections.rbs +11 -2
- data/sig/collection/config.rbs +2 -2
- data/sig/declarations.rbs +8 -58
- data/sig/definition.rbs +11 -1
- data/sig/definition_builder.rbs +8 -1
- data/sig/environment.rbs +7 -1
- data/sig/errors.rbs +19 -4
- data/sig/location.rbs +3 -1
- data/sig/locator.rbs +1 -1
- data/sig/method_types.rbs +25 -4
- data/sig/type_param.rbs +74 -0
- data/sig/types.rbs +27 -1
- data/sig/validator.rbs +31 -2
- data/sig/variance_calculator.rbs +1 -1
- data/sig/writer.rbs +1 -1
- data/stdlib/bigdecimal-math/0/manifest.yaml +2 -0
- data/stdlib/csv/0/manifest.yaml +2 -0
- data/stdlib/logger/0/manifest.yaml +2 -0
- data/stdlib/net-http/0/manifest.yaml +2 -0
- data/stdlib/openssl/0/manifest.yaml +2 -0
- data/stdlib/prime/0/manifest.yaml +2 -0
- data/stdlib/resolv/0/manifest.yaml +3 -0
- data/stdlib/uri/0/common.rbs +10 -5
- data/stdlib/uri/0/ftp.rbs +10 -0
- data/stdlib/uri/0/generic.rbs +34 -34
- data/stdlib/uri/0/mailto.rbs +5 -0
- data/stdlib/uri/0/ws.rbs +10 -0
- data/stdlib/uri/0/wss.rbs +7 -0
- data/stdlib/yaml/0/manifest.yaml +3 -0
- metadata +17 -2
data/sig/declarations.rbs
CHANGED
@@ -6,56 +6,6 @@ module RBS
|
|
6
6
|
class Base
|
7
7
|
end
|
8
8
|
|
9
|
-
type variance = :invariant | :covariant | :contravariant
|
10
|
-
|
11
|
-
class ModuleTypeParams
|
12
|
-
class TypeParam
|
13
|
-
# Key
|
14
|
-
# ^^^ name
|
15
|
-
#
|
16
|
-
# unchecked out Elem
|
17
|
-
# ^^^^^^^^^ unchecked
|
18
|
-
# ^^^ variance
|
19
|
-
# ^^^^ name
|
20
|
-
type loc = Location[:name, :variance | :unchecked]
|
21
|
-
|
22
|
-
attr_reader name: Symbol
|
23
|
-
attr_reader variance: variance
|
24
|
-
attr_reader skip_validation: bool
|
25
|
-
attr_reader location: loc?
|
26
|
-
|
27
|
-
def initialize: (name: Symbol, variance: variance, skip_validation: boolish, location: loc?) -> void
|
28
|
-
|
29
|
-
include _ToJson
|
30
|
-
end
|
31
|
-
|
32
|
-
attr_reader params: Array[TypeParam]
|
33
|
-
|
34
|
-
def initialize: () -> void
|
35
|
-
|
36
|
-
def add: (TypeParam param) -> self
|
37
|
-
|
38
|
-
include _HashEqual
|
39
|
-
include _ToJson
|
40
|
-
|
41
|
-
def []: (Symbol) -> TypeParam?
|
42
|
-
|
43
|
-
def each: { (TypeParam) -> void } -> void
|
44
|
-
| () -> Enumerator[TypeParam, void]
|
45
|
-
|
46
|
-
def self.empty: () -> instance
|
47
|
-
|
48
|
-
def variance: (Symbol) -> variance
|
49
|
-
|
50
|
-
def skip_validation?: (Symbol) -> bool
|
51
|
-
|
52
|
-
def empty?: () -> bool
|
53
|
-
|
54
|
-
def size: () -> Integer
|
55
|
-
|
56
|
-
def rename_to: (Array[Symbol] names) -> ModuleTypeParams
|
57
|
-
end
|
58
|
-
|
59
9
|
interface _WithMember
|
60
10
|
def members: () -> Array[untyped]
|
61
11
|
end
|
@@ -118,14 +68,14 @@ module RBS
|
|
118
68
|
include MixinHelper
|
119
69
|
|
120
70
|
attr_reader name: TypeName
|
121
|
-
attr_reader type_params:
|
71
|
+
attr_reader type_params: Array[TypeParam]
|
122
72
|
attr_reader members: Array[member]
|
123
73
|
attr_reader super_class: Super?
|
124
74
|
attr_reader annotations: Array[Annotation]
|
125
75
|
attr_reader location: loc?
|
126
76
|
attr_reader comment: Comment?
|
127
77
|
|
128
|
-
def initialize: (name: TypeName, type_params:
|
78
|
+
def initialize: (name: TypeName, type_params: Array[TypeParam], members: Array[member], super_class: Super?, annotations: Array[Annotation], location: loc?, comment: Comment?) -> void
|
129
79
|
|
130
80
|
include _HashEqual
|
131
81
|
include _ToJson
|
@@ -172,14 +122,14 @@ module RBS
|
|
172
122
|
include MixinHelper
|
173
123
|
|
174
124
|
attr_reader name: TypeName
|
175
|
-
attr_reader type_params:
|
125
|
+
attr_reader type_params: Array[TypeParam]
|
176
126
|
attr_reader members: Array[member]
|
177
127
|
attr_reader location: loc?
|
178
128
|
attr_reader annotations: Array[Annotation]
|
179
129
|
attr_reader self_types: Array[Self]
|
180
130
|
attr_reader comment: Comment?
|
181
131
|
|
182
|
-
def initialize: (name: TypeName, type_params:
|
132
|
+
def initialize: (name: TypeName, type_params: Array[TypeParam], members: Array[member], location: loc?, annotations: Array[Annotation], self_types: Array[Self], comment: Comment?) -> void
|
183
133
|
|
184
134
|
include _HashEqual
|
185
135
|
include _ToJson
|
@@ -202,13 +152,13 @@ module RBS
|
|
202
152
|
type loc = Location[:name | :keyword | :end, :type_params]
|
203
153
|
|
204
154
|
attr_reader name: TypeName
|
205
|
-
attr_reader type_params:
|
155
|
+
attr_reader type_params: Array[TypeParam]
|
206
156
|
attr_reader members: Array[member]
|
207
157
|
attr_reader annotations: Array[Annotation]
|
208
158
|
attr_reader location: loc?
|
209
159
|
attr_reader comment: Comment?
|
210
160
|
|
211
|
-
def initialize: (name: TypeName, type_params:
|
161
|
+
def initialize: (name: TypeName, type_params: Array[TypeParam], members: Array[member], annotations: Array[Annotation], location: loc?, comment: Comment?) -> void
|
212
162
|
|
213
163
|
include MixinHelper
|
214
164
|
|
@@ -226,13 +176,13 @@ module RBS
|
|
226
176
|
type loc = Location[:keyword | :name | :eq, :type_params]
|
227
177
|
|
228
178
|
attr_reader name: TypeName
|
229
|
-
attr_reader type_params:
|
179
|
+
attr_reader type_params: Array[TypeParam]
|
230
180
|
attr_reader type: Types::t
|
231
181
|
attr_reader annotations: Array[Annotation]
|
232
182
|
attr_reader location: loc?
|
233
183
|
attr_reader comment: Comment?
|
234
184
|
|
235
|
-
def initialize: (name: TypeName, type_params:
|
185
|
+
def initialize: (name: TypeName, type_params: Array[TypeParam], type: Types::t, annotations: Array[Annotation], location: loc?, comment: Comment?) -> void
|
236
186
|
|
237
187
|
include _HashEqual
|
238
188
|
include _ToJson
|
data/sig/definition.rbs
CHANGED
@@ -54,10 +54,20 @@ module RBS
|
|
54
54
|
|
55
55
|
def private?: () -> bool
|
56
56
|
|
57
|
+
# Substitutes type variables to some types.
|
58
|
+
# Takes care of type parameter bounds.
|
59
|
+
#
|
57
60
|
def sub: (Substitution) -> Method
|
58
61
|
|
62
|
+
# Applies the mapping from `Types::t` to `Types::t`.
|
63
|
+
#
|
64
|
+
# Note this method doesn't handle upper bound in type params.
|
65
|
+
# You may want to use `#map_type_bound` explicitly, or `#sub` for simple substitution.
|
66
|
+
#
|
59
67
|
def map_type: () { (Types::t) -> Types::t } -> Method
|
60
68
|
|
69
|
+
def map_type_bound: () { (AST::TypeParam::bound) -> AST::TypeParam::bound } -> Method
|
70
|
+
|
61
71
|
def map_method_type: () { (MethodType) -> MethodType } -> Method
|
62
72
|
end
|
63
73
|
|
@@ -127,7 +137,7 @@ module RBS
|
|
127
137
|
|
128
138
|
def type_params: () -> Array[Symbol]
|
129
139
|
|
130
|
-
def type_params_decl: () -> AST::
|
140
|
+
def type_params_decl: () -> Array[AST::TypeParam]
|
131
141
|
|
132
142
|
def sub: (Substitution) -> Definition
|
133
143
|
|
data/sig/definition_builder.rbs
CHANGED
@@ -33,7 +33,7 @@ module RBS
|
|
33
33
|
def try_cache: (TypeName, cache: Hash[TypeName, Definition | false | nil]) { () -> Definition } -> Definition
|
34
34
|
| [A] (TypeName, cache: Hash[A, Definition | false | nil], key: A) { () -> Definition } -> Definition
|
35
35
|
|
36
|
-
def validate_params_with: (AST::
|
36
|
+
def validate_params_with: (Array[AST::TypeParam], result: VarianceCalculator::Result) { (AST::TypeParam) -> void } -> void
|
37
37
|
|
38
38
|
def validate_type_params: (Definition, ancestors: AncestorBuilder::OneAncestors, methods: MethodBuilder::Methods) -> void
|
39
39
|
|
@@ -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
|
#
|
data/sig/environment.rbs
CHANGED
@@ -31,7 +31,9 @@ module RBS
|
|
31
31
|
|
32
32
|
def validate_type_params: () -> void
|
33
33
|
|
34
|
-
def
|
34
|
+
def compatible_params?: (Array[AST::TypeParam], Array[AST::TypeParam]) -> boolish
|
35
|
+
|
36
|
+
def type_params: () -> Array[AST::TypeParam]
|
35
37
|
|
36
38
|
def primary: () -> D[module_decl]
|
37
39
|
end
|
@@ -96,6 +98,10 @@ module RBS
|
|
96
98
|
|
97
99
|
def resolve_member: (TypeNameResolver, AST::Members::t, context: Array[Namespace]) -> AST::Members::t
|
98
100
|
|
101
|
+
def resolve_method_type: (TypeNameResolver, RBS::MethodType, context: Array[Namespace]) -> RBS::MethodType
|
102
|
+
|
103
|
+
def resolve_type_params: (TypeNameResolver resolver, Array[AST::TypeParam], context: Array[Namespace]) -> Array[AST::TypeParam]
|
104
|
+
|
99
105
|
def absolute_type: (TypeNameResolver, Types::t, context: Array[Namespace]) -> Types::t
|
100
106
|
|
101
107
|
def absolute_type_name: (TypeNameResolver, TypeName, context: Array[Namespace]) -> TypeName
|
data/sig/errors.rbs
CHANGED
@@ -179,10 +179,10 @@ module RBS
|
|
179
179
|
|
180
180
|
class InvalidVarianceAnnotationError < DefinitionError
|
181
181
|
attr_reader type_name: TypeName
|
182
|
-
attr_reader param: AST::
|
182
|
+
attr_reader param: AST::TypeParam
|
183
183
|
attr_reader location: Location[untyped, untyped]?
|
184
184
|
|
185
|
-
def initialize: (type_name: TypeName, param: AST::
|
185
|
+
def initialize: (type_name: TypeName, param: AST::TypeParam, location: Location[untyped, untyped]?) -> void
|
186
186
|
end
|
187
187
|
|
188
188
|
class RecursiveAliasDefinitionError < DefinitionError
|
@@ -212,7 +212,7 @@ module RBS
|
|
212
212
|
def mixin_name: () -> String
|
213
213
|
end
|
214
214
|
|
215
|
-
class RecursiveTypeAliasError <
|
215
|
+
class RecursiveTypeAliasError < BaseError
|
216
216
|
attr_reader alias_names: Array[TypeName]
|
217
217
|
attr_reader location: Location[untyped, untyped]?
|
218
218
|
|
@@ -221,7 +221,7 @@ module RBS
|
|
221
221
|
def name: () -> String
|
222
222
|
end
|
223
223
|
|
224
|
-
class NonregularTypeAliasError <
|
224
|
+
class NonregularTypeAliasError < BaseError
|
225
225
|
# Diagnostic reported from `TypeAliasRegularity`.
|
226
226
|
attr_reader diagnostic: TypeAliasRegularity::Diagnostic
|
227
227
|
|
@@ -230,4 +230,19 @@ module RBS
|
|
230
230
|
|
231
231
|
def initialize: (diagnostic: TypeAliasRegularity::Diagnostic, location: Location[untyped, untyped]?) -> void
|
232
232
|
end
|
233
|
+
|
234
|
+
class CyclicTypeParameterBound < BaseError
|
235
|
+
attr_reader location: Location[untyped, untyped]?
|
236
|
+
|
237
|
+
# Array of parameters which contains cyclic dependencies.
|
238
|
+
attr_reader params: Array[AST::TypeParam]
|
239
|
+
|
240
|
+
# Type name
|
241
|
+
attr_reader type_name: TypeName
|
242
|
+
|
243
|
+
# Method name
|
244
|
+
attr_reader method_name: Symbol?
|
245
|
+
|
246
|
+
def initialize: (type_name: TypeName, method_name: Symbol?, params: Array[AST::TypeParam], location: Location[untyped, untyped]?) -> void
|
247
|
+
end
|
233
248
|
end
|
data/sig/location.rbs
CHANGED
@@ -8,7 +8,7 @@ module RBS
|
|
8
8
|
#
|
9
9
|
# ```
|
10
10
|
#
|
11
|
-
class Location[RequiredChildKeys, OptionalChildKeys]
|
11
|
+
class Location[in RequiredChildKeys, in OptionalChildKeys]
|
12
12
|
# The buffer this location points on.
|
13
13
|
attr_reader buffer (): Buffer
|
14
14
|
|
@@ -79,6 +79,8 @@ module RBS
|
|
79
79
|
| (OptionalChildKeys) -> Location[bot, bot]?
|
80
80
|
| (Symbol) -> Location[bot, bot]?
|
81
81
|
|
82
|
+
alias aref []
|
83
|
+
|
82
84
|
def each_optional_key: () { (Symbol) -> void } -> void
|
83
85
|
| () -> Enumerator[Symbol, void]
|
84
86
|
|
data/sig/locator.rbs
CHANGED
data/sig/method_types.rbs
CHANGED
@@ -1,27 +1,48 @@
|
|
1
1
|
module RBS
|
2
2
|
class MethodType
|
3
|
-
|
3
|
+
# () -> void
|
4
|
+
# ^^^^^^^^^^ type
|
5
|
+
#
|
6
|
+
# [A] () { () -> A } -> A
|
7
|
+
# ^^^ type_params
|
8
|
+
# ^^^^^^^^^^^^^^^^^^^ type
|
9
|
+
#
|
10
|
+
type loc = Location[:type, :type_params]
|
11
|
+
|
12
|
+
attr_reader type_params: Array[AST::TypeParam]
|
4
13
|
attr_reader type: Types::Function
|
5
14
|
attr_reader block: Types::Block?
|
6
|
-
attr_reader location:
|
15
|
+
attr_reader location: loc?
|
7
16
|
|
8
|
-
def initialize: (type_params: Array[
|
17
|
+
def initialize: (type_params: Array[AST::TypeParam], type: Types::Function, block: Types::Block?, location: loc?) -> void
|
9
18
|
|
10
19
|
def ==: (untyped other) -> bool
|
11
20
|
|
12
21
|
include _ToJson
|
13
22
|
|
23
|
+
# Substitute type variables to some types.
|
24
|
+
# Takes care of type parameter bounds.
|
25
|
+
#
|
14
26
|
def sub: (Substitution) -> MethodType
|
15
27
|
|
16
|
-
def update: (?type_params: Array[
|
28
|
+
def update: (?type_params: Array[AST::TypeParam], ?type: Types::Function, ?block: Types::Block?, ?location: loc?) -> MethodType
|
17
29
|
|
18
30
|
def free_variables: (?Set[Symbol] set) -> Set[Symbol]
|
19
31
|
|
32
|
+
# Apply the mapping included in the MethodType.
|
33
|
+
#
|
34
|
+
# Note that type bound in generics parameter is not handled by this method.
|
35
|
+
# You may want to use `#map_type_bound` explicitly, or `#sub` for simple substitution.
|
36
|
+
#
|
20
37
|
def map_type: () { (Types::t) -> Types::t } -> MethodType
|
21
38
|
|
39
|
+
def map_type_bound: () { (AST::TypeParam::bound) -> AST::TypeParam::bound } -> MethodType
|
40
|
+
|
22
41
|
def each_type: () { (Types::t) -> void } -> void
|
23
42
|
| () -> Enumerator[Types::t, void]
|
24
43
|
|
25
44
|
def to_s: () -> String
|
45
|
+
|
46
|
+
def type_param_names: () -> Array[Symbol]
|
26
47
|
end
|
27
48
|
end
|
data/sig/type_param.rbs
ADDED
@@ -0,0 +1,74 @@
|
|
1
|
+
module RBS
|
2
|
+
module AST
|
3
|
+
class TypeParam
|
4
|
+
# Key
|
5
|
+
# ^^^ name
|
6
|
+
#
|
7
|
+
# unchecked out Elem < _ToJson
|
8
|
+
# ^^^^^^^^^ unchecked
|
9
|
+
# ^^^ variance
|
10
|
+
# ^^^^ name
|
11
|
+
# ^^^^^^^^^ upper_bound
|
12
|
+
type loc = Location[:name, :variance | :unchecked | :upper_bound]
|
13
|
+
|
14
|
+
type variance = :invariant | :covariant | :contravariant
|
15
|
+
|
16
|
+
type bound = Types::ClassInstance | Types::ClassSingleton | Types::Interface
|
17
|
+
|
18
|
+
attr_reader name: Symbol
|
19
|
+
attr_reader variance: variance
|
20
|
+
attr_reader location: loc?
|
21
|
+
|
22
|
+
attr_reader upper_bound: bound?
|
23
|
+
|
24
|
+
def initialize: (name: Symbol, variance: variance, upper_bound: bound?, location: loc?) -> void
|
25
|
+
|
26
|
+
include _ToJson
|
27
|
+
|
28
|
+
def ==: (untyped) -> bool
|
29
|
+
|
30
|
+
def eql?: (untyped) -> bool
|
31
|
+
|
32
|
+
def hash: () -> Integer
|
33
|
+
|
34
|
+
@unchecked: bool
|
35
|
+
|
36
|
+
def unchecked!: (?boolish) -> self
|
37
|
+
|
38
|
+
def unchecked?: () -> bool
|
39
|
+
|
40
|
+
def map_type: () { (bound) -> bound } -> TypeParam
|
41
|
+
|
42
|
+
# Helper function to resolve _class instance types_ to _type variables_.
|
43
|
+
#
|
44
|
+
# We need this step because RBS language has an identical syntax for both unqualified class instance types and type variables.
|
45
|
+
# `String` may be an instance of `::String` class or type variable depending on the list of bound type variables.
|
46
|
+
#
|
47
|
+
# So, we need second pass to parse the following generics parameter declaration.
|
48
|
+
#
|
49
|
+
# ```rbs
|
50
|
+
# class Foo[X < _Each[Y], Y]
|
51
|
+
# # ^ We want this `Y` to be a type variable.
|
52
|
+
# end
|
53
|
+
# ```
|
54
|
+
#
|
55
|
+
def self.resolve_variables: (Array[TypeParam]) -> void
|
56
|
+
|
57
|
+
def self.subst_var: (Set[Symbol], Types::t) -> Types::t
|
58
|
+
|
59
|
+
# Rename type parameter name.
|
60
|
+
#
|
61
|
+
# The renaming cannot be done separately because a set of `TypeParam` decls may be mutual recursive.
|
62
|
+
#
|
63
|
+
# Example:
|
64
|
+
#
|
65
|
+
# * Renaming `A -> X, B -> Y`
|
66
|
+
# * Input `[A, B < _Pushable[A]]`
|
67
|
+
# * Result `[X, Y < _Pushable[X]]`
|
68
|
+
#
|
69
|
+
def self.rename: (Array[TypeParam], new_names: Array[Symbol]) -> Array[TypeParam]
|
70
|
+
|
71
|
+
def to_s: () -> String
|
72
|
+
end
|
73
|
+
end
|
74
|
+
end
|
data/sig/types.rbs
CHANGED
@@ -55,6 +55,11 @@ module RBS
|
|
55
55
|
module EmptyEachType
|
56
56
|
def each_type: () { (t) -> void } -> void
|
57
57
|
| () -> Enumerator[t, void]
|
58
|
+
|
59
|
+
# `map_type` returns itself, because there is no sub type.
|
60
|
+
#
|
61
|
+
def map_type: () { (t) -> t } -> self
|
62
|
+
| () -> Enumerator[t, self]
|
58
63
|
end
|
59
64
|
|
60
65
|
module NoTypeName
|
@@ -199,6 +204,9 @@ module RBS
|
|
199
204
|
include _TypeBase
|
200
205
|
|
201
206
|
attr_reader location: loc?
|
207
|
+
|
208
|
+
def map_type: () { (t) -> t } -> Interface
|
209
|
+
| () -> Enumerator[t, Interface]
|
202
210
|
end
|
203
211
|
|
204
212
|
# ClassInstance represents a type of an instance of a class.
|
@@ -224,6 +232,9 @@ module RBS
|
|
224
232
|
attr_reader location: loc?
|
225
233
|
|
226
234
|
include _TypeBase
|
235
|
+
|
236
|
+
def map_type: () { (t) -> t } -> ClassInstance
|
237
|
+
| () -> Enumerator[t, ClassInstance]
|
227
238
|
end
|
228
239
|
|
229
240
|
class Alias
|
@@ -242,6 +253,9 @@ module RBS
|
|
242
253
|
|
243
254
|
include _TypeBase
|
244
255
|
include Application
|
256
|
+
|
257
|
+
def map_type: () { (t) -> t } -> Alias
|
258
|
+
| () -> Enumerator[t, Alias]
|
245
259
|
end
|
246
260
|
|
247
261
|
class Tuple
|
@@ -254,6 +268,9 @@ module RBS
|
|
254
268
|
include _TypeBase
|
255
269
|
|
256
270
|
attr_reader location: loc?
|
271
|
+
|
272
|
+
def map_type: () { (t) -> t } -> Tuple
|
273
|
+
| () -> Enumerator[t, Tuple]
|
257
274
|
end
|
258
275
|
|
259
276
|
class Record
|
@@ -266,6 +283,9 @@ module RBS
|
|
266
283
|
include _TypeBase
|
267
284
|
|
268
285
|
attr_reader location: loc?
|
286
|
+
|
287
|
+
def map_type: () { (t) -> t } -> Record
|
288
|
+
| () -> Enumerator[t, Record]
|
269
289
|
end
|
270
290
|
|
271
291
|
class Optional
|
@@ -278,6 +298,9 @@ module RBS
|
|
278
298
|
include _TypeBase
|
279
299
|
|
280
300
|
attr_reader location: loc?
|
301
|
+
|
302
|
+
def map_type: () { (t) -> t } -> Optional
|
303
|
+
| () -> Enumerator[t, Optional]
|
281
304
|
end
|
282
305
|
|
283
306
|
class Union
|
@@ -395,7 +418,7 @@ module RBS
|
|
395
418
|
|
396
419
|
def sub: (Substitution) -> Block
|
397
420
|
|
398
|
-
def map_type: () { (
|
421
|
+
def map_type: () { (t) -> t } -> Block
|
399
422
|
end
|
400
423
|
|
401
424
|
class Proc
|
@@ -409,6 +432,9 @@ module RBS
|
|
409
432
|
include _TypeBase
|
410
433
|
|
411
434
|
attr_reader location: loc?
|
435
|
+
|
436
|
+
def map_type: () { (t) -> t } -> Proc
|
437
|
+
| () -> Enumerator[t, Proc]
|
412
438
|
end
|
413
439
|
|
414
440
|
class Literal
|
data/sig/validator.rbs
CHANGED
@@ -12,10 +12,39 @@ module RBS
|
|
12
12
|
|
13
13
|
def initialize: (env: Environment, resolver: TypeNameResolver) -> void
|
14
14
|
|
15
|
-
|
16
|
-
|
15
|
+
# Validates the presence of type names and type application arity match.
|
16
|
+
#
|
17
17
|
def validate_type: (Types::t, context: TypeNameResolver::context) -> void
|
18
18
|
|
19
|
+
# Validates type alias definition:
|
20
|
+
#
|
21
|
+
# - There is no circular definition between aliases
|
22
|
+
# - The type alias is _regular_
|
23
|
+
# - The generics type parameter variance annotation is consistent with respect to their usage
|
24
|
+
# - There is no circular dependencies between the generics type parameter bounds
|
25
|
+
#
|
19
26
|
def validate_type_alias: (entry: Environment::SingleEntry[TypeName, AST::Declarations::Alias]) -> void
|
27
|
+
|
28
|
+
# Validates the type parameters in generic methods.
|
29
|
+
#
|
30
|
+
def validate_method_definition: (AST::Members::MethodDefinition, type_name: TypeName) -> void
|
31
|
+
|
32
|
+
# Validates the type parameters if there is no circular dependencies between the bounds.
|
33
|
+
#
|
34
|
+
# ```rbs
|
35
|
+
# [X, Y] # OK
|
36
|
+
# [X, Y < _Foo[X]] # OK
|
37
|
+
# [X < _Foo[Y], Y] # OK
|
38
|
+
# [X < _Foo[Y], Y < _Foo[X]] # Error
|
39
|
+
# ```
|
40
|
+
#
|
41
|
+
def validate_type_params: (Array[AST::TypeParam] params, type_name: TypeName, ?method_name: Symbol?, location: Location[untyped, untyped]?) -> void
|
42
|
+
|
43
|
+
private
|
44
|
+
|
45
|
+
# Resolves relative type names to absolute type names in given context.
|
46
|
+
# Yields the type when the type name resolution using `#resolver` fails.
|
47
|
+
#
|
48
|
+
def absolute_type: (Types::t, context: TypeNameResolver::context) { (Types::t) -> TypeName } -> Types::t
|
20
49
|
end
|
21
50
|
end
|
data/sig/variance_calculator.rbs
CHANGED
@@ -59,7 +59,7 @@ module RBS
|
|
59
59
|
|
60
60
|
def compatible?: (Symbol, with_annotation: variance) -> bool
|
61
61
|
|
62
|
-
def incompatible?: (AST::
|
62
|
+
def incompatible?: (Array[AST::TypeParam]) -> Set[Symbol]?
|
63
63
|
end
|
64
64
|
|
65
65
|
attr_reader builder: DefinitionBuilder
|
data/sig/writer.rbs
CHANGED
@@ -27,7 +27,7 @@ module RBS
|
|
27
27
|
|
28
28
|
def write_member: (AST::Declarations::Module::member) -> void
|
29
29
|
|
30
|
-
def name_and_params: (TypeName, AST::
|
30
|
+
def name_and_params: (TypeName, Array[AST::TypeParam]) -> String?
|
31
31
|
|
32
32
|
def name_and_args: (TypeName, Array[Types::t]) -> String?
|
33
33
|
|
data/stdlib/uri/0/common.rbs
CHANGED
@@ -154,7 +154,7 @@ module URI
|
|
154
154
|
#
|
155
155
|
# See URI.encode_www_form_component, URI.decode_www_form.
|
156
156
|
#
|
157
|
-
def self.encode_www_form: (Enumerable[[ _ToS, _ToS ]] enum, ?encoding enc) -> String
|
157
|
+
def self.encode_www_form: (Enumerable[[ _ToS, _ToS ]] enum, ?encoding? enc) -> String
|
158
158
|
|
159
159
|
# Encodes given `str` to URL-encoded form data.
|
160
160
|
#
|
@@ -168,7 +168,7 @@ module URI
|
|
168
168
|
#
|
169
169
|
# See URI.decode_www_form_component, URI.encode_www_form.
|
170
170
|
#
|
171
|
-
def self.encode_www_form_component: (
|
171
|
+
def self.encode_www_form_component: (_ToS str, ?encoding? enc) -> String
|
172
172
|
|
173
173
|
# ## Synopsis
|
174
174
|
#
|
@@ -268,7 +268,7 @@ module URI
|
|
268
268
|
# It's recommended to first ::escape the provided `uri_str` if there are any
|
269
269
|
# invalid URI characters.
|
270
270
|
#
|
271
|
-
def self.parse: (
|
271
|
+
def self.parse: (_ToStr uri) -> (File | FTP | HTTP | HTTPS | LDAP | LDAPS | MailTo | WS | WSS | Generic)
|
272
272
|
|
273
273
|
# ## Synopsis
|
274
274
|
#
|
@@ -302,12 +302,17 @@ module URI
|
|
302
302
|
# p $&
|
303
303
|
# end
|
304
304
|
#
|
305
|
-
def self.regexp: (?Array[String] schemes) -> Regexp
|
305
|
+
def self.regexp: (?Array[String]? schemes) -> Regexp
|
306
306
|
|
307
307
|
# Returns a Hash of the defined schemes.
|
308
308
|
#
|
309
309
|
def self.scheme_list: () -> Hash[String, Class]
|
310
310
|
|
311
|
+
# Construct a URI instance, using the scheme to detect the appropriate class
|
312
|
+
# from +URI.scheme_list+.
|
313
|
+
#
|
314
|
+
def self.for: (String scheme, *untyped arguments, ?default: Class) -> (File | FTP | HTTP | HTTPS | LDAP | LDAPS | MailTo | WS | WSS | Generic)
|
315
|
+
|
311
316
|
# ## Synopsis
|
312
317
|
#
|
313
318
|
# URI::split(uri)
|
@@ -340,7 +345,7 @@ module URI
|
|
340
345
|
# URI.split("http://www.ruby-lang.org/")
|
341
346
|
# # => ["http", nil, "www.ruby-lang.org", nil, nil, "/", nil, nil, nil]
|
342
347
|
#
|
343
|
-
def self.split: (
|
348
|
+
def self.split: (_ToStr uri) -> [ String?, String?, String?, String?, nil, String?, String?, String?, String? ]
|
344
349
|
end
|
345
350
|
|
346
351
|
URI::ABS_PATH: Regexp
|
@@ -0,0 +1,10 @@
|
|
1
|
+
module URI
|
2
|
+
# FTP URI syntax is defined by RFC1738 section 3.2.
|
3
|
+
#
|
4
|
+
# This class will be redesigned because of difference of implementations;
|
5
|
+
# the structure of its path. draft-hoffman-ftp-uri-04 is a draft but it
|
6
|
+
# is a good summary about the de facto spec.
|
7
|
+
# http://tools.ietf.org/html/draft-hoffman-ftp-uri-04
|
8
|
+
class FTP < Generic
|
9
|
+
end
|
10
|
+
end
|