steep 1.7.0.dev.4 → 1.7.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +49 -0
- data/README.md +18 -0
- data/doc/shape.md +18 -0
- data/guides/src/gem-rbs-collection/gem-rbs-collection.md +7 -24
- data/lib/steep/interface/builder.rb +11 -4
- data/lib/steep/rake_task.rb +132 -0
- data/lib/steep/signature/validator.rb +184 -132
- data/lib/steep/subtyping/check.rb +25 -21
- data/lib/steep/type_construction.rb +1 -0
- data/lib/steep/version.rb +1 -1
- data/steep.gemspec +4 -1
- metadata +3 -142
- data/.github/dependabot.yml +0 -28
- data/.github/workflows/ruby-windows.yml +0 -35
- data/.github/workflows/ruby.yml +0 -32
- data/.vscode/steep-shared.code-snippets +0 -41
- data/Gemfile +0 -14
- data/Gemfile.lock +0 -104
- data/Gemfile.steep +0 -0
- data/gemfile_steep/Gemfile +0 -3
- data/gemfile_steep/Gemfile.lock +0 -77
- data/rbs_collection.steep.lock.yaml +0 -108
- data/rbs_collection.steep.yaml +0 -23
- data/sig/shims/bundler.rbs +0 -3
- data/sig/shims/concurrent-ruby.rbs +0 -39
- data/sig/shims/exception.rbs +0 -4
- data/sig/shims/language-server_protocol.rbs +0 -450
- data/sig/shims/parser/comment.rbs +0 -33
- data/sig/shims/parser/nodes.rbs +0 -252
- data/sig/shims/parser/source/map.rbs +0 -146
- data/sig/shims/parser/source/range.rbs +0 -237
- data/sig/shims/parser.rbs +0 -69
- data/sig/shims/string.rbs +0 -4
- data/sig/shims/tagged_logging.rbs +0 -6
- data/sig/shims/yaml.rbs +0 -4
- data/sig/steep/annotation_parser.rbs +0 -60
- data/sig/steep/ast/annotation/collection.rbs +0 -78
- data/sig/steep/ast/annotation.rbs +0 -121
- data/sig/steep/ast/builtin.rbs +0 -69
- data/sig/steep/ast/ignore.rbs +0 -66
- data/sig/steep/ast/node/type_application.rbs +0 -31
- data/sig/steep/ast/node/type_assertion.rbs +0 -32
- data/sig/steep/ast/types/any.rbs +0 -29
- data/sig/steep/ast/types/boolean.rbs +0 -31
- data/sig/steep/ast/types/bot.rbs +0 -29
- data/sig/steep/ast/types/class.rbs +0 -33
- data/sig/steep/ast/types/factory.rbs +0 -110
- data/sig/steep/ast/types/helper.rbs +0 -24
- data/sig/steep/ast/types/instance.rbs +0 -33
- data/sig/steep/ast/types/intersection.rbs +0 -40
- data/sig/steep/ast/types/literal.rbs +0 -35
- data/sig/steep/ast/types/logic.rbs +0 -83
- data/sig/steep/ast/types/name.rbs +0 -84
- data/sig/steep/ast/types/nil.rbs +0 -31
- data/sig/steep/ast/types/proc.rbs +0 -53
- data/sig/steep/ast/types/record.rbs +0 -39
- data/sig/steep/ast/types/self.rbs +0 -33
- data/sig/steep/ast/types/top.rbs +0 -29
- data/sig/steep/ast/types/tuple.rbs +0 -37
- data/sig/steep/ast/types/union.rbs +0 -40
- data/sig/steep/ast/types/var.rbs +0 -42
- data/sig/steep/ast/types/void.rbs +0 -29
- data/sig/steep/ast/types.rbs +0 -16
- data/sig/steep/cli.rbs +0 -55
- data/sig/steep/diagnostic/deprecated/else_on_exhaustive_case.rbs +0 -13
- data/sig/steep/diagnostic/deprecated/unknown_constant_assigned.rbs +0 -15
- data/sig/steep/diagnostic/helper.rbs +0 -15
- data/sig/steep/diagnostic/lsp_formatter.rbs +0 -36
- data/sig/steep/diagnostic/ruby.rbs +0 -703
- data/sig/steep/diagnostic/signature.rbs +0 -252
- data/sig/steep/drivers/annotations.rbs +0 -17
- data/sig/steep/drivers/check.rbs +0 -33
- data/sig/steep/drivers/checkfile.rbs +0 -27
- data/sig/steep/drivers/diagnostic_printer.rbs +0 -25
- data/sig/steep/drivers/init.rbs +0 -19
- data/sig/steep/drivers/langserver.rbs +0 -36
- data/sig/steep/drivers/print_project.rbs +0 -15
- data/sig/steep/drivers/stats.rbs +0 -47
- data/sig/steep/drivers/utils/driver_helper.rbs +0 -25
- data/sig/steep/drivers/utils/jobs_option.rbs +0 -19
- data/sig/steep/drivers/validate.rbs +0 -15
- data/sig/steep/drivers/vendor.rbs +0 -19
- data/sig/steep/drivers/watch.rbs +0 -27
- data/sig/steep/drivers/worker.rbs +0 -29
- data/sig/steep/equatable.rbs +0 -11
- data/sig/steep/expectations.rbs +0 -72
- data/sig/steep/index/rbs_index.rbs +0 -141
- data/sig/steep/index/signature_symbol_provider.rbs +0 -41
- data/sig/steep/index/source_index.rbs +0 -63
- data/sig/steep/interface/block.rbs +0 -41
- data/sig/steep/interface/builder.rbs +0 -111
- data/sig/steep/interface/function.rbs +0 -271
- data/sig/steep/interface/method_type.rbs +0 -105
- data/sig/steep/interface/shape.rbs +0 -80
- data/sig/steep/interface/substitution.rbs +0 -51
- data/sig/steep/interface/type_param.rbs +0 -43
- data/sig/steep/method_name.rbs +0 -30
- data/sig/steep/module_helper.rbs +0 -16
- data/sig/steep/node_helper.rbs +0 -91
- data/sig/steep/path_helper.rbs +0 -15
- data/sig/steep/project/dsl.rbs +0 -108
- data/sig/steep/project/options.rbs +0 -47
- data/sig/steep/project/pattern.rbs +0 -47
- data/sig/steep/project/target.rbs +0 -25
- data/sig/steep/project.rbs +0 -26
- data/sig/steep/range_extension.rbs +0 -7
- data/sig/steep/server/base_worker.rbs +0 -49
- data/sig/steep/server/change_buffer.rbs +0 -38
- data/sig/steep/server/delay_queue.rbs +0 -37
- data/sig/steep/server/interaction_worker.rbs +0 -90
- data/sig/steep/server/lsp_formatter.rbs +0 -63
- data/sig/steep/server/master.rbs +0 -299
- data/sig/steep/server/type_check_worker.rbs +0 -141
- data/sig/steep/server/worker_process.rbs +0 -97
- data/sig/steep/services/completion_provider.rbs +0 -264
- data/sig/steep/services/content_change.rbs +0 -37
- data/sig/steep/services/file_loader.rbs +0 -21
- data/sig/steep/services/goto_service.rbs +0 -106
- data/sig/steep/services/hover_provider/rbs.rbs +0 -47
- data/sig/steep/services/hover_provider/ruby.rbs +0 -127
- data/sig/steep/services/hover_provider/singleton_methods.rbs +0 -11
- data/sig/steep/services/path_assignment.rbs +0 -21
- data/sig/steep/services/signature_help_provider.rbs +0 -51
- data/sig/steep/services/signature_service.rbs +0 -156
- data/sig/steep/services/stats_calculator.rbs +0 -41
- data/sig/steep/services/type_check_service.rbs +0 -112
- data/sig/steep/services/type_name_completion.rbs +0 -135
- data/sig/steep/signature/validator.rbs +0 -85
- data/sig/steep/source/ignore_ranges.rbs +0 -38
- data/sig/steep/source.rbs +0 -105
- data/sig/steep/subtyping/cache.rbs +0 -17
- data/sig/steep/subtyping/check.rbs +0 -131
- data/sig/steep/subtyping/constraints.rbs +0 -111
- data/sig/steep/subtyping/relation.rbs +0 -63
- data/sig/steep/subtyping/result.rbs +0 -179
- data/sig/steep/subtyping/variable_variance.rbs +0 -25
- data/sig/steep/thread_waiter.rbs +0 -13
- data/sig/steep/type_construction.rbs +0 -542
- data/sig/steep/type_inference/block_params.rbs +0 -170
- data/sig/steep/type_inference/case_when.rbs +0 -130
- data/sig/steep/type_inference/constant_env.rbs +0 -29
- data/sig/steep/type_inference/context.rbs +0 -216
- data/sig/steep/type_inference/context_array.rbs +0 -38
- data/sig/steep/type_inference/logic_type_interpreter.rbs +0 -108
- data/sig/steep/type_inference/method_call.rbs +0 -124
- data/sig/steep/type_inference/method_params.rbs +0 -127
- data/sig/steep/type_inference/multiple_assignment.rbs +0 -76
- data/sig/steep/type_inference/send_args.rbs +0 -243
- data/sig/steep/type_inference/type_env.rbs +0 -160
- data/sig/steep/type_inference/type_env_builder.rbs +0 -81
- data/sig/steep/typing.rbs +0 -75
- data/sig/steep.rbs +0 -45
@@ -5,10 +5,23 @@ module Steep
|
|
5
5
|
Declarations = RBS::AST::Declarations
|
6
6
|
|
7
7
|
attr_reader :checker
|
8
|
+
attr_reader :context
|
8
9
|
|
9
10
|
def initialize(checker:)
|
10
11
|
@checker = checker
|
11
12
|
@errors = []
|
13
|
+
@context = []
|
14
|
+
end
|
15
|
+
|
16
|
+
def push_context(self_type: latest_context[0], class_type: latest_context[1], instance_type: latest_context[2])
|
17
|
+
@context.push([self_type, class_type, instance_type])
|
18
|
+
yield
|
19
|
+
ensure
|
20
|
+
@context.pop
|
21
|
+
end
|
22
|
+
|
23
|
+
def latest_context
|
24
|
+
context.last || [nil, nil, nil]
|
12
25
|
end
|
13
26
|
|
14
27
|
def has_error?
|
@@ -72,11 +85,13 @@ module Steep
|
|
72
85
|
|
73
86
|
constraints = Subtyping::Constraints.empty
|
74
87
|
|
88
|
+
self_type, class_type, instance_type = latest_context
|
89
|
+
|
75
90
|
checker.check(
|
76
91
|
Subtyping::Relation.new(sub_type: arg_type, super_type: upper_bound_type),
|
77
|
-
self_type:
|
78
|
-
class_type:
|
79
|
-
instance_type:
|
92
|
+
self_type: self_type,
|
93
|
+
class_type: class_type,
|
94
|
+
instance_type: instance_type,
|
80
95
|
constraints: constraints
|
81
96
|
).else do |result|
|
82
97
|
@errors << Diagnostic::Signature::UnsatisfiableTypeApplication.new(
|
@@ -236,25 +251,113 @@ module Steep
|
|
236
251
|
end
|
237
252
|
end
|
238
253
|
|
239
|
-
def validate_one_class_decl(name)
|
254
|
+
def validate_one_class_decl(name, entry)
|
240
255
|
rescue_validation_errors(name) do
|
241
256
|
Steep.logger.debug { "Validating class definition `#{name}`..." }
|
242
257
|
|
258
|
+
class_type = AST::Types::Name::Singleton.new(name: name, location: nil)
|
259
|
+
instance_type = AST::Types::Name::Instance.new(
|
260
|
+
name: name,
|
261
|
+
args: entry.type_params.map { AST::Types::Any.new(location: nil) },
|
262
|
+
location: nil
|
263
|
+
)
|
264
|
+
|
243
265
|
Steep.logger.tagged "#{name}" do
|
244
266
|
builder.build_instance(name).tap do |definition|
|
245
267
|
upper_bounds = definition.type_params_decl.each.with_object({}) do |param, bounds|
|
246
268
|
bounds[param.name] = factory.type_opt(param.upper_bound)
|
247
269
|
end
|
248
270
|
|
249
|
-
|
271
|
+
self_type = AST::Types::Name::Instance.new(
|
272
|
+
name: name,
|
273
|
+
args: entry.type_params.map { AST::Types::Var.new(name: _1.name) },
|
274
|
+
location: nil
|
275
|
+
)
|
276
|
+
|
277
|
+
push_context(self_type: self_type, class_type: class_type, instance_type: instance_type) do
|
278
|
+
checker.push_variable_bounds(upper_bounds) do
|
279
|
+
definition.instance_variables.each do |name, var|
|
280
|
+
if parent = var.parent_variable
|
281
|
+
var_type = checker.factory.type(var.type)
|
282
|
+
parent_type = checker.factory.type(parent.type)
|
283
|
+
|
284
|
+
relation = Subtyping::Relation.new(sub_type: var_type, super_type: parent_type)
|
285
|
+
result1 = checker.check(relation, self_type: nil, instance_type: nil, class_type: nil, constraints: Subtyping::Constraints.empty)
|
286
|
+
result2 = checker.check(relation.flip, self_type: nil, instance_type: nil, class_type: nil, constraints: Subtyping::Constraints.empty)
|
287
|
+
|
288
|
+
unless result1.success? and result2.success?
|
289
|
+
@errors << Diagnostic::Signature::InstanceVariableTypeError.new(
|
290
|
+
name: name,
|
291
|
+
location: var.type.location,
|
292
|
+
var_type: var_type,
|
293
|
+
parent_type: parent_type
|
294
|
+
)
|
295
|
+
end
|
296
|
+
end
|
297
|
+
end
|
298
|
+
|
299
|
+
ancestors = builder.ancestor_builder.one_instance_ancestors(name)
|
300
|
+
mixin_constraints(definition, ancestors.included_modules || raise, immediate_self_types: ancestors.self_types).each do |relation, ancestor|
|
301
|
+
checker.check(
|
302
|
+
relation,
|
303
|
+
self_type: AST::Types::Self.instance,
|
304
|
+
instance_type: AST::Types::Instance.instance,
|
305
|
+
class_type: AST::Types::Class.instance,
|
306
|
+
constraints: Subtyping::Constraints.empty
|
307
|
+
).else do
|
308
|
+
raise if ancestor.source.is_a?(Symbol)
|
309
|
+
|
310
|
+
@errors << Diagnostic::Signature::ModuleSelfTypeError.new(
|
311
|
+
name: name,
|
312
|
+
location: ancestor.source&.location || raise,
|
313
|
+
ancestor: ancestor,
|
314
|
+
relation: relation
|
315
|
+
)
|
316
|
+
end
|
317
|
+
end
|
318
|
+
|
319
|
+
ancestors.each_ancestor do |ancestor|
|
320
|
+
case ancestor
|
321
|
+
when RBS::Definition::Ancestor::Instance
|
322
|
+
validate_ancestor_application(name, ancestor)
|
323
|
+
end
|
324
|
+
end
|
325
|
+
|
326
|
+
validate_definition_type(definition)
|
327
|
+
end
|
328
|
+
end
|
329
|
+
end
|
330
|
+
|
331
|
+
builder.build_singleton(name).tap do |definition|
|
332
|
+
entry =
|
333
|
+
case definition.entry
|
334
|
+
when RBS::Environment::ClassEntry, RBS::Environment::ModuleEntry
|
335
|
+
definition.entry
|
336
|
+
else
|
337
|
+
raise
|
338
|
+
end
|
339
|
+
|
340
|
+
push_context(self_type: class_type, class_type: class_type, instance_type: instance_type) do
|
250
341
|
definition.instance_variables.each do |name, var|
|
251
342
|
if parent = var.parent_variable
|
252
343
|
var_type = checker.factory.type(var.type)
|
253
344
|
parent_type = checker.factory.type(parent.type)
|
254
345
|
|
255
346
|
relation = Subtyping::Relation.new(sub_type: var_type, super_type: parent_type)
|
256
|
-
result1 = checker.check(
|
257
|
-
|
347
|
+
result1 = checker.check(
|
348
|
+
relation,
|
349
|
+
self_type: AST::Types::Self.instance,
|
350
|
+
instance_type: AST::Types::Instance.instance,
|
351
|
+
class_type: AST::Types::Class.instance,
|
352
|
+
constraints: Subtyping::Constraints.empty
|
353
|
+
)
|
354
|
+
result2 = checker.check(
|
355
|
+
relation.flip,
|
356
|
+
self_type: AST::Types::Self.instance,
|
357
|
+
instance_type: AST::Types::Instance.instance,
|
358
|
+
class_type: AST::Types::Class.instance,
|
359
|
+
constraints: Subtyping::Constraints.empty
|
360
|
+
)
|
258
361
|
|
259
362
|
unless result1.success? and result2.success?
|
260
363
|
@errors << Diagnostic::Signature::InstanceVariableTypeError.new(
|
@@ -267,11 +370,32 @@ module Steep
|
|
267
370
|
end
|
268
371
|
end
|
269
372
|
|
270
|
-
|
271
|
-
|
373
|
+
definition.class_variables.each do |name, var|
|
374
|
+
if var.declared_in == definition.type_name
|
375
|
+
if (parent = var.parent_variable) && var.declared_in != parent.declared_in
|
376
|
+
class_var = entry.decls.flat_map {|decl| decl.decl.members }.find do |member|
|
377
|
+
member.is_a?(RBS::AST::Members::ClassVariable) && member.name == name
|
378
|
+
end
|
379
|
+
|
380
|
+
if class_var
|
381
|
+
loc = class_var.location #: RBS::Location[untyped, untyped]?
|
382
|
+
@errors << Diagnostic::Signature::ClassVariableDuplicationError.new(
|
383
|
+
class_name: definition.type_name,
|
384
|
+
other_class_name: parent.declared_in,
|
385
|
+
variable_name: name,
|
386
|
+
location: loc&.[](:name) || raise
|
387
|
+
)
|
388
|
+
end
|
389
|
+
end
|
390
|
+
end
|
391
|
+
end
|
392
|
+
|
393
|
+
ancestors = builder.ancestor_builder.one_singleton_ancestors(name)
|
394
|
+
ancestors.extended_modules or raise
|
395
|
+
mixin_constraints(definition, ancestors.extended_modules, immediate_self_types: ancestors.self_types).each do |relation, ancestor|
|
272
396
|
checker.check(
|
273
397
|
relation,
|
274
|
-
self_type: AST::Types::Self.instance,
|
398
|
+
self_type: AST::Types::Self.instance ,
|
275
399
|
instance_type: AST::Types::Instance.instance,
|
276
400
|
class_type: AST::Types::Class.instance,
|
277
401
|
constraints: Subtyping::Constraints.empty
|
@@ -286,7 +410,6 @@ module Steep
|
|
286
410
|
)
|
287
411
|
end
|
288
412
|
end
|
289
|
-
|
290
413
|
ancestors.each_ancestor do |ancestor|
|
291
414
|
case ancestor
|
292
415
|
when RBS::Definition::Ancestor::Instance
|
@@ -297,97 +420,6 @@ module Steep
|
|
297
420
|
validate_definition_type(definition)
|
298
421
|
end
|
299
422
|
end
|
300
|
-
|
301
|
-
builder.build_singleton(name).tap do |definition|
|
302
|
-
entry =
|
303
|
-
case definition.entry
|
304
|
-
when RBS::Environment::ClassEntry, RBS::Environment::ModuleEntry
|
305
|
-
definition.entry
|
306
|
-
else
|
307
|
-
raise
|
308
|
-
end
|
309
|
-
|
310
|
-
definition.instance_variables.each do |name, var|
|
311
|
-
if parent = var.parent_variable
|
312
|
-
var_type = checker.factory.type(var.type)
|
313
|
-
parent_type = checker.factory.type(parent.type)
|
314
|
-
|
315
|
-
relation = Subtyping::Relation.new(sub_type: var_type, super_type: parent_type)
|
316
|
-
result1 = checker.check(
|
317
|
-
relation,
|
318
|
-
self_type: AST::Types::Self.instance,
|
319
|
-
instance_type: AST::Types::Instance.instance,
|
320
|
-
class_type: AST::Types::Class.instance,
|
321
|
-
constraints: Subtyping::Constraints.empty
|
322
|
-
)
|
323
|
-
result2 = checker.check(
|
324
|
-
relation.flip,
|
325
|
-
self_type: AST::Types::Self.instance,
|
326
|
-
instance_type: AST::Types::Instance.instance,
|
327
|
-
class_type: AST::Types::Class.instance,
|
328
|
-
constraints: Subtyping::Constraints.empty
|
329
|
-
)
|
330
|
-
|
331
|
-
unless result1.success? and result2.success?
|
332
|
-
@errors << Diagnostic::Signature::InstanceVariableTypeError.new(
|
333
|
-
name: name,
|
334
|
-
location: var.type.location,
|
335
|
-
var_type: var_type,
|
336
|
-
parent_type: parent_type
|
337
|
-
)
|
338
|
-
end
|
339
|
-
end
|
340
|
-
end
|
341
|
-
|
342
|
-
definition.class_variables.each do |name, var|
|
343
|
-
if var.declared_in == definition.type_name
|
344
|
-
if (parent = var.parent_variable) && var.declared_in != parent.declared_in
|
345
|
-
class_var = entry.decls.flat_map {|decl| decl.decl.members }.find do |member|
|
346
|
-
member.is_a?(RBS::AST::Members::ClassVariable) && member.name == name
|
347
|
-
end
|
348
|
-
|
349
|
-
if class_var
|
350
|
-
loc = class_var.location #: RBS::Location[untyped, untyped]?
|
351
|
-
@errors << Diagnostic::Signature::ClassVariableDuplicationError.new(
|
352
|
-
class_name: definition.type_name,
|
353
|
-
other_class_name: parent.declared_in,
|
354
|
-
variable_name: name,
|
355
|
-
location: loc&.[](:name) || raise
|
356
|
-
)
|
357
|
-
end
|
358
|
-
end
|
359
|
-
end
|
360
|
-
end
|
361
|
-
|
362
|
-
ancestors = builder.ancestor_builder.one_singleton_ancestors(name)
|
363
|
-
ancestors.extended_modules or raise
|
364
|
-
mixin_constraints(definition, ancestors.extended_modules, immediate_self_types: ancestors.self_types).each do |relation, ancestor|
|
365
|
-
checker.check(
|
366
|
-
relation,
|
367
|
-
self_type: AST::Types::Self.instance ,
|
368
|
-
instance_type: AST::Types::Instance.instance,
|
369
|
-
class_type: AST::Types::Class.instance,
|
370
|
-
constraints: Subtyping::Constraints.empty
|
371
|
-
).else do
|
372
|
-
raise if ancestor.source.is_a?(Symbol)
|
373
|
-
|
374
|
-
@errors << Diagnostic::Signature::ModuleSelfTypeError.new(
|
375
|
-
name: name,
|
376
|
-
location: ancestor.source&.location || raise,
|
377
|
-
ancestor: ancestor,
|
378
|
-
relation: relation
|
379
|
-
)
|
380
|
-
end
|
381
|
-
end
|
382
|
-
ancestors.each_ancestor do |ancestor|
|
383
|
-
case ancestor
|
384
|
-
when RBS::Definition::Ancestor::Instance
|
385
|
-
validate_ancestor_application(name, ancestor)
|
386
|
-
end
|
387
|
-
end
|
388
|
-
|
389
|
-
validate_definition_type(definition)
|
390
|
-
end
|
391
423
|
end
|
392
424
|
end
|
393
425
|
end
|
@@ -397,7 +429,7 @@ module Steep
|
|
397
429
|
|
398
430
|
case entry
|
399
431
|
when RBS::Environment::ClassEntry, RBS::Environment::ModuleEntry
|
400
|
-
validate_one_class_decl(name)
|
432
|
+
validate_one_class_decl(name, entry)
|
401
433
|
when RBS::Environment::ClassAliasEntry, RBS::Environment::ModuleAliasEntry
|
402
434
|
validate_one_class_alias(name, entry)
|
403
435
|
end
|
@@ -453,23 +485,31 @@ module Steep
|
|
453
485
|
bounds[param.name] = factory.type_opt(param.upper_bound)
|
454
486
|
end
|
455
487
|
|
456
|
-
|
457
|
-
|
458
|
-
|
459
|
-
|
460
|
-
|
461
|
-
|
462
|
-
|
463
|
-
|
464
|
-
|
465
|
-
|
466
|
-
|
467
|
-
|
468
|
-
|
469
|
-
|
470
|
-
ancestor
|
471
|
-
|
472
|
-
|
488
|
+
self_type = AST::Types::Name::Interface.new(
|
489
|
+
name: name,
|
490
|
+
args: definition.type_params.map { AST::Types::Var.new(name: _1) },
|
491
|
+
location: nil
|
492
|
+
)
|
493
|
+
|
494
|
+
push_context(self_type: self_type, class_type: nil, instance_type: nil) do
|
495
|
+
checker.push_variable_bounds(upper_bounds) do
|
496
|
+
validate_definition_type(definition)
|
497
|
+
|
498
|
+
ancestors = builder.ancestor_builder.one_interface_ancestors(name)
|
499
|
+
ancestors.each_ancestor do |ancestor|
|
500
|
+
case ancestor
|
501
|
+
when RBS::Definition::Ancestor::Instance
|
502
|
+
# Interface ancestor cannot be other than Interface
|
503
|
+
ancestor.source.is_a?(Symbol) and raise
|
504
|
+
|
505
|
+
defn = builder.build_interface(ancestor.name)
|
506
|
+
validate_type_application_constraints(
|
507
|
+
ancestor.name,
|
508
|
+
defn.type_params_decl,
|
509
|
+
ancestor.args,
|
510
|
+
location: ancestor.source&.location || raise
|
511
|
+
)
|
512
|
+
end
|
473
513
|
end
|
474
514
|
end
|
475
515
|
end
|
@@ -519,21 +559,33 @@ module Steep
|
|
519
559
|
end
|
520
560
|
|
521
561
|
def validate_one_alias(name, entry = env.type_alias_decls[name])
|
522
|
-
|
523
|
-
|
562
|
+
*, inner_most_outer_module = entry.outer
|
563
|
+
if inner_most_outer_module
|
564
|
+
class_type = AST::Types::Name::Singleton.new(name: inner_most_outer_module.name, location: nil)
|
565
|
+
instance_type = AST::Types::Name::Instance.new(
|
566
|
+
name: inner_most_outer_module.name,
|
567
|
+
args: inner_most_outer_module.type_params.map { AST::Types::Any.new(location: nil) },
|
568
|
+
location: nil
|
569
|
+
)
|
570
|
+
end
|
524
571
|
|
525
|
-
|
526
|
-
|
527
|
-
|
528
|
-
end
|
572
|
+
push_context(class_type: class_type, instance_type: instance_type, self_type: nil) do
|
573
|
+
rescue_validation_errors(name) do
|
574
|
+
Steep.logger.debug "Validating alias `#{name}`..."
|
529
575
|
|
530
|
-
|
531
|
-
|
532
|
-
|
576
|
+
unless name.namespace.empty?
|
577
|
+
outer = name.namespace.to_type_name
|
578
|
+
builder.validate_type_name(outer, entry.decl.location&.aref(:name))
|
579
|
+
end
|
580
|
+
|
581
|
+
upper_bounds = entry.decl.type_params.each.with_object({}) do |param, bounds|
|
582
|
+
bounds[param.name] = factory.type_opt(param.upper_bound)
|
583
|
+
end
|
533
584
|
|
534
|
-
|
535
|
-
|
536
|
-
|
585
|
+
validator.validate_type_alias(entry: entry) do |type|
|
586
|
+
checker.push_variable_bounds(upper_bounds) do
|
587
|
+
validate_type(entry.decl.type)
|
588
|
+
end
|
537
589
|
end
|
538
590
|
end
|
539
591
|
end
|
@@ -798,33 +798,37 @@ module Steep
|
|
798
798
|
end
|
799
799
|
|
800
800
|
def check_method_type(name, relation)
|
801
|
-
relation.
|
801
|
+
Steep.logger.tagged "#{name} : #{relation.sub_type} <: #{relation.super_type}" do
|
802
|
+
relation.method!
|
802
803
|
|
803
|
-
|
804
|
+
sub_type, super_type = relation
|
804
805
|
|
805
|
-
|
806
|
-
|
806
|
+
sub_type.type_params.empty? or raise "Expected monomorphic method type: #{sub_type}"
|
807
|
+
super_type.type_params.empty? or raise "Expected monomorphic method type: #{super_type}"
|
807
808
|
|
808
|
-
|
809
|
-
|
810
|
-
|
811
|
-
|
812
|
-
|
813
|
-
|
814
|
-
|
815
|
-
|
816
|
-
|
817
|
-
|
818
|
-
|
819
|
-
|
820
|
-
|
821
|
-
|
822
|
-
|
809
|
+
All(relation) do |result|
|
810
|
+
type_relation = Relation.new(sub_type: sub_type.type, super_type: super_type.type)
|
811
|
+
|
812
|
+
ret = expand_block_given(name, Relation.new(sub_type: sub_type.block, super_type: super_type.block))
|
813
|
+
|
814
|
+
case ret
|
815
|
+
when true
|
816
|
+
result.add(type_relation) { check_function(name, type_relation) }
|
817
|
+
when Relation
|
818
|
+
result.add(type_relation) { check_function(name, type_relation) }
|
819
|
+
result.add(ret) do
|
820
|
+
All(ret) do |result|
|
821
|
+
result.add_result(check_self_type_binding(ret, ret.super_type.self_type, ret.sub_type.self_type))
|
822
|
+
result.add(Relation(ret.super_type.type, ret.sub_type.type)) do |block_relation|
|
823
|
+
check_function(name, block_relation)
|
824
|
+
end
|
823
825
|
end
|
824
826
|
end
|
827
|
+
when Result::Failure
|
828
|
+
result.add(ret.relation) { ret }
|
829
|
+
end.tap do |ret|
|
830
|
+
Steep.logger.debug "result=#{ret.class}"
|
825
831
|
end
|
826
|
-
when Result::Failure
|
827
|
-
result.add(ret.relation) { ret }
|
828
832
|
end
|
829
833
|
end
|
830
834
|
end
|
@@ -2106,6 +2106,7 @@ module Steep
|
|
2106
2106
|
end
|
2107
2107
|
|
2108
2108
|
if body
|
2109
|
+
resbody_construction.typing.add_context_for_node(body, context: resbody_construction.context)
|
2109
2110
|
resbody_construction.synthesize(body, hint: hint)
|
2110
2111
|
else
|
2111
2112
|
Pair.new(constr: body_constr, type: AST::Builtin.nil_type)
|
data/lib/steep/version.rb
CHANGED
data/steep.gemspec
CHANGED
@@ -18,8 +18,11 @@ Gem::Specification.new do |spec|
|
|
18
18
|
spec.metadata["source_code_uri"] = "https://github.com/soutaro/steep"
|
19
19
|
spec.metadata["changelog_uri"] = "https://github.com/soutaro/steep/blob/master/CHANGELOG.md"
|
20
20
|
|
21
|
+
skip_dirs = %w(test spec features smoke sig gemfile_steep .github .vscode)
|
22
|
+
skip_files = %w(Gemfile Gemfile.lock rbs_collection.steep.yaml rbs_collection.steep.lock.yaml)
|
23
|
+
|
21
24
|
spec.files = `git ls-files -z`.split("\x0").reject {|f|
|
22
|
-
|
25
|
+
skip_dirs.any? {|dir| f.start_with?(dir + File::SEPARATOR) } || skip_files.include?(f)
|
23
26
|
}
|
24
27
|
|
25
28
|
spec.bindir = "exe"
|