steep 1.7.0.dev.3 → 1.7.0.dev.4
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/Gemfile.lock +12 -12
- data/doc/narrowing.md +1 -1
- data/doc/shape.md +176 -0
- data/gemfile_steep/Gemfile.lock +5 -5
- data/lib/steep/ast/types/factory.rb +27 -18
- data/lib/steep/ast/types/proc.rb +14 -9
- data/lib/steep/interface/block.rb +1 -1
- data/lib/steep/interface/builder.rb +1 -0
- data/lib/steep/interface/function.rb +14 -6
- data/lib/steep/interface/method_type.rb +15 -7
- data/lib/steep/project/pattern.rb +1 -2
- data/lib/steep/server/interaction_worker.rb +6 -0
- data/lib/steep/server/lsp_formatter.rb +2 -0
- data/lib/steep/services/completion_provider.rb +1 -1
- data/lib/steep/services/file_loader.rb +15 -20
- data/lib/steep/services/signature_help_provider.rb +11 -9
- data/lib/steep/signature/validator.rb +1 -1
- data/lib/steep/subtyping/check.rb +15 -6
- data/lib/steep/subtyping/variable_variance.rb +3 -3
- data/lib/steep/type_construction.rb +185 -149
- data/lib/steep/type_inference/block_params.rb +1 -1
- data/lib/steep/type_inference/logic_type_interpreter.rb +2 -1
- data/lib/steep/type_inference/method_params.rb +16 -0
- data/lib/steep/type_inference/send_args.rb +5 -2
- data/lib/steep/version.rb +1 -1
- data/sig/steep/ast/types/factory.rbs +2 -2
- data/sig/steep/interface/builder.rbs +12 -53
- data/sig/steep/interface/function.rbs +5 -4
- data/sig/steep/services/signature_help_provider.rbs +1 -1
- data/sig/steep/subtyping/variable_variance.rbs +1 -1
- data/sig/steep/type_inference/block_params.rbs +1 -1
- data/sig/steep/type_inference/method_params.rbs +3 -3
- data/steep.gemspec +1 -1
- metadata +5 -4
@@ -850,8 +850,10 @@ module Steep
|
|
850
850
|
relation.function!
|
851
851
|
|
852
852
|
All(relation) do |result|
|
853
|
-
|
854
|
-
|
853
|
+
if relation.sub_type.params && relation.super_type.params
|
854
|
+
result.add(relation.map {|fun| _ = fun.params }) do |rel|
|
855
|
+
check_method_params(name, rel)
|
856
|
+
end
|
855
857
|
end
|
856
858
|
|
857
859
|
result.add(relation.map {|fun| fun.return_type }) do |rel|
|
@@ -906,16 +908,23 @@ module Steep
|
|
906
908
|
end
|
907
909
|
|
908
910
|
def match_method_type_fails?(name, type1, type2)
|
909
|
-
|
910
|
-
|
911
|
+
if type1.type.params && type2.type.params
|
912
|
+
match_params(name, Relation(type1.type.params, type2.type.params)).tap do |param_pairs|
|
913
|
+
return param_pairs unless param_pairs.is_a?(Array)
|
914
|
+
end
|
911
915
|
end
|
912
916
|
|
913
917
|
case result = expand_block_given(name, Relation(type1.block, type2.block))
|
914
918
|
when Result::Base
|
915
919
|
return result
|
916
920
|
when Relation
|
917
|
-
|
918
|
-
|
921
|
+
type1.block or raise
|
922
|
+
type2.block or raise
|
923
|
+
|
924
|
+
if type1.block.type.params && type2.block.type.params
|
925
|
+
match_params(name, result.map {|m| _ = m.type.params }).tap do |param_pairs|
|
926
|
+
return param_pairs unless param_pairs.is_a?(Array)
|
927
|
+
end
|
919
928
|
end
|
920
929
|
end
|
921
930
|
|
@@ -46,7 +46,7 @@ module Steep
|
|
46
46
|
end
|
47
47
|
|
48
48
|
def self.add_params(params, block:, covariants:, contravariants:)
|
49
|
-
params
|
49
|
+
params&.each_type do |type|
|
50
50
|
add_type(type, variance: block ? :contravariant : :covariant, covariants: covariants, contravariants: contravariants)
|
51
51
|
end
|
52
52
|
end
|
@@ -64,12 +64,12 @@ module Steep
|
|
64
64
|
contravariants << type.name
|
65
65
|
end
|
66
66
|
when AST::Types::Proc
|
67
|
-
type.type.params
|
67
|
+
type.type.params&.each_type do |type|
|
68
68
|
add_type(type, variance: variance, covariants: contravariants, contravariants: covariants)
|
69
69
|
end
|
70
70
|
add_type(type.type.return_type, variance: variance, covariants: covariants, contravariants: contravariants)
|
71
71
|
if type.block
|
72
|
-
type.block.type.params
|
72
|
+
type.block.type.params&.each_type do |type|
|
73
73
|
add_type(type, variance: variance, covariants: covariants, contravariants: contravariants)
|
74
74
|
end
|
75
75
|
add_type(type.type.return_type, variance: variance, covariants: contravariants, contravariants: covariants)
|
@@ -1635,28 +1635,32 @@ module Steep
|
|
1635
1635
|
when :yield
|
1636
1636
|
if method_context && method_context.method_type
|
1637
1637
|
if block_type = method_context.block_type
|
1638
|
-
|
1639
|
-
type
|
1640
|
-
|
1641
|
-
|
1642
|
-
|
1643
|
-
|
1644
|
-
|
1645
|
-
|
1646
|
-
|
1647
|
-
|
1638
|
+
if block_type.type.params
|
1639
|
+
type = AST::Types::Proc.new(
|
1640
|
+
type: block_type.type,
|
1641
|
+
block: nil,
|
1642
|
+
self_type: block_type.self_type
|
1643
|
+
)
|
1644
|
+
args = TypeInference::SendArgs.new(
|
1645
|
+
node: node,
|
1646
|
+
arguments: node.children,
|
1647
|
+
type: type
|
1648
|
+
)
|
1648
1649
|
|
1649
|
-
|
1650
|
-
|
1651
|
-
|
1652
|
-
|
1653
|
-
|
1654
|
-
|
1655
|
-
|
1656
|
-
|
1650
|
+
# @type var errors: Array[Diagnostic::Ruby::Base]
|
1651
|
+
errors = []
|
1652
|
+
constr = type_check_args(
|
1653
|
+
nil,
|
1654
|
+
args,
|
1655
|
+
Subtyping::Constraints.new(unknowns: []),
|
1656
|
+
errors
|
1657
|
+
)
|
1657
1658
|
|
1658
|
-
|
1659
|
-
|
1659
|
+
errors.each do |error|
|
1660
|
+
typing.add_error(error)
|
1661
|
+
end
|
1662
|
+
else
|
1663
|
+
constr = type_check_untyped_args(node.children)
|
1660
1664
|
end
|
1661
1665
|
|
1662
1666
|
add_typing(node, type: block_type.type.return_type)
|
@@ -2172,10 +2176,21 @@ module Steep
|
|
2172
2176
|
var_type = AST::Builtin.any_type
|
2173
2177
|
else
|
2174
2178
|
if each = calculate_interface(collection_type, :each, private: true)
|
2175
|
-
|
2179
|
+
method_type = (each.method_types || []).find do |type|
|
2180
|
+
if type.block
|
2181
|
+
if type.block.type.params
|
2182
|
+
type.block.type.params.first_param
|
2183
|
+
else
|
2184
|
+
true
|
2185
|
+
end
|
2186
|
+
end
|
2187
|
+
end
|
2188
|
+
if method_type
|
2176
2189
|
if block = method_type.block
|
2177
|
-
if first_param = block.type
|
2190
|
+
if first_param = block.type&.params&.first_param
|
2178
2191
|
var_type = first_param.type #: AST::Types::t
|
2192
|
+
else
|
2193
|
+
var_type - AST::Builtin.any_type
|
2179
2194
|
end
|
2180
2195
|
end
|
2181
2196
|
end
|
@@ -2386,31 +2401,33 @@ module Steep
|
|
2386
2401
|
|
2387
2402
|
if hint.is_a?(AST::Types::Proc) && value_node.type == :sym
|
2388
2403
|
if hint.one_arg?
|
2389
|
-
|
2390
|
-
|
2391
|
-
|
2392
|
-
|
2393
|
-
|
2394
|
-
|
2395
|
-
|
2396
|
-
|
2397
|
-
|
2398
|
-
method_type.type.
|
2404
|
+
if hint.type.params
|
2405
|
+
# Assumes Symbol#to_proc implementation
|
2406
|
+
param_type = hint.type.params.required[0]
|
2407
|
+
case param_type
|
2408
|
+
when AST::Types::Any
|
2409
|
+
type = AST::Types::Any.new
|
2410
|
+
else
|
2411
|
+
if method = calculate_interface(param_type, private: true)&.methods&.[](value_node.children[0])
|
2412
|
+
return_types = method.method_types.filter_map do |method_type|
|
2413
|
+
if method_type.type.params.nil? || method_type.type.params.optional?
|
2414
|
+
method_type.type.return_type
|
2415
|
+
end
|
2399
2416
|
end
|
2400
|
-
end
|
2401
2417
|
|
2402
|
-
|
2403
|
-
|
2404
|
-
|
2405
|
-
|
2406
|
-
|
2418
|
+
unless return_types.empty?
|
2419
|
+
type = AST::Types::Proc.new(
|
2420
|
+
type: Interface::Function.new(
|
2421
|
+
params: Interface::Function::Params.empty.with_first_param(
|
2422
|
+
Interface::Function::Params::PositionalParams::Required.new(param_type)
|
2423
|
+
),
|
2424
|
+
return_type: return_types[0],
|
2425
|
+
location: nil
|
2407
2426
|
),
|
2408
|
-
|
2409
|
-
|
2410
|
-
)
|
2411
|
-
|
2412
|
-
self_type: nil
|
2413
|
-
)
|
2427
|
+
block: nil,
|
2428
|
+
self_type: nil
|
2429
|
+
)
|
2430
|
+
end
|
2414
2431
|
end
|
2415
2432
|
end
|
2416
2433
|
end
|
@@ -3186,7 +3203,7 @@ module Steep
|
|
3186
3203
|
end
|
3187
3204
|
|
3188
3205
|
def type_send_interface(node, interface:, receiver:, receiver_type:, method_name:, arguments:, block_params:, block_body:, tapp:, hint:)
|
3189
|
-
method = interface
|
3206
|
+
method = interface.methods[method_name]
|
3190
3207
|
|
3191
3208
|
if method
|
3192
3209
|
call, constr = type_method_call(
|
@@ -3915,13 +3932,17 @@ module Steep
|
|
3915
3932
|
# @type var errors: Array[Diagnostic::Ruby::Base]
|
3916
3933
|
errors = []
|
3917
3934
|
|
3918
|
-
|
3919
|
-
|
3920
|
-
|
3921
|
-
|
3922
|
-
|
3923
|
-
|
3924
|
-
|
3935
|
+
if method_type.type.params
|
3936
|
+
args = TypeInference::SendArgs.new(node: node, arguments: arguments, type: method_type)
|
3937
|
+
constr = constr.type_check_args(
|
3938
|
+
method_name,
|
3939
|
+
args,
|
3940
|
+
constraints,
|
3941
|
+
errors
|
3942
|
+
)
|
3943
|
+
else
|
3944
|
+
constr = constr.type_check_untyped_args(arguments)
|
3945
|
+
end
|
3925
3946
|
|
3926
3947
|
if block_params
|
3927
3948
|
# block is given
|
@@ -4010,11 +4031,12 @@ module Steep
|
|
4010
4031
|
end
|
4011
4032
|
|
4012
4033
|
method_type, solved, s = apply_solution(errors, node: node, method_type: method_type) {
|
4013
|
-
|
4014
|
-
|
4015
|
-
|
4016
|
-
|
4017
|
-
|
4034
|
+
fvs_ = Set[] #: Set[AST::Types::variable]
|
4035
|
+
|
4036
|
+
fvs_.merge(method_type.type.params.free_variables) if method_type.type.params
|
4037
|
+
fvs_.merge(method_type.block.type.params.free_variables) if method_type.block.type.params
|
4038
|
+
|
4039
|
+
constraints.solution(checker, variables: fvs_, context: ccontext)
|
4018
4040
|
}
|
4019
4041
|
|
4020
4042
|
method_type.block or raise
|
@@ -4102,129 +4124,143 @@ module Steep
|
|
4102
4124
|
return_type = method_type.type.return_type
|
4103
4125
|
end
|
4104
4126
|
else
|
4105
|
-
|
4106
|
-
|
4107
|
-
|
4108
|
-
|
4109
|
-
|
4127
|
+
if args
|
4128
|
+
# Block is given but method doesn't accept
|
4129
|
+
#
|
4130
|
+
constr.type_block_without_hint(node: node, block_annotations: block_annotations, block_params: block_params_, block_body: block_body) do |error|
|
4131
|
+
errors << error
|
4132
|
+
end
|
4110
4133
|
|
4111
|
-
|
4112
|
-
|
4113
|
-
|
4114
|
-
|
4115
|
-
|
4116
|
-
|
4134
|
+
case node.children[0].type
|
4135
|
+
when :super, :zsuper
|
4136
|
+
unless method_context!.super_method
|
4137
|
+
errors << Diagnostic::Ruby::UnexpectedSuper.new(
|
4138
|
+
node: node.children[0],
|
4139
|
+
method: method_name
|
4140
|
+
)
|
4141
|
+
end
|
4142
|
+
else
|
4143
|
+
errors << Diagnostic::Ruby::UnexpectedBlockGiven.new(
|
4144
|
+
node: node,
|
4145
|
+
method_type: method_type
|
4117
4146
|
)
|
4118
4147
|
end
|
4148
|
+
|
4149
|
+
method_type = eliminate_vars(method_type, type_param_names)
|
4150
|
+
return_type = method_type.type.return_type
|
4119
4151
|
else
|
4120
|
-
|
4121
|
-
|
4122
|
-
|
4123
|
-
|
4152
|
+
if block_body
|
4153
|
+
block_annotations = source.annotations(block: node, factory: checker.factory, context: nesting)
|
4154
|
+
type_block_without_hint(
|
4155
|
+
node: node,
|
4156
|
+
block_annotations: block_annotations,
|
4157
|
+
block_params: TypeInference::BlockParams.from_node(block_params, annotations: block_annotations),
|
4158
|
+
block_body: block_body
|
4159
|
+
)
|
4160
|
+
end
|
4124
4161
|
end
|
4125
|
-
|
4126
|
-
method_type = eliminate_vars(method_type, type_param_names)
|
4127
|
-
return_type = method_type.type.return_type
|
4128
4162
|
end
|
4129
4163
|
else
|
4130
4164
|
# Block syntax is not given
|
4131
|
-
|
4165
|
+
if args
|
4166
|
+
arg = args.block_pass_arg
|
4132
4167
|
|
4133
|
-
|
4134
|
-
|
4135
|
-
|
4168
|
+
case
|
4169
|
+
when forwarded_args_node = args.forwarded_args_node
|
4170
|
+
(_, block = method_context!.forward_arg_type) or raise
|
4136
4171
|
|
4137
|
-
|
4138
|
-
|
4172
|
+
method_block_type = method_type.block&.to_proc_type || AST::Builtin.nil_type
|
4173
|
+
forwarded_block_type = block&.to_proc_type || AST::Builtin.nil_type
|
4139
4174
|
|
4140
|
-
|
4141
|
-
|
4142
|
-
|
4143
|
-
|
4144
|
-
|
4145
|
-
|
4146
|
-
|
4147
|
-
|
4175
|
+
if result = constr.no_subtyping?(sub_type: forwarded_block_type, super_type: method_block_type)
|
4176
|
+
errors << Diagnostic::Ruby::IncompatibleArgumentForwarding.new(
|
4177
|
+
method_name: method_name,
|
4178
|
+
node: forwarded_args_node,
|
4179
|
+
block_pair: [block, method_type.block],
|
4180
|
+
result: result
|
4181
|
+
)
|
4182
|
+
end
|
4148
4183
|
|
4149
|
-
|
4150
|
-
|
4151
|
-
|
4152
|
-
|
4184
|
+
when arg.compatible?
|
4185
|
+
if arg.node
|
4186
|
+
# Block pass (&block) is given
|
4187
|
+
node_type, constr = constr.synthesize(arg.node, hint: arg.node_type)
|
4153
4188
|
|
4154
|
-
|
4155
|
-
|
4156
|
-
|
4189
|
+
nil_given =
|
4190
|
+
constr.check_relation(sub_type: node_type, super_type: AST::Builtin.nil_type).success? &&
|
4191
|
+
!node_type.is_a?(AST::Types::Any)
|
4157
4192
|
|
4158
|
-
|
4159
|
-
|
4160
|
-
|
4161
|
-
|
4162
|
-
|
4163
|
-
|
4193
|
+
if nil_given
|
4194
|
+
# nil is given ==> no block arg node is given
|
4195
|
+
method_type, solved, _ = apply_solution(errors, node: node, method_type: method_type) {
|
4196
|
+
constraints.solution(checker, variables: method_type.free_variables, context: ccontext)
|
4197
|
+
}
|
4198
|
+
method_type = eliminate_vars(method_type, type_param_names) unless solved
|
4164
4199
|
|
4165
|
-
|
4166
|
-
|
4167
|
-
|
4168
|
-
|
4169
|
-
)
|
4170
|
-
else
|
4171
|
-
# non-nil value is given
|
4172
|
-
constr.check_relation(sub_type: node_type, super_type: arg.node_type, constraints: constraints).else do |result|
|
4173
|
-
errors << Diagnostic::Ruby::BlockTypeMismatch.new(
|
4174
|
-
node: arg.node,
|
4175
|
-
expected: arg.node_type,
|
4176
|
-
actual: node_type,
|
4177
|
-
result: result
|
4200
|
+
# Passing no block
|
4201
|
+
errors << Diagnostic::Ruby::RequiredBlockMissing.new(
|
4202
|
+
node: node,
|
4203
|
+
method_type: method_type
|
4178
4204
|
)
|
4179
|
-
|
4205
|
+
else
|
4206
|
+
# non-nil value is given
|
4207
|
+
constr.check_relation(sub_type: node_type, super_type: arg.node_type, constraints: constraints).else do |result|
|
4208
|
+
errors << Diagnostic::Ruby::BlockTypeMismatch.new(
|
4209
|
+
node: arg.node,
|
4210
|
+
expected: arg.node_type,
|
4211
|
+
actual: node_type,
|
4212
|
+
result: result
|
4213
|
+
)
|
4214
|
+
end
|
4180
4215
|
|
4216
|
+
method_type, solved, _ = apply_solution(errors, node: node, method_type: method_type) {
|
4217
|
+
constraints.solution(checker, variables: method_type.free_variables, context: ccontext)
|
4218
|
+
}
|
4219
|
+
method_type = eliminate_vars(method_type, type_param_names) unless solved
|
4220
|
+
end
|
4221
|
+
else
|
4222
|
+
# Block is not given
|
4181
4223
|
method_type, solved, _ = apply_solution(errors, node: node, method_type: method_type) {
|
4182
4224
|
constraints.solution(checker, variables: method_type.free_variables, context: ccontext)
|
4183
4225
|
}
|
4184
4226
|
method_type = eliminate_vars(method_type, type_param_names) unless solved
|
4185
4227
|
end
|
4186
|
-
|
4187
|
-
|
4228
|
+
|
4229
|
+
return_type = method_type.type.return_type
|
4230
|
+
|
4231
|
+
when arg.block_missing?
|
4232
|
+
# Block is required but not given
|
4188
4233
|
method_type, solved, _ = apply_solution(errors, node: node, method_type: method_type) {
|
4189
4234
|
constraints.solution(checker, variables: method_type.free_variables, context: ccontext)
|
4190
4235
|
}
|
4191
|
-
method_type = eliminate_vars(method_type, type_param_names) unless solved
|
4192
|
-
end
|
4193
|
-
|
4194
|
-
return_type = method_type.type.return_type
|
4195
4236
|
|
4196
|
-
|
4197
|
-
|
4198
|
-
method_type, solved, _ = apply_solution(errors, node: node, method_type: method_type) {
|
4199
|
-
constraints.solution(checker, variables: method_type.free_variables, context: ccontext)
|
4200
|
-
}
|
4201
|
-
|
4202
|
-
method_type = eliminate_vars(method_type, type_param_names) unless solved
|
4203
|
-
return_type = method_type.type.return_type
|
4237
|
+
method_type = eliminate_vars(method_type, type_param_names) unless solved
|
4238
|
+
return_type = method_type.type.return_type
|
4204
4239
|
|
4205
|
-
|
4206
|
-
|
4207
|
-
|
4208
|
-
|
4240
|
+
errors << Diagnostic::Ruby::RequiredBlockMissing.new(
|
4241
|
+
node: node,
|
4242
|
+
method_type: method_type
|
4243
|
+
)
|
4209
4244
|
|
4210
|
-
|
4211
|
-
|
4245
|
+
when arg.unexpected_block?
|
4246
|
+
# Unexpected block pass node is given
|
4212
4247
|
|
4213
|
-
|
4248
|
+
arg.node or raise
|
4214
4249
|
|
4215
|
-
|
4216
|
-
|
4217
|
-
|
4218
|
-
|
4219
|
-
|
4250
|
+
method_type, solved, _ = apply_solution(errors, node: node, method_type: method_type) {
|
4251
|
+
constraints.solution(checker, variables: method_type.free_variables, context: ccontext)
|
4252
|
+
}
|
4253
|
+
method_type = eliminate_vars(method_type, type_param_names) unless solved
|
4254
|
+
return_type = method_type.type.return_type
|
4220
4255
|
|
4221
|
-
|
4256
|
+
node_type, constr = constr.synthesize(arg.node)
|
4222
4257
|
|
4223
|
-
|
4224
|
-
|
4225
|
-
|
4226
|
-
|
4227
|
-
|
4258
|
+
unless constr.check_relation(sub_type: node_type, super_type: AST::Builtin.nil_type).success?
|
4259
|
+
errors << Diagnostic::Ruby::UnexpectedBlockGiven.new(
|
4260
|
+
node: node,
|
4261
|
+
method_type: method_type
|
4262
|
+
)
|
4263
|
+
end
|
4228
4264
|
end
|
4229
4265
|
end
|
4230
4266
|
end
|
@@ -4796,7 +4832,7 @@ module Steep
|
|
4796
4832
|
if shape = calculate_interface(type, private: false)
|
4797
4833
|
if entry = shape.methods[method]
|
4798
4834
|
method_type = entry.method_types.find do |method_type|
|
4799
|
-
method_type.type.params.optional?
|
4835
|
+
method_type.type.params.nil? || method_type.type.params.optional?
|
4800
4836
|
end
|
4801
4837
|
|
4802
4838
|
method_type.type.return_type if method_type
|
@@ -248,7 +248,7 @@ module Steep
|
|
248
248
|
# @type var zip: Array[[Param | MultipleParam, AST::Types::t]]
|
249
249
|
zip = []
|
250
250
|
|
251
|
-
if untyped_args?(params_type)
|
251
|
+
if params_type.nil? || untyped_args?(params_type)
|
252
252
|
params.each do |param|
|
253
253
|
if param == rest_param
|
254
254
|
zip << [param, AST::Builtin::Array.instance_type(fill_untyped: true)]
|
@@ -596,7 +596,8 @@ module Steep
|
|
596
596
|
if shape = subtyping.builder.shape(type, config)
|
597
597
|
if entry = shape.methods[method]
|
598
598
|
method_type = entry.method_types.find do |method_type|
|
599
|
-
method_type.type.params.
|
599
|
+
method_type.type.params.nil? ||
|
600
|
+
method_type.type.params.optional?
|
600
601
|
end
|
601
602
|
|
602
603
|
method_type.type.return_type if method_type
|
@@ -241,6 +241,22 @@ module Steep
|
|
241
241
|
|
242
242
|
instance = new(args: original, method_type: method_type, forward_arg_type: nil)
|
243
243
|
|
244
|
+
unless method_type.type.params
|
245
|
+
args.each do |arg|
|
246
|
+
case arg.type
|
247
|
+
when :arg
|
248
|
+
name = arg.children[0]
|
249
|
+
instance.params[name] = PositionalParameter.new(name: name, type: AST::Builtin.any_type, node: arg)
|
250
|
+
when :optarg
|
251
|
+
name = arg.children[0]
|
252
|
+
instance.params[name] = PositionalParameter.new(name: name, type: AST::Builtin.any_type, node: arg)
|
253
|
+
when :forward_arg
|
254
|
+
return instance.update(forward_arg_type: true)
|
255
|
+
end
|
256
|
+
end
|
257
|
+
return instance
|
258
|
+
end
|
259
|
+
|
244
260
|
positional_params = method_type.type.params.positional_params
|
245
261
|
|
246
262
|
loop do
|
@@ -500,6 +500,7 @@ module Steep
|
|
500
500
|
attr_reader :type
|
501
501
|
|
502
502
|
def initialize(node:, arguments:, type:)
|
503
|
+
raise "Untyped function is not supported" unless type.type.params
|
503
504
|
@node = node
|
504
505
|
@arguments = arguments
|
505
506
|
@type = type
|
@@ -508,9 +509,9 @@ module Steep
|
|
508
509
|
def params
|
509
510
|
case type
|
510
511
|
when Interface::MethodType
|
511
|
-
type.type.params
|
512
|
+
type.type.params or raise
|
512
513
|
when AST::Types::Proc
|
513
|
-
type.type.params
|
514
|
+
type.type.params or raise
|
514
515
|
else
|
515
516
|
raise
|
516
517
|
end
|
@@ -526,10 +527,12 @@ module Steep
|
|
526
527
|
end
|
527
528
|
|
528
529
|
def positional_params
|
530
|
+
params or raise
|
529
531
|
params.positional_params
|
530
532
|
end
|
531
533
|
|
532
534
|
def keyword_params
|
535
|
+
params or raise
|
533
536
|
params.keyword_params
|
534
537
|
end
|
535
538
|
|
data/lib/steep/version.rb
CHANGED
@@ -28,9 +28,9 @@ module Steep
|
|
28
28
|
|
29
29
|
def type_1_opt: (t?) -> RBS::Types::t?
|
30
30
|
|
31
|
-
def function_1: (Interface::Function func) -> RBS::Types::
|
31
|
+
def function_1: (Interface::Function func) -> RBS::Types::function
|
32
32
|
|
33
|
-
def params: (RBS::Types::
|
33
|
+
def params: (RBS::Types::function `type`) -> Interface::Function::Params?
|
34
34
|
|
35
35
|
def type_param: (RBS::AST::TypeParam type_param) -> Interface::TypeParam
|
36
36
|
|