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,215 @@
|
|
1
|
+
module Steep
|
2
|
+
module Diagnostic
|
3
|
+
module Signature
|
4
|
+
class Base
|
5
|
+
include Helper
|
6
|
+
|
7
|
+
attr_reader location: untyped
|
8
|
+
|
9
|
+
def initialize: (location: untyped) -> void
|
10
|
+
|
11
|
+
def header_line: () -> untyped
|
12
|
+
|
13
|
+
def detail_lines: () -> nil
|
14
|
+
|
15
|
+
def diagnostic_code: () -> ::String
|
16
|
+
|
17
|
+
def path: () -> untyped
|
18
|
+
end
|
19
|
+
|
20
|
+
class SyntaxError < Base
|
21
|
+
attr_reader exception: untyped
|
22
|
+
|
23
|
+
def initialize: (untyped exception, location: untyped) -> void
|
24
|
+
|
25
|
+
def self.parser_syntax_error_message: (untyped exception) -> ::String
|
26
|
+
|
27
|
+
def header_line: () -> untyped
|
28
|
+
end
|
29
|
+
|
30
|
+
class DuplicatedDeclaration < Base
|
31
|
+
attr_reader type_name: untyped
|
32
|
+
|
33
|
+
def initialize: (type_name: untyped, location: untyped) -> void
|
34
|
+
|
35
|
+
def header_line: () -> ::String
|
36
|
+
end
|
37
|
+
|
38
|
+
class UnknownTypeName < Base
|
39
|
+
attr_reader name: untyped
|
40
|
+
|
41
|
+
def initialize: (name: untyped, location: untyped) -> void
|
42
|
+
|
43
|
+
def header_line: () -> ::String
|
44
|
+
end
|
45
|
+
|
46
|
+
class InvalidTypeApplication < Base
|
47
|
+
attr_reader name: untyped
|
48
|
+
|
49
|
+
attr_reader args: untyped
|
50
|
+
|
51
|
+
attr_reader params: untyped
|
52
|
+
|
53
|
+
def initialize: (name: untyped, args: untyped, params: untyped, location: untyped) -> void
|
54
|
+
|
55
|
+
def header_line: () -> untyped
|
56
|
+
end
|
57
|
+
|
58
|
+
class UnsatisfiableTypeApplication < Base
|
59
|
+
attr_reader type_name: untyped
|
60
|
+
|
61
|
+
attr_reader type_arg: untyped
|
62
|
+
|
63
|
+
attr_reader type_param: untyped
|
64
|
+
|
65
|
+
def initialize: (type_name: untyped, type_arg: untyped, type_param: untyped, location: untyped) -> void
|
66
|
+
|
67
|
+
def header_line: () -> ::String
|
68
|
+
end
|
69
|
+
|
70
|
+
class InvalidMethodOverload < Base
|
71
|
+
attr_reader class_name: untyped
|
72
|
+
|
73
|
+
attr_reader method_name: untyped
|
74
|
+
|
75
|
+
def initialize: (class_name: untyped, method_name: untyped, location: untyped) -> void
|
76
|
+
|
77
|
+
def header_line: () -> ::String
|
78
|
+
end
|
79
|
+
|
80
|
+
class UnknownMethodAlias < Base
|
81
|
+
attr_reader class_name: untyped
|
82
|
+
|
83
|
+
attr_reader method_name: untyped
|
84
|
+
|
85
|
+
def initialize: (class_name: untyped, method_name: untyped, location: untyped) -> void
|
86
|
+
|
87
|
+
def header_line: () -> ::String
|
88
|
+
end
|
89
|
+
|
90
|
+
class DuplicatedMethodDefinition < Base
|
91
|
+
attr_reader class_name: untyped
|
92
|
+
|
93
|
+
attr_reader method_name: untyped
|
94
|
+
|
95
|
+
def initialize: (class_name: untyped, method_name: untyped, location: untyped) -> void
|
96
|
+
|
97
|
+
def header_line: () -> ::String
|
98
|
+
end
|
99
|
+
|
100
|
+
class RecursiveAlias < Base
|
101
|
+
attr_reader class_name: untyped
|
102
|
+
|
103
|
+
attr_reader names: untyped
|
104
|
+
|
105
|
+
attr_reader location: untyped
|
106
|
+
|
107
|
+
def initialize: (class_name: untyped, names: untyped, location: untyped) -> void
|
108
|
+
|
109
|
+
def header_line: () -> ::String
|
110
|
+
end
|
111
|
+
|
112
|
+
class RecursiveAncestor < Base
|
113
|
+
attr_reader ancestors: untyped
|
114
|
+
|
115
|
+
def initialize: (ancestors: untyped, location: untyped) -> void
|
116
|
+
|
117
|
+
def header_line: () -> ::String
|
118
|
+
end
|
119
|
+
|
120
|
+
class SuperclassMismatch < Base
|
121
|
+
attr_reader name: untyped
|
122
|
+
|
123
|
+
def initialize: (name: untyped, location: untyped) -> void
|
124
|
+
|
125
|
+
def header_line: () -> ::String
|
126
|
+
end
|
127
|
+
|
128
|
+
class GenericParameterMismatch < Base
|
129
|
+
attr_reader name: untyped
|
130
|
+
|
131
|
+
def initialize: (name: untyped, location: untyped) -> void
|
132
|
+
|
133
|
+
def header_line: () -> ::String
|
134
|
+
end
|
135
|
+
|
136
|
+
class InvalidVarianceAnnotation < Base
|
137
|
+
attr_reader name: untyped
|
138
|
+
|
139
|
+
attr_reader param: untyped
|
140
|
+
|
141
|
+
def initialize: (name: untyped, param: untyped, location: untyped) -> void
|
142
|
+
|
143
|
+
def header_line: () -> ::String
|
144
|
+
end
|
145
|
+
|
146
|
+
class ModuleSelfTypeError < Base
|
147
|
+
attr_reader name: untyped
|
148
|
+
|
149
|
+
attr_reader ancestor: untyped
|
150
|
+
|
151
|
+
attr_reader relation: untyped
|
152
|
+
|
153
|
+
def initialize: (name: untyped, ancestor: untyped, relation: untyped, location: untyped) -> void
|
154
|
+
|
155
|
+
def header_line: () -> ::String
|
156
|
+
end
|
157
|
+
|
158
|
+
class InstanceVariableTypeError < Base
|
159
|
+
attr_reader name: untyped
|
160
|
+
|
161
|
+
attr_reader variable: untyped
|
162
|
+
|
163
|
+
attr_reader var_type: untyped
|
164
|
+
|
165
|
+
attr_reader parent_type: untyped
|
166
|
+
|
167
|
+
def initialize: (name: untyped, location: untyped, var_type: untyped, parent_type: untyped) -> void
|
168
|
+
|
169
|
+
def header_line: () -> ::String
|
170
|
+
end
|
171
|
+
|
172
|
+
class MixinClassError < Base
|
173
|
+
attr_reader member: untyped
|
174
|
+
|
175
|
+
attr_reader type_name: untyped
|
176
|
+
|
177
|
+
def initialize: (location: untyped, member: untyped, type_name: untyped) -> void
|
178
|
+
|
179
|
+
def header_line: () -> ::String
|
180
|
+
|
181
|
+
private
|
182
|
+
|
183
|
+
def mixin_name: () -> untyped
|
184
|
+
end
|
185
|
+
|
186
|
+
class UnexpectedError < Base
|
187
|
+
attr_reader message: untyped
|
188
|
+
|
189
|
+
def initialize: (message: untyped, location: untyped) -> void
|
190
|
+
|
191
|
+
def header_line: () -> ::String
|
192
|
+
end
|
193
|
+
|
194
|
+
class RecursiveTypeAlias < Base
|
195
|
+
attr_reader alias_names: untyped
|
196
|
+
|
197
|
+
def initialize: (alias_names: untyped, location: untyped) -> void
|
198
|
+
|
199
|
+
def header_line: () -> ::String
|
200
|
+
end
|
201
|
+
|
202
|
+
class NonregularTypeAlias < Base
|
203
|
+
attr_reader type_name: untyped
|
204
|
+
|
205
|
+
attr_reader nonregular_type: untyped
|
206
|
+
|
207
|
+
def initialize: (type_name: untyped, nonregular_type: untyped, location: untyped) -> void
|
208
|
+
|
209
|
+
def header_line: () -> ::String
|
210
|
+
end
|
211
|
+
|
212
|
+
def self.from_rbs_error: (untyped error, factory: untyped) -> untyped
|
213
|
+
end
|
214
|
+
end
|
215
|
+
end
|
@@ -0,0 +1,35 @@
|
|
1
|
+
module Steep
|
2
|
+
module Interface
|
3
|
+
class Block
|
4
|
+
attr_reader type: Function
|
5
|
+
|
6
|
+
attr_reader optional: bool
|
7
|
+
|
8
|
+
def initialize: (type: Function, optional: bool) -> void
|
9
|
+
|
10
|
+
def optional?: () -> bool
|
11
|
+
|
12
|
+
def required?: () -> bool
|
13
|
+
|
14
|
+
def to_optional: () -> Block
|
15
|
+
|
16
|
+
def ==: (untyped other) -> bool
|
17
|
+
|
18
|
+
alias eql? ==
|
19
|
+
|
20
|
+
def hash: () -> Integer
|
21
|
+
|
22
|
+
def closed?: () -> bool
|
23
|
+
|
24
|
+
def subst: (Substitution s) -> Block
|
25
|
+
|
26
|
+
def free_variables: () -> Set[Symbol]
|
27
|
+
|
28
|
+
def to_s: () -> ::String
|
29
|
+
|
30
|
+
def map_type: () { (AST::Types::t) -> AST::Types::t } -> Block
|
31
|
+
|
32
|
+
def +: (Block other) -> Block
|
33
|
+
end
|
34
|
+
end
|
35
|
+
end
|
@@ -0,0 +1,253 @@
|
|
1
|
+
module Steep
|
2
|
+
module Interface
|
3
|
+
class Function
|
4
|
+
class Params
|
5
|
+
module Utils
|
6
|
+
def union: (*AST::Types::t types, ?null: bool) -> AST::Types::t
|
7
|
+
|
8
|
+
def intersection: (*AST::Types::t types) -> AST::Types::t
|
9
|
+
end
|
10
|
+
|
11
|
+
class PositionalParams
|
12
|
+
class Base
|
13
|
+
attr_reader type: untyped
|
14
|
+
|
15
|
+
def initialize: (untyped `type`) -> void
|
16
|
+
|
17
|
+
def ==: (untyped other) -> untyped
|
18
|
+
|
19
|
+
alias eql? ==
|
20
|
+
|
21
|
+
def hash: () -> untyped
|
22
|
+
|
23
|
+
def subst: (untyped s) -> untyped
|
24
|
+
|
25
|
+
def var_type: () -> untyped
|
26
|
+
|
27
|
+
def map_type: () { (untyped) -> untyped } -> untyped
|
28
|
+
end
|
29
|
+
|
30
|
+
class Required < Base
|
31
|
+
end
|
32
|
+
|
33
|
+
class Optional < Base
|
34
|
+
end
|
35
|
+
|
36
|
+
class Rest < Base
|
37
|
+
end
|
38
|
+
|
39
|
+
attr_reader head: untyped
|
40
|
+
|
41
|
+
attr_reader tail: untyped
|
42
|
+
|
43
|
+
def initialize: (head: untyped, tail: untyped) -> void
|
44
|
+
|
45
|
+
def self.required: (untyped `type`, ?untyped? tail) -> untyped
|
46
|
+
|
47
|
+
def self.optional: (untyped `type`, ?untyped? tail) -> untyped
|
48
|
+
|
49
|
+
def self.rest: (untyped `type`, ?untyped? tail) -> untyped
|
50
|
+
|
51
|
+
def to_ary: () -> ::Array[untyped]
|
52
|
+
|
53
|
+
def map: () { (untyped) -> untyped } -> untyped
|
54
|
+
|
55
|
+
def map_type: () { () -> untyped } -> untyped
|
56
|
+
|
57
|
+
def subst: (untyped s) -> untyped
|
58
|
+
|
59
|
+
def ==: (untyped other) -> untyped
|
60
|
+
|
61
|
+
alias eql? ==
|
62
|
+
|
63
|
+
def hash: () -> untyped
|
64
|
+
|
65
|
+
def each: () { (untyped) -> untyped } -> untyped
|
66
|
+
|
67
|
+
def each_type: () { (untyped) -> untyped } -> untyped
|
68
|
+
|
69
|
+
def size: () -> untyped
|
70
|
+
|
71
|
+
def self.build: (required: untyped, optional: untyped, rest: untyped) -> untyped
|
72
|
+
|
73
|
+
extend Utils
|
74
|
+
|
75
|
+
# Calculates xs + ys.
|
76
|
+
# Never fails.
|
77
|
+
def self.merge_for_overload: (untyped xs, untyped ys) -> untyped
|
78
|
+
|
79
|
+
# xs | ys
|
80
|
+
def self.merge_for_union: (untyped xs, untyped ys) -> untyped
|
81
|
+
|
82
|
+
# Calculates xs & ys.
|
83
|
+
# Raises when failed.
|
84
|
+
#
|
85
|
+
def self.merge_for_intersection: (untyped xs, untyped ys) -> untyped
|
86
|
+
end
|
87
|
+
|
88
|
+
class KeywordParams
|
89
|
+
attr_reader requireds: untyped
|
90
|
+
|
91
|
+
attr_reader optionals: untyped
|
92
|
+
|
93
|
+
attr_reader rest: untyped
|
94
|
+
|
95
|
+
def initialize: (?requireds: ::Hash[untyped, untyped], ?optionals: ::Hash[untyped, untyped], ?rest: untyped?) -> void
|
96
|
+
|
97
|
+
def ==: (untyped other) -> untyped
|
98
|
+
|
99
|
+
alias eql? ==
|
100
|
+
|
101
|
+
def hash: () -> untyped
|
102
|
+
|
103
|
+
def update: (?requireds: untyped, ?optionals: untyped, ?rest: untyped) -> untyped
|
104
|
+
|
105
|
+
def empty?: () -> untyped
|
106
|
+
|
107
|
+
def each: () { (untyped, untyped) -> untyped } -> untyped
|
108
|
+
|
109
|
+
def each_type: () { (untyped) -> untyped } -> untyped
|
110
|
+
|
111
|
+
def map_type: () { () -> untyped } -> untyped
|
112
|
+
|
113
|
+
def subst: (untyped s) -> untyped
|
114
|
+
|
115
|
+
def size: () -> untyped
|
116
|
+
|
117
|
+
def keywords: () -> untyped
|
118
|
+
|
119
|
+
include Utils
|
120
|
+
|
121
|
+
# For overloading
|
122
|
+
def +: (untyped other) -> untyped
|
123
|
+
|
124
|
+
# For union
|
125
|
+
def |: (untyped other) -> untyped
|
126
|
+
|
127
|
+
# For intersection
|
128
|
+
def &: (untyped other) -> (nil | untyped)
|
129
|
+
end
|
130
|
+
|
131
|
+
def required: () -> Array[AST::Types::t]
|
132
|
+
|
133
|
+
def optional: () -> Array[AST::Types::t]
|
134
|
+
|
135
|
+
def rest: () -> AST::Types::t?
|
136
|
+
|
137
|
+
attr_reader positional_params: PositionalParams
|
138
|
+
|
139
|
+
attr_reader keyword_params: KeywordParams
|
140
|
+
|
141
|
+
def self.build: (?required: untyped, ?optional: untyped, ?rest: untyped?, ?required_keywords: ::Hash[untyped, untyped], ?optional_keywords: ::Hash[untyped, untyped], ?rest_keywords: untyped?) -> untyped
|
142
|
+
|
143
|
+
def initialize: (positional_params: untyped, keyword_params: untyped) -> void
|
144
|
+
|
145
|
+
def update: (?positional_params: untyped, ?keyword_params: untyped) -> untyped
|
146
|
+
|
147
|
+
def first_param: () -> untyped
|
148
|
+
|
149
|
+
def with_first_param: (untyped param) -> untyped
|
150
|
+
|
151
|
+
def has_positional?: () -> (true | false)
|
152
|
+
|
153
|
+
def self.empty: () -> untyped
|
154
|
+
|
155
|
+
def ==: (untyped other) -> untyped
|
156
|
+
|
157
|
+
alias eql? ==
|
158
|
+
|
159
|
+
def hash: () -> untyped
|
160
|
+
|
161
|
+
def flat_unnamed_params: () -> (untyped | ::Array[untyped])
|
162
|
+
|
163
|
+
def flat_keywords: () -> untyped
|
164
|
+
|
165
|
+
def required_keywords: () -> untyped
|
166
|
+
|
167
|
+
def optional_keywords: () -> untyped
|
168
|
+
|
169
|
+
def rest_keywords: () -> untyped
|
170
|
+
|
171
|
+
def has_keywords?: () -> untyped
|
172
|
+
|
173
|
+
def each_positional_param: () { () -> untyped } -> (untyped | nil | untyped)
|
174
|
+
|
175
|
+
def without_keywords: () -> untyped
|
176
|
+
|
177
|
+
def drop_first: () -> untyped
|
178
|
+
|
179
|
+
def each_type: () { () -> untyped } -> untyped
|
180
|
+
|
181
|
+
def free_variables: () -> untyped
|
182
|
+
|
183
|
+
def closed?: () -> untyped
|
184
|
+
|
185
|
+
def subst: (untyped s) -> untyped
|
186
|
+
|
187
|
+
def size: () -> untyped
|
188
|
+
|
189
|
+
def to_s: () -> ::String
|
190
|
+
|
191
|
+
def map_type: () { () -> untyped } -> untyped
|
192
|
+
|
193
|
+
def empty?: () -> untyped
|
194
|
+
|
195
|
+
# Returns true if all arguments are non-required.
|
196
|
+
def optional?: () -> untyped
|
197
|
+
|
198
|
+
# self + params returns a new params for overloading.
|
199
|
+
#
|
200
|
+
def +: (untyped other) -> untyped
|
201
|
+
|
202
|
+
# Returns the intersection between self and other.
|
203
|
+
# Returns nil if the intersection cannot be computed.
|
204
|
+
#
|
205
|
+
# (self & other) <: self
|
206
|
+
# (self & other) <: other
|
207
|
+
#
|
208
|
+
# `self & other` accept `arg` if `arg` is acceptable for both of `self` and `other`.
|
209
|
+
#
|
210
|
+
def &: (untyped other) -> (nil | untyped)
|
211
|
+
|
212
|
+
# Returns the union between self and other.
|
213
|
+
#
|
214
|
+
# self <: (self | other)
|
215
|
+
# other <: (self | other)
|
216
|
+
#
|
217
|
+
# `self | other` accept `arg` if `self` accepts `arg` or `other` accepts `arg`.
|
218
|
+
#
|
219
|
+
def |: (untyped other) -> (nil | untyped)
|
220
|
+
end
|
221
|
+
|
222
|
+
attr_reader params: untyped
|
223
|
+
|
224
|
+
attr_reader return_type: AST::Types::t
|
225
|
+
|
226
|
+
attr_reader location: untyped
|
227
|
+
|
228
|
+
def initialize: (params: untyped, return_type: untyped, location: untyped) -> void
|
229
|
+
|
230
|
+
def ==: (untyped other) -> untyped
|
231
|
+
|
232
|
+
alias eql? ==
|
233
|
+
|
234
|
+
def hash: () -> untyped
|
235
|
+
|
236
|
+
def free_variables: () -> Set[Symbol]
|
237
|
+
|
238
|
+
def subst: (Substitution s) -> Function
|
239
|
+
|
240
|
+
def each_child: () { () -> untyped } -> untyped
|
241
|
+
|
242
|
+
def each_type: () { (untyped) -> untyped } -> untyped
|
243
|
+
|
244
|
+
def map_type: () { (untyped) -> untyped } -> untyped
|
245
|
+
|
246
|
+
def with: (?params: untyped, ?return_type: untyped) -> untyped
|
247
|
+
|
248
|
+
def to_s: () -> ::String
|
249
|
+
|
250
|
+
def closed?: () -> bool
|
251
|
+
end
|
252
|
+
end
|
253
|
+
end
|
@@ -0,0 +1,23 @@
|
|
1
|
+
module Steep
|
2
|
+
module Interface
|
3
|
+
class Interface
|
4
|
+
class Entry
|
5
|
+
attr_reader method_types: untyped
|
6
|
+
|
7
|
+
def initialize: (method_types: untyped) -> void
|
8
|
+
|
9
|
+
def to_s: () -> ::String
|
10
|
+
end
|
11
|
+
|
12
|
+
attr_reader type: untyped
|
13
|
+
|
14
|
+
attr_reader methods: untyped
|
15
|
+
|
16
|
+
def initialize: (type: untyped, private: untyped) -> void
|
17
|
+
|
18
|
+
def private?: () -> untyped
|
19
|
+
|
20
|
+
def public?: () -> untyped
|
21
|
+
end
|
22
|
+
end
|
23
|
+
end
|
@@ -0,0 +1,55 @@
|
|
1
|
+
module Steep
|
2
|
+
module Interface
|
3
|
+
class MethodType
|
4
|
+
attr_reader type_params: Array[TypeParam]
|
5
|
+
|
6
|
+
attr_reader type: Function
|
7
|
+
|
8
|
+
attr_reader block: Block
|
9
|
+
|
10
|
+
attr_reader method_decls: untyped
|
11
|
+
|
12
|
+
def initialize: (type_params: untyped, type: untyped, block: untyped, method_decls: untyped) -> void
|
13
|
+
|
14
|
+
def ==: (untyped other) -> untyped
|
15
|
+
|
16
|
+
alias eql? ==
|
17
|
+
|
18
|
+
def hash: () -> Integer
|
19
|
+
|
20
|
+
def free_variables: () -> Set[Symbol]
|
21
|
+
|
22
|
+
def subst: (Substitution s) -> MethodType
|
23
|
+
|
24
|
+
def each_type: () { (untyped) -> untyped } -> untyped
|
25
|
+
|
26
|
+
def instantiate: (Substitution s) -> MethodType
|
27
|
+
|
28
|
+
def with: (?type_params: untyped, ?type: untyped, ?block: untyped, ?method_decls: untyped) -> MethodType
|
29
|
+
|
30
|
+
def to_s: () -> ::String
|
31
|
+
|
32
|
+
def map_type: () { (AST::Types::t) -> AST::Types::t } -> MethodType
|
33
|
+
|
34
|
+
# Returns a new method type which can be used for the method implementation type of both `self` and `other`.
|
35
|
+
#
|
36
|
+
def unify_overload: (untyped other) -> untyped
|
37
|
+
|
38
|
+
def +: (untyped other) -> untyped
|
39
|
+
|
40
|
+
# Returns a method type which is a super-type of both self and other.
|
41
|
+
# self <: (self | other) && other <: (self | other)
|
42
|
+
#
|
43
|
+
# Returns nil if self and other are incompatible.
|
44
|
+
#
|
45
|
+
def |: (untyped other) -> (nil | untyped)
|
46
|
+
|
47
|
+
# Returns a method type which is a sub-type of both self and other.
|
48
|
+
# (self & other) <: self && (self & other) <: other
|
49
|
+
#
|
50
|
+
# Returns nil if self and other are incompatible.
|
51
|
+
#
|
52
|
+
def &: (untyped other) -> (nil | untyped)
|
53
|
+
end
|
54
|
+
end
|
55
|
+
end
|
@@ -0,0 +1,53 @@
|
|
1
|
+
module Steep
|
2
|
+
module Interface
|
3
|
+
class Substitution
|
4
|
+
class InvalidSubstitutionError < StandardError
|
5
|
+
attr_reader vars_size: untyped
|
6
|
+
|
7
|
+
attr_reader types_size: untyped
|
8
|
+
|
9
|
+
def initialize: (vars_size: untyped, types_size: untyped) -> void
|
10
|
+
end
|
11
|
+
|
12
|
+
attr_reader dictionary: untyped
|
13
|
+
|
14
|
+
attr_reader instance_type: untyped
|
15
|
+
|
16
|
+
attr_reader module_type: untyped
|
17
|
+
|
18
|
+
attr_reader self_type: untyped
|
19
|
+
|
20
|
+
def initialize: (dictionary: untyped, instance_type: untyped, module_type: untyped, self_type: untyped) -> void
|
21
|
+
|
22
|
+
def self.empty: () -> untyped
|
23
|
+
|
24
|
+
def empty?: () -> untyped
|
25
|
+
|
26
|
+
INSTANCE_TYPE: untyped
|
27
|
+
|
28
|
+
CLASS_TYPE: untyped
|
29
|
+
|
30
|
+
SELF_TYPE: untyped
|
31
|
+
|
32
|
+
def domain: () -> untyped
|
33
|
+
|
34
|
+
def to_s: () -> ::String
|
35
|
+
|
36
|
+
def []: (untyped key) -> untyped
|
37
|
+
|
38
|
+
def key?: (untyped var) -> untyped
|
39
|
+
|
40
|
+
def self.build: (untyped vars, ?untyped? types, ?instance_type: untyped, ?module_type: untyped, ?self_type: untyped) -> Substitution
|
41
|
+
|
42
|
+
def except: (untyped vars) -> untyped
|
43
|
+
|
44
|
+
def except!: (untyped vars) -> self
|
45
|
+
|
46
|
+
def merge!: (untyped s, ?overwrite: bool) -> self
|
47
|
+
|
48
|
+
def merge: (untyped s) -> untyped
|
49
|
+
|
50
|
+
def add!: (untyped v, untyped ty) -> untyped
|
51
|
+
end
|
52
|
+
end
|
53
|
+
end
|
@@ -0,0 +1,35 @@
|
|
1
|
+
module Steep
|
2
|
+
module Interface
|
3
|
+
class TypeParam
|
4
|
+
type loc = RBS::Location[untyped, untyped]
|
5
|
+
|
6
|
+
type variance = RBS::AST::TypeParam::variance
|
7
|
+
|
8
|
+
attr_reader name: Symbol
|
9
|
+
|
10
|
+
attr_reader upper_bound: AST::Types::t?
|
11
|
+
|
12
|
+
attr_reader variance: variance
|
13
|
+
|
14
|
+
attr_reader unchecked: bool
|
15
|
+
|
16
|
+
attr_reader location: loc?
|
17
|
+
|
18
|
+
def initialize: (name: Symbol, upper_bound: AST::Types::t?, variance: variance, unchecked: bool, ?location: loc?) -> void
|
19
|
+
|
20
|
+
def ==: (untyped other) -> bool
|
21
|
+
|
22
|
+
alias eql? ==
|
23
|
+
|
24
|
+
def hash: () -> Integer
|
25
|
+
|
26
|
+
def self.rename: (Array[TypeParam] params, ?Array[Symbol] conflicting_names) -> [Array[TypeParam], Substitution]
|
27
|
+
|
28
|
+
def to_s: () -> String
|
29
|
+
|
30
|
+
def update: (?name: Symbol, ?upper_bound: AST::Types::t?, ?variance: variance, ?unchecked: bool, ?location: loc?) -> TypeParam
|
31
|
+
|
32
|
+
def subst: (Substitution s) -> TypeParam
|
33
|
+
end
|
34
|
+
end
|
35
|
+
end
|
@@ -0,0 +1,26 @@
|
|
1
|
+
module Steep
|
2
|
+
type method_name = InstanceMethodName | SingletonMethodName
|
3
|
+
|
4
|
+
class InstanceMethodName
|
5
|
+
attr_reader type_name: RBS::TypeName
|
6
|
+
attr_reader method_name: Symbol
|
7
|
+
|
8
|
+
def initialize: (type_name: RBS::TypeName, method_name: Symbol) -> void
|
9
|
+
end
|
10
|
+
|
11
|
+
class SingletonMethodName
|
12
|
+
attr_reader type_name: RBS::TypeName
|
13
|
+
attr_reader method_name: Symbol
|
14
|
+
|
15
|
+
def initialize: (type_name: RBS::TypeName, method_name: Symbol) -> void
|
16
|
+
end
|
17
|
+
|
18
|
+
class ::Object
|
19
|
+
# Returns method name corresponding to given `string`.
|
20
|
+
#
|
21
|
+
# * `ClassName#method_name` syntax returns an `InstanceMethodName` object
|
22
|
+
# * `ClassName.method_name` syntax returns a `SingletonMethodName` object
|
23
|
+
#
|
24
|
+
def MethodName: (String string) -> (InstanceMethodName | SingletonMethodName)
|
25
|
+
end
|
26
|
+
end
|