steep 1.0.0 → 1.1.0.pre.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.github/workflows/ruby-windows.yml +34 -0
- data/.github/workflows/ruby.yml +7 -2
- data/.gitignore +1 -0
- data/CHANGELOG.md +59 -0
- data/Gemfile +7 -4
- data/Gemfile.lock +17 -21
- data/Gemfile.steep +3 -0
- data/Gemfile.steep.lock +49 -0
- data/Rakefile +5 -0
- data/Steepfile +6 -1
- data/bin/setup +2 -0
- data/bin/steep +19 -0
- data/lib/steep/ast/builtin.rb +2 -2
- data/lib/steep/ast/types/factory.rb +7 -3
- data/lib/steep/ast/types/proc.rb +2 -0
- data/lib/steep/cli.rb +3 -1
- data/lib/steep/diagnostic/ruby.rb +50 -4
- data/lib/steep/diagnostic/signature.rb +18 -0
- data/lib/steep/drivers/check.rb +3 -3
- data/lib/steep/drivers/watch.rb +3 -1
- data/lib/steep/method_name.rb +9 -3
- data/lib/steep/node_helper.rb +49 -0
- data/lib/steep/path_helper.rb +22 -0
- data/lib/steep/project.rb +3 -15
- data/lib/steep/server/base_worker.rb +1 -0
- data/lib/steep/server/change_buffer.rb +1 -1
- data/lib/steep/server/interaction_worker.rb +3 -5
- data/lib/steep/server/master.rb +61 -45
- data/lib/steep/server/type_check_worker.rb +10 -25
- data/lib/steep/services/completion_provider.rb +25 -18
- data/lib/steep/services/goto_service.rb +2 -4
- data/lib/steep/services/hover_provider/rbs.rb +1 -1
- data/lib/steep/services/hover_provider/ruby.rb +30 -12
- data/lib/steep/services/stats_calculator.rb +0 -1
- data/lib/steep/services/type_check_service.rb +15 -12
- data/lib/steep/shims/symbol_start_with.rb +18 -0
- data/lib/steep/signature/validator.rb +25 -1
- data/lib/steep/source.rb +1 -1
- data/lib/steep/subtyping/check.rb +0 -3
- data/lib/steep/subtyping/constraints.rb +43 -14
- data/lib/steep/type_construction.rb +721 -764
- data/lib/steep/type_inference/constant_env.rb +0 -2
- data/lib/steep/type_inference/context.rb +23 -17
- data/lib/steep/type_inference/logic_type_interpreter.rb +210 -117
- data/lib/steep/type_inference/method_call.rb +80 -6
- data/lib/steep/type_inference/multiple_assignment.rb +189 -0
- data/lib/steep/type_inference/send_args.rb +1 -2
- data/lib/steep/type_inference/type_env.rb +273 -116
- data/lib/steep/type_inference/type_env_builder.rb +138 -0
- data/lib/steep/typing.rb +2 -0
- data/lib/steep/version.rb +1 -1
- data/lib/steep.rb +7 -5
- data/rbs_collection.steep.lock.yaml +112 -0
- data/rbs_collection.steep.yaml +19 -0
- data/sample/sig/conference.rbs +8 -0
- data/sig/shims/parser/source/map.rbs +146 -0
- data/sig/shims/parser/source/range.rbs +237 -0
- data/sig/shims/parser.rbs +17 -0
- data/sig/steep/ast/annotation/collection.rbs +75 -0
- data/sig/steep/ast/annotation.rbs +126 -0
- data/sig/steep/ast/builtin.rbs +69 -0
- data/sig/steep/ast/type_params.rbs +11 -0
- data/sig/steep/ast/types/any.rbs +29 -0
- data/sig/steep/ast/types/boolean.rbs +31 -0
- data/sig/steep/ast/types/bot.rbs +29 -0
- data/sig/steep/ast/types/class.rbs +29 -0
- data/sig/steep/ast/types/factory.rbs +76 -0
- data/sig/steep/ast/types/helper.rbs +19 -0
- data/sig/steep/ast/types/instance.rbs +29 -0
- data/sig/steep/ast/types/intersection.rbs +35 -0
- data/sig/steep/ast/types/literal.rbs +33 -0
- data/sig/steep/ast/types/logic.rbs +78 -0
- data/sig/steep/ast/types/name.rbs +71 -0
- data/sig/steep/ast/types/nil.rbs +31 -0
- data/sig/steep/ast/types/proc.rbs +46 -0
- data/sig/steep/ast/types/record.rbs +38 -0
- data/sig/steep/ast/types/self.rbs +29 -0
- data/sig/steep/ast/types/top.rbs +29 -0
- data/sig/steep/ast/types/tuple.rbs +34 -0
- data/sig/steep/ast/types/union.rbs +38 -0
- data/sig/steep/ast/types/var.rbs +37 -0
- data/sig/steep/ast/types/void.rbs +29 -0
- data/sig/steep/ast/types.rbs +37 -0
- data/sig/steep/diagnostic/deprecated/unknown_constant_assigned.rbs +15 -0
- data/sig/steep/diagnostic/helper.rbs +9 -0
- data/sig/steep/diagnostic/lsp_formatter.rbs +29 -0
- data/sig/steep/diagnostic/ruby.rbs +494 -0
- data/sig/steep/diagnostic/signature.rbs +215 -0
- data/sig/steep/interface/block.rbs +35 -0
- data/sig/steep/interface/function.rbs +253 -0
- data/sig/steep/interface/interface.rbs +23 -0
- data/sig/steep/interface/method_type.rbs +55 -0
- data/sig/steep/interface/substitution.rbs +53 -0
- data/sig/steep/interface/type_param.rbs +35 -0
- data/sig/steep/method_name.rbs +26 -0
- data/sig/steep/module_helper.rbs +7 -0
- data/sig/steep/node_helper.rbs +11 -0
- data/sig/steep/project/dsl.rbs +94 -0
- data/sig/steep/project/options.rbs +15 -0
- data/sig/steep/project/pattern.rbs +25 -0
- data/sig/steep/project/target.rbs +25 -0
- data/sig/steep/project.rbs +19 -0
- data/sig/steep/services/completion_provider.rbs +123 -0
- data/sig/steep/services/content_change.rbs +35 -0
- data/sig/steep/services/file_loader.rbs +13 -0
- data/sig/steep/services/goto_service.rbs +45 -0
- data/sig/steep/services/hover_provider/rbs.rbs +21 -0
- data/sig/steep/services/hover_provider/ruby.rbs +109 -0
- data/sig/steep/services/hover_provider/singleton_methods.rbs +11 -0
- data/sig/steep/services/path_assignment.rbs +21 -0
- data/sig/steep/services/signature_service.rbs +91 -0
- data/sig/steep/services/stats_calculator.rbs +17 -0
- data/sig/steep/services/type_check_service.rbs +93 -0
- data/sig/steep/source.rbs +55 -0
- data/sig/steep/subtyping/cache.rbs +17 -0
- data/sig/steep/subtyping/check.rbs +93 -0
- data/sig/steep/subtyping/constraints.rbs +111 -0
- data/sig/steep/subtyping/relation.rbs +51 -0
- data/sig/steep/subtyping/result.rbs +157 -0
- data/sig/steep/subtyping/variable_variance.rbs +23 -0
- data/sig/steep/type_construction.rbs +285 -0
- data/sig/steep/type_inference/block_params.rbs +52 -0
- data/sig/steep/type_inference/constant_env.rbs +27 -0
- data/sig/steep/type_inference/context.rbs +137 -0
- data/sig/steep/type_inference/logic_type_interpreter.rbs +72 -0
- data/sig/steep/type_inference/method_call.rbs +124 -0
- data/sig/steep/type_inference/method_params.rbs +104 -0
- data/sig/steep/type_inference/multiple_assignment.rbs +76 -0
- data/sig/steep/type_inference/type_env.rbs +158 -0
- data/sig/steep/type_inference/type_env_builder.rbs +77 -0
- data/sig/steep/typing.rbs +68 -0
- data/sig/steep.rbs +31 -0
- data/smoke/class/f.rb +1 -0
- data/smoke/class/test_expectations.yml +2 -2
- data/smoke/diagnostics/test_expectations.yml +4 -2
- data/smoke/regression/lambda.rb +3 -0
- data/smoke/regression/test_expectations.yml +12 -0
- data/steep.gemspec +1 -1
- metadata +95 -9
- data/lib/steep/subtyping/variable_occurrence.rb +0 -51
- data/lib/steep/type_inference/local_variable_type_env.rb +0 -249
- data/lib/steep/type_inference/logic.rb +0 -161
@@ -0,0 +1,93 @@
|
|
1
|
+
module Steep
|
2
|
+
module Services
|
3
|
+
class TypeCheckService
|
4
|
+
attr_reader project: untyped
|
5
|
+
|
6
|
+
attr_reader signature_validation_diagnostics: untyped
|
7
|
+
|
8
|
+
attr_reader source_files: untyped
|
9
|
+
|
10
|
+
attr_reader signature_services: untyped
|
11
|
+
|
12
|
+
class SourceFile
|
13
|
+
attr_reader path: untyped
|
14
|
+
|
15
|
+
attr_reader target: untyped
|
16
|
+
|
17
|
+
attr_reader content: untyped
|
18
|
+
|
19
|
+
attr_reader node: untyped
|
20
|
+
|
21
|
+
attr_reader typing: untyped
|
22
|
+
|
23
|
+
attr_reader errors: untyped
|
24
|
+
|
25
|
+
def initialize: (path: untyped, node: untyped, content: untyped, typing: untyped, errors: untyped) -> void
|
26
|
+
|
27
|
+
def self.with_syntax_error: (path: untyped, content: untyped, error: untyped) -> untyped
|
28
|
+
|
29
|
+
def self.with_typing: (path: untyped, content: untyped, typing: untyped, node: untyped) -> untyped
|
30
|
+
|
31
|
+
def self.no_data: (path: untyped, content: untyped) -> untyped
|
32
|
+
|
33
|
+
def update_content: (untyped content) -> untyped
|
34
|
+
|
35
|
+
def diagnostics: () -> untyped
|
36
|
+
end
|
37
|
+
|
38
|
+
class TargetRequest
|
39
|
+
attr_reader target: untyped
|
40
|
+
|
41
|
+
attr_reader source_paths: untyped
|
42
|
+
|
43
|
+
def initialize: (target: untyped) -> void
|
44
|
+
|
45
|
+
def signature_updated!: (?bool value) -> self
|
46
|
+
|
47
|
+
def signature_updated?: () -> untyped
|
48
|
+
|
49
|
+
def empty?: () -> untyped
|
50
|
+
|
51
|
+
def ==: (untyped other) -> untyped
|
52
|
+
|
53
|
+
alias eql? ==
|
54
|
+
|
55
|
+
def hash: () -> untyped
|
56
|
+
end
|
57
|
+
|
58
|
+
def initialize: (project: untyped) -> void
|
59
|
+
|
60
|
+
def signature_diagnostics: () -> untyped
|
61
|
+
|
62
|
+
def has_diagnostics?: () -> untyped
|
63
|
+
|
64
|
+
def diagnostics: () -> untyped
|
65
|
+
|
66
|
+
def each_diagnostics: () { (untyped) -> untyped } -> untyped
|
67
|
+
|
68
|
+
def update: (changes: untyped) -> untyped
|
69
|
+
|
70
|
+
def update_and_check: (changes: untyped, assignment: untyped) ?{ () -> untyped } -> untyped
|
71
|
+
|
72
|
+
def validate_signature: (path: untyped) { (untyped) -> untyped } -> untyped
|
73
|
+
|
74
|
+
def typecheck_source: (path: untyped, ?target: untyped) { (untyped) -> untyped } -> (nil | untyped)
|
75
|
+
|
76
|
+
def update_signature: (changes: untyped, requests: untyped) -> untyped
|
77
|
+
|
78
|
+
def update_sources: (changes: untyped, requests: untyped) -> untyped
|
79
|
+
|
80
|
+
def type_check_file: (target: untyped, subtyping: untyped, path: untyped, text: untyped) -> untyped
|
81
|
+
|
82
|
+
def self.type_check: (source: Source, subtyping: Subtyping::Check) -> Typing
|
83
|
+
|
84
|
+
def source_file?: (Pathname path) -> (untyped | nil)
|
85
|
+
|
86
|
+
def signature_file?: (Pathname path) -> untyped
|
87
|
+
|
88
|
+
def app_signature_file?: (Pathname path) -> untyped
|
89
|
+
|
90
|
+
def lib_signature_file?: (Pathname path) -> untyped
|
91
|
+
end
|
92
|
+
end
|
93
|
+
end
|
@@ -0,0 +1,55 @@
|
|
1
|
+
module Steep
|
2
|
+
class Source
|
3
|
+
class LocatedAnnotation
|
4
|
+
attr_reader line: untyped
|
5
|
+
|
6
|
+
attr_reader annotation: untyped
|
7
|
+
|
8
|
+
attr_reader source: untyped
|
9
|
+
|
10
|
+
def initialize: (line: untyped, source: untyped, annotation: untyped) -> void
|
11
|
+
|
12
|
+
def ==: (untyped other) -> untyped
|
13
|
+
end
|
14
|
+
|
15
|
+
attr_reader path: untyped
|
16
|
+
|
17
|
+
attr_reader node: untyped
|
18
|
+
|
19
|
+
attr_reader mapping: untyped
|
20
|
+
|
21
|
+
def initialize: (path: untyped, node: untyped, mapping: untyped) -> void
|
22
|
+
|
23
|
+
class Builder
|
24
|
+
def string_value: (untyped token) -> untyped
|
25
|
+
end
|
26
|
+
|
27
|
+
def self.new_parser: () -> untyped
|
28
|
+
|
29
|
+
def self.parse: (untyped source_code, path: untyped, factory: untyped) -> untyped
|
30
|
+
|
31
|
+
def self.construct_mapping: (node: untyped, annotations: untyped, mapping: untyped, ?line_range: untyped?) -> untyped
|
32
|
+
|
33
|
+
def self.each_child_node: (untyped node) { (untyped) -> untyped } -> untyped
|
34
|
+
|
35
|
+
def self.map_child_nodes: (untyped node) { (untyped) -> untyped } -> untyped
|
36
|
+
|
37
|
+
def annotations: (block: Parser::AST::Node, factory: AST::Types::Factory, context: RBS::Resolver::context) -> AST::Annotation::Collection
|
38
|
+
|
39
|
+
def each_annotation: () { (untyped, untyped) -> untyped } -> untyped
|
40
|
+
|
41
|
+
def each_heredoc_node: (?untyped node, ?untyped parents) { (untyped) -> untyped } -> untyped
|
42
|
+
|
43
|
+
def find_heredoc_nodes: (untyped line, untyped column, untyped position) -> (untyped | nil)
|
44
|
+
|
45
|
+
def find_nodes_loc: (untyped node, untyped position, untyped parents) -> untyped
|
46
|
+
|
47
|
+
def find_nodes: (line: Integer, column: Integer) -> ::Array[Parser::AST::Node]?
|
48
|
+
|
49
|
+
def self.delete_defs: (untyped node, untyped allow_list) -> untyped
|
50
|
+
|
51
|
+
def without_unrelated_defs: (line: untyped, column: untyped) -> (untyped | self)
|
52
|
+
|
53
|
+
def compact_siblings: (untyped node) -> untyped
|
54
|
+
end
|
55
|
+
end
|
@@ -0,0 +1,17 @@
|
|
1
|
+
module Steep
|
2
|
+
module Subtyping
|
3
|
+
class Cache
|
4
|
+
attr_reader subtypes: untyped
|
5
|
+
|
6
|
+
def initialize: () -> void
|
7
|
+
|
8
|
+
def subtype: (untyped relation, untyped self_type, untyped instance_type, untyped class_type, untyped bounds) -> untyped
|
9
|
+
|
10
|
+
def []: (untyped relation, untyped self_type, untyped instance_type, untyped class_type, untyped bounds) -> untyped
|
11
|
+
|
12
|
+
def []=: (untyped relation, untyped self_type, untyped instance_type, untyped class_type, untyped bounds, untyped value) -> untyped
|
13
|
+
|
14
|
+
def no_subtype_cache?: () -> untyped
|
15
|
+
end
|
16
|
+
end
|
17
|
+
end
|
@@ -0,0 +1,93 @@
|
|
1
|
+
module Steep
|
2
|
+
module Subtyping
|
3
|
+
class Check
|
4
|
+
attr_reader factory: AST::Types::Factory
|
5
|
+
|
6
|
+
attr_reader cache: untyped
|
7
|
+
|
8
|
+
attr_reader assumptions: untyped
|
9
|
+
|
10
|
+
def initialize: (factory: untyped) -> void
|
11
|
+
|
12
|
+
def with_context: (self_type: untyped, instance_type: untyped, class_type: untyped, constraints: untyped) { () -> untyped } -> untyped
|
13
|
+
|
14
|
+
def push_assumption: (untyped relation) { () -> untyped } -> untyped
|
15
|
+
|
16
|
+
def push_variable_bounds: (untyped params) { () -> untyped } -> untyped
|
17
|
+
|
18
|
+
def variable_upper_bound: (untyped name) -> (untyped | nil)
|
19
|
+
|
20
|
+
def self_type: () -> untyped
|
21
|
+
|
22
|
+
def instance_type: () -> untyped
|
23
|
+
|
24
|
+
def class_type: () -> untyped
|
25
|
+
|
26
|
+
def constraints: () -> untyped
|
27
|
+
|
28
|
+
def each_ancestor: (untyped ancestors) { (untyped) -> untyped } -> untyped
|
29
|
+
|
30
|
+
def instance_super_types: (untyped type_name, args: untyped) -> untyped
|
31
|
+
|
32
|
+
def singleton_super_types: (untyped type_name) -> untyped
|
33
|
+
|
34
|
+
def check: (untyped relation, constraints: untyped, self_type: untyped, instance_type: untyped, class_type: untyped) -> untyped
|
35
|
+
|
36
|
+
def check_type: (untyped relation) -> untyped
|
37
|
+
|
38
|
+
def cache_bounds: (untyped relation) -> untyped
|
39
|
+
|
40
|
+
def alias?: (untyped `type`) -> untyped
|
41
|
+
|
42
|
+
def cacheable?: (untyped relation) -> untyped
|
43
|
+
|
44
|
+
def true_type?: (untyped `type`) -> untyped
|
45
|
+
|
46
|
+
def false_type?: (untyped `type`) -> untyped
|
47
|
+
|
48
|
+
include Result::Helper
|
49
|
+
|
50
|
+
def check_type0: (untyped relation) -> untyped
|
51
|
+
|
52
|
+
def definition_for_type: (untyped `type`) -> untyped
|
53
|
+
|
54
|
+
def arg_type?: (untyped `type`) -> untyped
|
55
|
+
|
56
|
+
def check_type_arg: (untyped relation) -> untyped
|
57
|
+
|
58
|
+
def same_type?: (untyped relation) -> (true | untyped)
|
59
|
+
|
60
|
+
def check_interface: (untyped relation) -> untyped
|
61
|
+
|
62
|
+
def check_method: (untyped name, untyped relation) -> untyped
|
63
|
+
|
64
|
+
def check_type_application: (untyped result, untyped type_params, untyped type_args) { () -> untyped } -> untyped
|
65
|
+
|
66
|
+
def check_generic_method_type: (untyped name, untyped relation) -> untyped
|
67
|
+
|
68
|
+
def check_constraints: (untyped relation, variables: untyped, variance: untyped) -> untyped
|
69
|
+
|
70
|
+
def check_method_type: (untyped name, untyped relation) -> untyped
|
71
|
+
|
72
|
+
def check_block_given: (untyped name, untyped relation) { () -> untyped } -> untyped
|
73
|
+
|
74
|
+
def check_function: (untyped name, untyped relation) -> untyped
|
75
|
+
|
76
|
+
def check_method_params: (untyped name, untyped relation) -> untyped
|
77
|
+
|
78
|
+
# ```rbs
|
79
|
+
# (Symbol, Relation[MethodType]) -> (Array[[Symbol, Symbol]] | Result::t)
|
80
|
+
# [A] (Symbol, Relation[MethodType]) { (Array[[Symbol, Symbol]]) -> A } -> (A | Result::t)
|
81
|
+
# ````
|
82
|
+
def match_method_type: (untyped name, untyped relation) { (untyped) -> untyped } -> untyped
|
83
|
+
|
84
|
+
def match_params: (untyped name, untyped relation) -> untyped
|
85
|
+
|
86
|
+
def expand_alias: (untyped `type`) { () -> untyped } -> untyped
|
87
|
+
|
88
|
+
# Returns the shortest type paths for one of the _unknown_ type variables.
|
89
|
+
# Returns nil if there is no path.
|
90
|
+
def hole_path: (untyped `type`, ?untyped path) -> untyped
|
91
|
+
end
|
92
|
+
end
|
93
|
+
end
|
@@ -0,0 +1,111 @@
|
|
1
|
+
module Steep
|
2
|
+
module Subtyping
|
3
|
+
class Constraints
|
4
|
+
class UnsatisfiedInvariantError < StandardError
|
5
|
+
attr_reader constraints: untyped
|
6
|
+
|
7
|
+
attr_reader reason: untyped
|
8
|
+
|
9
|
+
def initialize: (reason: untyped, constraints: untyped) -> void
|
10
|
+
|
11
|
+
class VariablesUnknownsNotDisjoint
|
12
|
+
attr_reader vars: untyped
|
13
|
+
|
14
|
+
def initialize: (vars: untyped) -> void
|
15
|
+
|
16
|
+
def message: () -> ::String
|
17
|
+
end
|
18
|
+
|
19
|
+
class VariablesFreeVariablesNotDisjoint
|
20
|
+
attr_reader var: untyped
|
21
|
+
|
22
|
+
attr_reader lower_bound: untyped
|
23
|
+
|
24
|
+
attr_reader upper_bound: untyped
|
25
|
+
|
26
|
+
def initialize: (?var: untyped?, ?lower_bound: untyped?, ?upper_bound: untyped?) -> void
|
27
|
+
|
28
|
+
def message: () -> ::String
|
29
|
+
end
|
30
|
+
|
31
|
+
class UnknownsFreeVariableNotDisjoint
|
32
|
+
attr_reader var: untyped
|
33
|
+
|
34
|
+
attr_reader upper_bound: untyped
|
35
|
+
|
36
|
+
attr_reader lower_bound: untyped
|
37
|
+
|
38
|
+
def initialize: (var: untyped, lower_bound: untyped, upper_bound: untyped) -> void
|
39
|
+
|
40
|
+
def message: () -> ::String
|
41
|
+
end
|
42
|
+
end
|
43
|
+
|
44
|
+
class UnsatisfiableConstraint < StandardError
|
45
|
+
attr_reader var: untyped
|
46
|
+
|
47
|
+
attr_reader sub_type: untyped
|
48
|
+
|
49
|
+
attr_reader super_type: untyped
|
50
|
+
|
51
|
+
attr_reader result: untyped
|
52
|
+
|
53
|
+
def initialize: (var: untyped, sub_type: untyped, super_type: untyped, result: untyped) -> void
|
54
|
+
end
|
55
|
+
|
56
|
+
class Context
|
57
|
+
attr_reader variance: untyped
|
58
|
+
|
59
|
+
attr_reader self_type: AST::Types::t
|
60
|
+
|
61
|
+
attr_reader instance_type: AST::Types::t
|
62
|
+
|
63
|
+
attr_reader class_type: AST::Types::t
|
64
|
+
|
65
|
+
def initialize: (variance: untyped, self_type: AST::Types::t, instance_type: AST::Types::t, class_type: AST::Types::t) -> void
|
66
|
+
end
|
67
|
+
|
68
|
+
attr_reader dictionary: Hash[Symbol, [Set[AST::Types::t], Set[AST::Types::t], Set[AST::Types::t]]]
|
69
|
+
|
70
|
+
attr_reader vars: Set[Symbol]
|
71
|
+
|
72
|
+
def initialize: (unknowns: _Each[Symbol]) -> void
|
73
|
+
|
74
|
+
def self.empty: () -> Constraints
|
75
|
+
|
76
|
+
def add_var: (*Symbol vars) -> void
|
77
|
+
|
78
|
+
def add: (Symbol var, ?sub_type: untyped?, ?super_type: untyped?, ?skip: bool) -> untyped
|
79
|
+
|
80
|
+
def eliminate_variable: (AST::Types::t `type`, to: AST::Types::t) -> AST::Types::t
|
81
|
+
|
82
|
+
def unknown?: (Symbol var) -> bool
|
83
|
+
|
84
|
+
def unknowns: () -> Set[Symbol]
|
85
|
+
|
86
|
+
def unknown!: (Symbol var) -> void
|
87
|
+
|
88
|
+
def empty?: () -> bool
|
89
|
+
|
90
|
+
def upper_bound: (Symbol var, ?skip: bool) -> AST::Types::t
|
91
|
+
|
92
|
+
def lower_bound: (Symbol var, ?skip: bool) -> AST::Types::t
|
93
|
+
|
94
|
+
def solution: (Check checker, variables: Enumerable[Symbol], variance: VariableVariance, self_type: AST::Types::t, instance_type: AST::Types::t, class_type: AST::Types::t) -> Interface::Substitution
|
95
|
+
| (Check checker, variables: Enumerable[Symbol], context: Context) -> Interface::Substitution
|
96
|
+
|
97
|
+
def has_constraint?: (Symbol var) -> bool
|
98
|
+
|
99
|
+
def each: () { ([Symbol, AST::Types::t, AST::Types::t]) -> void } -> void
|
100
|
+
| () -> Enumerator[[Symbol, AST::Types::t, AST::Types::t], void]
|
101
|
+
|
102
|
+
def to_s: () -> ::String
|
103
|
+
|
104
|
+
private
|
105
|
+
|
106
|
+
def lower_bound_types: (Symbol var_name) -> Set[AST::Types::t]
|
107
|
+
|
108
|
+
def upper_bound_types: (Symbol var_name) -> Set[AST::Types::t]
|
109
|
+
end
|
110
|
+
end
|
111
|
+
end
|
@@ -0,0 +1,51 @@
|
|
1
|
+
module Steep
|
2
|
+
module Subtyping
|
3
|
+
class Relation
|
4
|
+
attr_reader sub_type: untyped
|
5
|
+
|
6
|
+
attr_reader super_type: untyped
|
7
|
+
|
8
|
+
def initialize: (sub_type: untyped, super_type: untyped) -> void
|
9
|
+
|
10
|
+
def hash: () -> untyped
|
11
|
+
|
12
|
+
def ==: (untyped other) -> untyped
|
13
|
+
|
14
|
+
alias eql? ==
|
15
|
+
|
16
|
+
def to_s: () -> ::String
|
17
|
+
|
18
|
+
def to_ary: () -> ::Array[untyped]
|
19
|
+
|
20
|
+
def type?: () -> untyped
|
21
|
+
|
22
|
+
def interface?: () -> untyped
|
23
|
+
|
24
|
+
def method?: () -> untyped
|
25
|
+
|
26
|
+
def function?: () -> untyped
|
27
|
+
|
28
|
+
def params?: () -> untyped
|
29
|
+
|
30
|
+
def block?: () -> untyped
|
31
|
+
|
32
|
+
def assert_type: (untyped `type`) -> (untyped | nil)
|
33
|
+
|
34
|
+
def type!: () -> untyped
|
35
|
+
|
36
|
+
def interface!: () -> untyped
|
37
|
+
|
38
|
+
def method!: () -> untyped
|
39
|
+
|
40
|
+
def function!: () -> untyped
|
41
|
+
|
42
|
+
def params!: () -> untyped
|
43
|
+
|
44
|
+
def block!: () -> untyped
|
45
|
+
|
46
|
+
def map: () { (untyped) -> untyped } -> untyped
|
47
|
+
|
48
|
+
def flip: () -> untyped
|
49
|
+
end
|
50
|
+
end
|
51
|
+
end
|
@@ -0,0 +1,157 @@
|
|
1
|
+
module Steep
|
2
|
+
module Subtyping
|
3
|
+
module Result
|
4
|
+
type t = Skip | Expand | All | Any | Success | Failure
|
5
|
+
|
6
|
+
class Base
|
7
|
+
attr_reader relation: Relation
|
8
|
+
|
9
|
+
def initialize: (Relation relation) -> void
|
10
|
+
|
11
|
+
def failure?: () -> bool
|
12
|
+
|
13
|
+
def success?: () -> bool
|
14
|
+
|
15
|
+
def then: [A] () { (self) -> A } -> A
|
16
|
+
|
17
|
+
def else: [A] () { (self) -> A } -> A
|
18
|
+
|
19
|
+
def failure_path: (?untyped path) -> untyped
|
20
|
+
end
|
21
|
+
|
22
|
+
class Skip < Base
|
23
|
+
def success?: () -> false
|
24
|
+
|
25
|
+
def failure?: () -> false
|
26
|
+
|
27
|
+
def failure_path: (?untyped path) -> untyped
|
28
|
+
end
|
29
|
+
|
30
|
+
class Expand < Base
|
31
|
+
attr_reader child: untyped
|
32
|
+
|
33
|
+
def initialize: (untyped relation) { (untyped) -> untyped } -> void
|
34
|
+
|
35
|
+
def success?: () -> untyped
|
36
|
+
|
37
|
+
def failure_path: (?untyped path) -> (untyped | nil)
|
38
|
+
end
|
39
|
+
|
40
|
+
class All < Base
|
41
|
+
attr_reader branches: untyped
|
42
|
+
|
43
|
+
def initialize: (untyped relation) -> void
|
44
|
+
|
45
|
+
# Returns `false` if no future `#add` changes the result.
|
46
|
+
def add: (*untyped relations) { (untyped) -> untyped } -> untyped
|
47
|
+
|
48
|
+
def success?: () -> untyped
|
49
|
+
|
50
|
+
def failure?: () -> untyped
|
51
|
+
|
52
|
+
def failure_path: (?untyped path) -> (untyped | nil)
|
53
|
+
end
|
54
|
+
|
55
|
+
class Any < Base
|
56
|
+
attr_reader branches: untyped
|
57
|
+
|
58
|
+
def initialize: (untyped relation) -> void
|
59
|
+
|
60
|
+
# Returns `false` if no future `#add` changes the result.
|
61
|
+
def add: (*untyped relations) { (untyped) -> untyped } -> untyped
|
62
|
+
|
63
|
+
def success?: () -> untyped
|
64
|
+
|
65
|
+
def failure_path: (?untyped path) -> (untyped | nil)
|
66
|
+
end
|
67
|
+
|
68
|
+
class Success < Base
|
69
|
+
def success?: () -> true
|
70
|
+
|
71
|
+
def failure_path: (?untyped path) -> nil
|
72
|
+
end
|
73
|
+
|
74
|
+
class Failure < Base
|
75
|
+
class MethodMissingError
|
76
|
+
attr_reader name: untyped
|
77
|
+
|
78
|
+
def initialize: (name: untyped) -> void
|
79
|
+
|
80
|
+
def message: () -> ::String
|
81
|
+
end
|
82
|
+
|
83
|
+
class BlockMismatchError
|
84
|
+
attr_reader name: untyped
|
85
|
+
|
86
|
+
def initialize: (name: untyped) -> void
|
87
|
+
|
88
|
+
def message: () -> ::String
|
89
|
+
end
|
90
|
+
|
91
|
+
class ParameterMismatchError
|
92
|
+
attr_reader name: untyped
|
93
|
+
|
94
|
+
def initialize: (name: untyped) -> void
|
95
|
+
|
96
|
+
def message: () -> ::String
|
97
|
+
end
|
98
|
+
|
99
|
+
class UnknownPairError
|
100
|
+
attr_reader relation: untyped
|
101
|
+
|
102
|
+
def initialize: (relation: untyped) -> void
|
103
|
+
|
104
|
+
def message: () -> ::String
|
105
|
+
end
|
106
|
+
|
107
|
+
class PolyMethodSubtyping
|
108
|
+
attr_reader name: untyped
|
109
|
+
|
110
|
+
def initialize: (name: untyped) -> void
|
111
|
+
|
112
|
+
def message: () -> ::String
|
113
|
+
end
|
114
|
+
|
115
|
+
class UnsatisfiedConstraints
|
116
|
+
attr_reader error: untyped
|
117
|
+
|
118
|
+
def initialize: (untyped error) -> void
|
119
|
+
|
120
|
+
def var: () -> untyped
|
121
|
+
|
122
|
+
def sub_type: () -> untyped
|
123
|
+
|
124
|
+
def super_type: () -> untyped
|
125
|
+
|
126
|
+
def result: () -> untyped
|
127
|
+
|
128
|
+
def message: () -> ::String
|
129
|
+
end
|
130
|
+
|
131
|
+
attr_reader error: untyped
|
132
|
+
|
133
|
+
def initialize: (untyped relation, untyped error) -> void
|
134
|
+
|
135
|
+
def success?: () -> false
|
136
|
+
|
137
|
+
def failure_path: (?untyped path) -> untyped
|
138
|
+
end
|
139
|
+
|
140
|
+
module Helper
|
141
|
+
def Skip: (untyped relation) -> untyped
|
142
|
+
|
143
|
+
def Expand: (untyped relation) { () -> untyped } -> untyped
|
144
|
+
|
145
|
+
def All: (untyped relation) { () -> untyped } -> untyped
|
146
|
+
|
147
|
+
def Any: (untyped relation) { () -> untyped } -> untyped
|
148
|
+
|
149
|
+
def Success: (untyped relation) -> untyped
|
150
|
+
|
151
|
+
alias success Success
|
152
|
+
|
153
|
+
def Failure: (untyped relation, ?untyped? error) { () -> untyped } -> untyped
|
154
|
+
end
|
155
|
+
end
|
156
|
+
end
|
157
|
+
end
|
@@ -0,0 +1,23 @@
|
|
1
|
+
module Steep
|
2
|
+
module Subtyping
|
3
|
+
class VariableVariance
|
4
|
+
attr_reader covariants: untyped
|
5
|
+
|
6
|
+
attr_reader contravariants: untyped
|
7
|
+
|
8
|
+
def initialize: (covariants: untyped, contravariants: untyped) -> void
|
9
|
+
|
10
|
+
def covariant?: (untyped var) -> untyped
|
11
|
+
|
12
|
+
def contravariant?: (untyped var) -> untyped
|
13
|
+
|
14
|
+
def invariant?: (untyped var) -> untyped
|
15
|
+
|
16
|
+
def self.from_method_type: (untyped method_type) -> untyped
|
17
|
+
|
18
|
+
def self.add_params: (untyped params, block: untyped, covariants: untyped, contravariants: untyped) -> untyped
|
19
|
+
|
20
|
+
def self.add_type: (untyped `type`, variance: untyped, covariants: untyped, contravariants: untyped) -> untyped
|
21
|
+
end
|
22
|
+
end
|
23
|
+
end
|