steep 0.47.1 → 0.48.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +9 -0
- data/Gemfile.lock +6 -6
- data/lib/steep/ast/types/factory.rb +161 -137
- data/lib/steep/ast/types/var.rb +14 -3
- data/lib/steep/diagnostic/ruby.rb +23 -11
- data/lib/steep/diagnostic/signature.rb +56 -0
- data/lib/steep/interface/method_type.rb +14 -26
- data/lib/steep/interface/type_param.rb +103 -0
- data/lib/steep/server/base_worker.rb +1 -0
- data/lib/steep/server/interaction_worker.rb +1 -1
- data/lib/steep/server/type_check_worker.rb +2 -2
- data/lib/steep/services/signature_service.rb +2 -2
- data/lib/steep/services/type_check_service.rb +2 -1
- data/lib/steep/signature/validator.rb +221 -49
- data/lib/steep/subtyping/cache.rb +30 -0
- data/lib/steep/subtyping/check.rb +582 -708
- data/lib/steep/subtyping/constraints.rb +66 -30
- data/lib/steep/subtyping/relation.rb +60 -0
- data/lib/steep/subtyping/result.rb +190 -16
- data/lib/steep/type_construction.rb +492 -371
- data/lib/steep/type_inference/context.rb +37 -3
- data/lib/steep/version.rb +1 -1
- data/lib/steep.rb +3 -3
- data/sample/lib/length.rb +35 -0
- data/sample/sig/length.rbs +34 -0
- data/smoke/diagnostics-rbs/nonregular-type-alias.rbs +3 -0
- data/smoke/diagnostics-rbs/recursive-type-alias.rbs +3 -0
- data/smoke/diagnostics-rbs/test_expectations.yml +57 -12
- data/steep.gemspec +1 -1
- metadata +13 -10
- data/lib/steep/drivers/trace_printer.rb +0 -29
- data/lib/steep/interface/method.rb +0 -78
- data/lib/steep/subtyping/trace.rb +0 -71
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 72c3b61eccfe6a3f2cf2da22293bd7b50a001c25e82197b3efea52753857ff78
|
4
|
+
data.tar.gz: '08786e3140b0bbf10f79c5395a7026062abef6a690a9fefdf6ca464fbf13e92d'
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: d3abc0d6f64deffebf187428be69cec72dc5c887e0ecb2fbc407c20e2dde66bae8ce3bdf5f7f8a43ccaa90c562fa9c178bb9cc93a3d3d5b7fa99d5e7344fbfdd
|
7
|
+
data.tar.gz: df16f83cf33224f0442124546d3406313dff27bd472fc60978864c40cdffcbb9aa8013bb049c940021ccb6e76c7a1338d9d30fc0fb07f71e306e7dae21885ad7
|
data/CHANGELOG.md
CHANGED
@@ -2,6 +2,15 @@
|
|
2
2
|
|
3
3
|
## master
|
4
4
|
|
5
|
+
## 0.48.0 (2022-03-07)
|
6
|
+
|
7
|
+
Steep supports all of the new features of RBS 2. 🎉
|
8
|
+
It now requires RBS >= 2.2 and support all of the features.
|
9
|
+
|
10
|
+
* Update RBS ([\#495](https://github.com/soutaro/steep/pull/495))
|
11
|
+
* Support generic type aliases ([\#496](https://github.com/soutaro/steep/pull/496))
|
12
|
+
* Support bounded generics ([\#499](https://github.com/soutaro/steep/pull/499))
|
13
|
+
|
5
14
|
## 0.47.1 (2022-02-17)
|
6
15
|
|
7
16
|
This update lets Steep run with Active Support 7.
|
data/Gemfile.lock
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
PATH
|
2
2
|
remote: .
|
3
3
|
specs:
|
4
|
-
steep (0.
|
4
|
+
steep (0.48.0)
|
5
5
|
activesupport (>= 5.1)
|
6
6
|
language_server-protocol (>= 3.15, < 4.0)
|
7
7
|
listen (~> 3.0)
|
8
8
|
parallel (>= 1.0.0)
|
9
9
|
parser (>= 3.0)
|
10
10
|
rainbow (>= 2.2.2, < 4.0)
|
11
|
-
rbs (
|
11
|
+
rbs (>= 2.2.0)
|
12
12
|
terminal-table (>= 2, < 4)
|
13
13
|
|
14
14
|
PATH
|
@@ -42,15 +42,15 @@ GEM
|
|
42
42
|
minitest-hooks (1.5.0)
|
43
43
|
minitest (> 5.3)
|
44
44
|
parallel (1.21.0)
|
45
|
-
parser (3.1.
|
45
|
+
parser (3.1.1.0)
|
46
46
|
ast (~> 2.4.1)
|
47
47
|
rainbow (3.1.1)
|
48
48
|
rake (13.0.6)
|
49
49
|
rb-fsevent (0.11.1)
|
50
50
|
rb-inotify (0.10.1)
|
51
51
|
ffi (~> 1.0)
|
52
|
-
rbs (
|
53
|
-
stackprof (0.2.
|
52
|
+
rbs (2.2.2)
|
53
|
+
stackprof (0.2.19)
|
54
54
|
terminal-table (3.0.2)
|
55
55
|
unicode-display_width (>= 1.1.1, < 3)
|
56
56
|
tzinfo (2.0.4)
|
@@ -70,4 +70,4 @@ DEPENDENCIES
|
|
70
70
|
without_steep_types!
|
71
71
|
|
72
72
|
BUNDLED WITH
|
73
|
-
2.
|
73
|
+
2.3.8
|
@@ -21,143 +21,154 @@ module Steep
|
|
21
21
|
@type_name_resolver ||= RBS::TypeNameResolver.from_env(definition_builder.env)
|
22
22
|
end
|
23
23
|
|
24
|
+
def type_opt(type)
|
25
|
+
if type
|
26
|
+
type(type)
|
27
|
+
end
|
28
|
+
end
|
29
|
+
|
24
30
|
def type(type)
|
25
31
|
ty = type_cache[type] and return ty
|
26
32
|
|
27
|
-
type_cache[type] =
|
28
|
-
|
29
|
-
Any
|
30
|
-
|
31
|
-
Class
|
32
|
-
|
33
|
-
Instance
|
34
|
-
|
35
|
-
Self
|
36
|
-
|
37
|
-
Top
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
Void
|
44
|
-
|
45
|
-
Nil
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
-
|
56
|
-
|
57
|
-
|
58
|
-
|
59
|
-
|
60
|
-
|
61
|
-
|
62
|
-
|
63
|
-
|
64
|
-
|
65
|
-
|
66
|
-
|
67
|
-
|
68
|
-
|
69
|
-
|
70
|
-
|
71
|
-
|
72
|
-
|
73
|
-
|
74
|
-
|
75
|
-
|
76
|
-
|
77
|
-
|
78
|
-
|
79
|
-
|
80
|
-
|
81
|
-
|
82
|
-
|
83
|
-
|
84
|
-
|
85
|
-
|
86
|
-
|
87
|
-
|
88
|
-
|
89
|
-
|
90
|
-
|
91
|
-
|
92
|
-
|
33
|
+
type_cache[type] =
|
34
|
+
case type
|
35
|
+
when RBS::Types::Bases::Any
|
36
|
+
Any.new(location: type.location)
|
37
|
+
when RBS::Types::Bases::Class
|
38
|
+
Class.new(location: type.location)
|
39
|
+
when RBS::Types::Bases::Instance
|
40
|
+
Instance.new(location: type.location)
|
41
|
+
when RBS::Types::Bases::Self
|
42
|
+
Self.new(location: type.location)
|
43
|
+
when RBS::Types::Bases::Top
|
44
|
+
Top.new(location: type.location)
|
45
|
+
when RBS::Types::Bases::Bottom
|
46
|
+
Bot.new(location: type.location)
|
47
|
+
when RBS::Types::Bases::Bool
|
48
|
+
Boolean.new(location: type.location)
|
49
|
+
when RBS::Types::Bases::Void
|
50
|
+
Void.new(location: type.location)
|
51
|
+
when RBS::Types::Bases::Nil
|
52
|
+
Nil.new(location: type.location)
|
53
|
+
when RBS::Types::Variable
|
54
|
+
Var.new(name: type.name, location: type.location)
|
55
|
+
when RBS::Types::ClassSingleton
|
56
|
+
type_name = type.name
|
57
|
+
Name::Singleton.new(name: type_name, location: type.location)
|
58
|
+
when RBS::Types::ClassInstance
|
59
|
+
type_name = type.name
|
60
|
+
args = type.args.map {|arg| type(arg) }
|
61
|
+
Name::Instance.new(name: type_name, args: args, location: type.location)
|
62
|
+
when RBS::Types::Interface
|
63
|
+
type_name = type.name
|
64
|
+
args = type.args.map {|arg| type(arg) }
|
65
|
+
Name::Interface.new(name: type_name, args: args, location: type.location)
|
66
|
+
when RBS::Types::Alias
|
67
|
+
type_name = type.name
|
68
|
+
args = type.args.map {|arg| type(arg) }
|
69
|
+
Name::Alias.new(name: type_name, args: args, location: type.location)
|
70
|
+
when RBS::Types::Union
|
71
|
+
Union.build(types: type.types.map {|ty| type(ty) }, location: type.location)
|
72
|
+
when RBS::Types::Intersection
|
73
|
+
Intersection.build(types: type.types.map {|ty| type(ty) }, location: type.location)
|
74
|
+
when RBS::Types::Optional
|
75
|
+
Union.build(types: [type(type.type), Nil.new(location: nil)], location: type.location)
|
76
|
+
when RBS::Types::Literal
|
77
|
+
Literal.new(value: type.literal, location: type.location)
|
78
|
+
when RBS::Types::Tuple
|
79
|
+
Tuple.new(types: type.types.map {|ty| type(ty) }, location: type.location)
|
80
|
+
when RBS::Types::Record
|
81
|
+
elements = type.fields.each.with_object({}) do |(key, value), hash|
|
82
|
+
hash[key] = type(value)
|
83
|
+
end
|
84
|
+
Record.new(elements: elements, location: type.location)
|
85
|
+
when RBS::Types::Proc
|
86
|
+
func = Interface::Function.new(
|
87
|
+
params: params(type.type),
|
88
|
+
return_type: type(type.type.return_type),
|
89
|
+
location: type.location
|
90
|
+
)
|
91
|
+
block = if type.block
|
92
|
+
Interface::Block.new(
|
93
|
+
type: Interface::Function.new(
|
94
|
+
params: params(type.block.type),
|
95
|
+
return_type: type(type.block.type.return_type),
|
96
|
+
location: type.location
|
97
|
+
),
|
98
|
+
optional: !type.block.required
|
99
|
+
)
|
100
|
+
end
|
93
101
|
|
94
|
-
|
95
|
-
|
96
|
-
|
97
|
-
|
102
|
+
Proc.new(type: func, block: block)
|
103
|
+
else
|
104
|
+
raise "Unexpected type given: #{type}"
|
105
|
+
end
|
98
106
|
end
|
99
107
|
|
100
108
|
def type_1(type)
|
101
109
|
case type
|
102
110
|
when Any
|
103
|
-
RBS::Types::Bases::Any.new(location:
|
111
|
+
RBS::Types::Bases::Any.new(location: type.location)
|
104
112
|
when Class
|
105
|
-
RBS::Types::Bases::Class.new(location:
|
113
|
+
RBS::Types::Bases::Class.new(location: type.location)
|
106
114
|
when Instance
|
107
|
-
RBS::Types::Bases::Instance.new(location:
|
115
|
+
RBS::Types::Bases::Instance.new(location: type.location)
|
108
116
|
when Self
|
109
|
-
RBS::Types::Bases::Self.new(location:
|
117
|
+
RBS::Types::Bases::Self.new(location: type.location)
|
110
118
|
when Top
|
111
|
-
RBS::Types::Bases::Top.new(location:
|
119
|
+
RBS::Types::Bases::Top.new(location: type.location)
|
112
120
|
when Bot
|
113
|
-
RBS::Types::Bases::Bottom.new(location:
|
121
|
+
RBS::Types::Bases::Bottom.new(location: type.location)
|
114
122
|
when Boolean
|
115
|
-
RBS::Types::Bases::Bool.new(location:
|
123
|
+
RBS::Types::Bases::Bool.new(location: type.location)
|
116
124
|
when Void
|
117
|
-
RBS::Types::Bases::Void.new(location:
|
125
|
+
RBS::Types::Bases::Void.new(location: type.location)
|
118
126
|
when Nil
|
119
|
-
RBS::Types::Bases::Nil.new(location:
|
127
|
+
RBS::Types::Bases::Nil.new(location: type.location)
|
120
128
|
when Var
|
121
|
-
RBS::Types::Variable.new(name: type.name, location:
|
129
|
+
RBS::Types::Variable.new(name: type.name, location: type.location)
|
122
130
|
when Name::Singleton
|
123
|
-
RBS::Types::ClassSingleton.new(name: type.name, location:
|
131
|
+
RBS::Types::ClassSingleton.new(name: type.name, location: type.location)
|
124
132
|
when Name::Instance
|
125
133
|
RBS::Types::ClassInstance.new(
|
126
134
|
name: type.name,
|
127
135
|
args: type.args.map {|arg| type_1(arg) },
|
128
|
-
location:
|
136
|
+
location: type.location
|
129
137
|
)
|
130
138
|
when Name::Interface
|
131
139
|
RBS::Types::Interface.new(
|
132
140
|
name: type.name,
|
133
141
|
args: type.args.map {|arg| type_1(arg) },
|
134
|
-
location:
|
142
|
+
location: type.location
|
135
143
|
)
|
136
144
|
when Name::Alias
|
137
|
-
|
138
|
-
|
145
|
+
RBS::Types::Alias.new(
|
146
|
+
name: type.name,
|
147
|
+
args: type.args.map {|arg| type_1(arg) },
|
148
|
+
location: type.location
|
149
|
+
)
|
139
150
|
when Union
|
140
151
|
RBS::Types::Union.new(
|
141
152
|
types: type.types.map {|ty| type_1(ty) },
|
142
|
-
location:
|
153
|
+
location: type.location
|
143
154
|
)
|
144
155
|
when Intersection
|
145
156
|
RBS::Types::Intersection.new(
|
146
157
|
types: type.types.map {|ty| type_1(ty) },
|
147
|
-
location:
|
158
|
+
location: type.location
|
148
159
|
)
|
149
160
|
when Literal
|
150
|
-
RBS::Types::Literal.new(literal: type.value, location:
|
161
|
+
RBS::Types::Literal.new(literal: type.value, location: type.location)
|
151
162
|
when Tuple
|
152
163
|
RBS::Types::Tuple.new(
|
153
164
|
types: type.types.map {|ty| type_1(ty) },
|
154
|
-
location:
|
165
|
+
location: type.location
|
155
166
|
)
|
156
167
|
when Record
|
157
168
|
fields = type.elements.each.with_object({}) do |(key, value), hash|
|
158
169
|
hash[key] = type_1(value)
|
159
170
|
end
|
160
|
-
RBS::Types::Record.new(fields: fields, location:
|
171
|
+
RBS::Types::Record.new(fields: fields, location: type.location)
|
161
172
|
when Proc
|
162
173
|
block = if type.block
|
163
174
|
RBS::Types::Block.new(
|
@@ -168,10 +179,10 @@ module Steep
|
|
168
179
|
RBS::Types::Proc.new(
|
169
180
|
type: function_1(type.type),
|
170
181
|
block: block,
|
171
|
-
location:
|
182
|
+
location: type.location
|
172
183
|
)
|
173
184
|
when Logic::Base
|
174
|
-
RBS::Types::Bases::Bool.new(location:
|
185
|
+
RBS::Types::Bases::Bool.new(location: type.location)
|
175
186
|
else
|
176
187
|
raise "Unexpected type given: #{type} (#{type.class})"
|
177
188
|
end
|
@@ -204,45 +215,61 @@ module Steep
|
|
204
215
|
)
|
205
216
|
end
|
206
217
|
|
218
|
+
def type_param(type_param)
|
219
|
+
Interface::TypeParam.new(
|
220
|
+
name: type_param.name,
|
221
|
+
upper_bound: type_param.upper_bound&.yield_self {|u| type(u) },
|
222
|
+
variance: type_param.variance,
|
223
|
+
unchecked: type_param.unchecked?
|
224
|
+
)
|
225
|
+
end
|
226
|
+
|
227
|
+
def type_param_1(type_param)
|
228
|
+
RBS::AST::TypeParam.new(
|
229
|
+
name: type_param.name,
|
230
|
+
variance: type_param.variance,
|
231
|
+
upper_bound: type_param.upper_bound&.yield_self {|u| type_1(u) },
|
232
|
+
location: type_param.location
|
233
|
+
).unchecked!(type_param.unchecked)
|
234
|
+
end
|
235
|
+
|
207
236
|
def method_type(method_type, self_type:, subst2: nil, method_decls:)
|
208
237
|
fvs = self_type.free_variables()
|
209
238
|
|
210
239
|
type_params = []
|
211
|
-
|
212
|
-
alpha_types = []
|
240
|
+
conflicting_names = []
|
213
241
|
|
214
|
-
method_type.type_params.map do |
|
215
|
-
if fvs.include?(name)
|
216
|
-
|
217
|
-
alpha_vars << name
|
218
|
-
alpha_types << type
|
219
|
-
type_params << type.name
|
220
|
-
else
|
221
|
-
type_params << name
|
242
|
+
type_params = method_type.type_params.map do |type_param|
|
243
|
+
if fvs.include?(type_param.name)
|
244
|
+
conflicting_names << type_param.name
|
222
245
|
end
|
246
|
+
|
247
|
+
type_param(type_param)
|
223
248
|
end
|
224
|
-
|
249
|
+
|
250
|
+
type_params, subst = Interface::TypeParam.rename(type_params, conflicting_names)
|
225
251
|
subst.merge!(subst2, overwrite: true) if subst2
|
226
252
|
|
227
|
-
type =
|
228
|
-
|
229
|
-
|
230
|
-
|
231
|
-
|
232
|
-
|
233
|
-
|
234
|
-
|
235
|
-
|
236
|
-
|
237
|
-
|
238
|
-
|
239
|
-
|
240
|
-
|
253
|
+
type =
|
254
|
+
Interface::MethodType.new(
|
255
|
+
type_params: type_params,
|
256
|
+
type: Interface::Function.new(
|
257
|
+
params: params(method_type.type).subst(subst),
|
258
|
+
return_type: type(method_type.type.return_type).subst(subst),
|
259
|
+
location: method_type.location
|
260
|
+
),
|
261
|
+
block: method_type.block&.yield_self do |block|
|
262
|
+
Interface::Block.new(
|
263
|
+
optional: !block.required,
|
264
|
+
type: Interface::Function.new(
|
265
|
+
params: params(block.type).subst(subst),
|
266
|
+
return_type: type(block.type.return_type).subst(subst),
|
267
|
+
location: nil
|
268
|
+
)
|
241
269
|
)
|
242
|
-
|
243
|
-
|
244
|
-
|
245
|
-
)
|
270
|
+
end,
|
271
|
+
method_decls: method_decls
|
272
|
+
)
|
246
273
|
|
247
274
|
if block_given?
|
248
275
|
yield type
|
@@ -258,20 +285,14 @@ module Steep
|
|
258
285
|
alpha_vars = []
|
259
286
|
alpha_types = []
|
260
287
|
|
261
|
-
method_type.type_params.
|
262
|
-
if fvs.include?(name)
|
263
|
-
type = RBS::Types::Variable.new(name: name, location: nil),
|
264
|
-
alpha_vars << name
|
265
|
-
alpha_types << type
|
266
|
-
type_params << type.name
|
267
|
-
else
|
268
|
-
type_params << name
|
269
|
-
end
|
288
|
+
conflicting_names = method_type.type_params.each.with_object([]) do |param, names|
|
289
|
+
names << params.name if fvs.include?(param.name)
|
270
290
|
end
|
271
|
-
|
291
|
+
|
292
|
+
type_params, subst = Interface::TypeParam.rename(method_type.type_params, conflicting_names)
|
272
293
|
|
273
294
|
type = RBS::MethodType.new(
|
274
|
-
type_params: type_params,
|
295
|
+
type_params: type_params.map {|param| type_param_1(param) },
|
275
296
|
type: function_1(method_type.type.subst(subst)),
|
276
297
|
block: method_type.block&.yield_self do |block|
|
277
298
|
block_type = block.type.subst(subst)
|
@@ -300,16 +321,19 @@ module Steep
|
|
300
321
|
end
|
301
322
|
end
|
302
323
|
|
303
|
-
def unfold(type_name)
|
304
|
-
|
305
|
-
|
306
|
-
|
324
|
+
def unfold(type_name, args)
|
325
|
+
type(
|
326
|
+
definition_builder.expand_alias2(
|
327
|
+
type_name,
|
328
|
+
args.empty? ? args : args.map {|t| type_1(t) }
|
329
|
+
)
|
330
|
+
)
|
307
331
|
end
|
308
332
|
|
309
333
|
def expand_alias(type)
|
310
334
|
unfolded = case type
|
311
335
|
when AST::Types::Name::Alias
|
312
|
-
unfold(type.name)
|
336
|
+
unfold(type.name, type.args)
|
313
337
|
else
|
314
338
|
type
|
315
339
|
end
|
data/lib/steep/ast/types/var.rb
CHANGED
@@ -21,17 +21,21 @@ module Steep
|
|
21
21
|
|
22
22
|
alias eql? ==
|
23
23
|
|
24
|
-
def self.
|
24
|
+
def self.fresh_name(name)
|
25
25
|
@mutex ||= Mutex.new
|
26
26
|
|
27
27
|
@mutex.synchronize do
|
28
28
|
@max ||= 0
|
29
29
|
@max += 1
|
30
30
|
|
31
|
-
|
31
|
+
:"#{name}(#{@max})"
|
32
32
|
end
|
33
33
|
end
|
34
34
|
|
35
|
+
def self.fresh(name, location: nil)
|
36
|
+
new(name: fresh_name(name), location: location)
|
37
|
+
end
|
38
|
+
|
35
39
|
def to_s
|
36
40
|
name.to_s
|
37
41
|
end
|
@@ -52,8 +56,15 @@ module Steep
|
|
52
56
|
[0]
|
53
57
|
end
|
54
58
|
|
59
|
+
def update(name: self.name, location: self.location)
|
60
|
+
self.class.new(
|
61
|
+
name: name,
|
62
|
+
location: location
|
63
|
+
)
|
64
|
+
end
|
65
|
+
|
55
66
|
def with_location(new_location)
|
56
|
-
|
67
|
+
update(location: new_location)
|
57
68
|
end
|
58
69
|
end
|
59
70
|
end
|
@@ -26,20 +26,32 @@ module Steep
|
|
26
26
|
end
|
27
27
|
|
28
28
|
module ResultPrinter
|
29
|
-
def
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
29
|
+
def relation_message(relation)
|
30
|
+
case
|
31
|
+
when relation.type?
|
32
|
+
relation.to_s
|
33
|
+
when relation.method?
|
34
|
+
if relation.super_type.is_a?(Interface::MethodType) && relation.sub_type.is_a?(Interface::MethodType)
|
35
|
+
relation.to_s
|
36
|
+
end
|
37
|
+
when relation.interface?
|
38
|
+
nil
|
39
|
+
when relation.block?
|
40
|
+
nil
|
41
|
+
when relation.function?
|
42
|
+
nil
|
43
|
+
when relation.params?
|
44
|
+
nil
|
45
|
+
end
|
38
46
|
end
|
39
47
|
|
40
48
|
def detail_lines
|
41
49
|
StringIO.new.tap do |io|
|
42
|
-
|
50
|
+
result.failure_path&.reverse_each.map do |result|
|
51
|
+
relation_message(result.relation)
|
52
|
+
end.compact.each.with_index(1) do |message, index|
|
53
|
+
io.puts "#{" " * (index)}#{message}"
|
54
|
+
end
|
43
55
|
end.string.chomp
|
44
56
|
end
|
45
57
|
end
|
@@ -440,7 +452,7 @@ module Steep
|
|
440
452
|
super(node: node)
|
441
453
|
@interface_method = interface_method
|
442
454
|
@annotation_method = annotation_method
|
443
|
-
@result =
|
455
|
+
@result = relation
|
444
456
|
end
|
445
457
|
end
|
446
458
|
|
@@ -101,6 +101,23 @@ module Steep
|
|
101
101
|
end
|
102
102
|
end
|
103
103
|
|
104
|
+
class UnsatisfiableTypeApplication < Base
|
105
|
+
attr_reader :type_name
|
106
|
+
attr_reader :type_arg
|
107
|
+
attr_reader :type_param
|
108
|
+
|
109
|
+
def initialize(type_name:, type_arg:, type_param:, location:)
|
110
|
+
super(location: location)
|
111
|
+
@type_name = type_name
|
112
|
+
@type_arg = type_arg
|
113
|
+
@type_param = type_param
|
114
|
+
end
|
115
|
+
|
116
|
+
def header_line
|
117
|
+
"Type application of `#{type_name}` doesn't satisfy the constraints: #{type_arg} <: #{type_param.upper_bound}"
|
118
|
+
end
|
119
|
+
end
|
120
|
+
|
104
121
|
class InvalidMethodOverload < Base
|
105
122
|
attr_reader :class_name
|
106
123
|
attr_reader :method_name
|
@@ -307,6 +324,34 @@ module Steep
|
|
307
324
|
end
|
308
325
|
end
|
309
326
|
|
327
|
+
class RecursiveTypeAlias < Base
|
328
|
+
attr_reader :alias_names
|
329
|
+
|
330
|
+
def initialize(alias_names:, location:)
|
331
|
+
@alias_names = alias_names
|
332
|
+
super(location: location)
|
333
|
+
end
|
334
|
+
|
335
|
+
def header_line
|
336
|
+
"Type aliases cannot be *directly recursive*: #{alias_names.join(", ")}"
|
337
|
+
end
|
338
|
+
end
|
339
|
+
|
340
|
+
class NonregularTypeAlias < Base
|
341
|
+
attr_reader :type_name
|
342
|
+
attr_reader :nonregular_type
|
343
|
+
|
344
|
+
def initialize(type_name:, nonregular_type:, location:)
|
345
|
+
@type_name = type_name
|
346
|
+
@nonregular_type = nonregular_type
|
347
|
+
@location = location
|
348
|
+
end
|
349
|
+
|
350
|
+
def header_line
|
351
|
+
"Type alias #{type_name} is defined *non-regular*: #{nonregular_type}"
|
352
|
+
end
|
353
|
+
end
|
354
|
+
|
310
355
|
def self.from_rbs_error(error, factory:)
|
311
356
|
case error
|
312
357
|
when RBS::ParsingError
|
@@ -388,6 +433,17 @@ module Steep
|
|
388
433
|
type_name: error.type_name,
|
389
434
|
member: error.member,
|
390
435
|
)
|
436
|
+
when RBS::RecursiveTypeAliasError
|
437
|
+
Diagnostic::Signature::RecursiveTypeAlias.new(
|
438
|
+
alias_names: error.alias_names,
|
439
|
+
location: error.location
|
440
|
+
)
|
441
|
+
when RBS::NonregularTypeAliasError
|
442
|
+
Diagnostic::Signature::NonregularTypeAlias.new(
|
443
|
+
type_name: error.diagnostic.type_name,
|
444
|
+
nonregular_type: factory.type(error.diagnostic.nonregular_type),
|
445
|
+
location: error.location
|
446
|
+
)
|
391
447
|
else
|
392
448
|
raise error
|
393
449
|
end
|