Skip to content

Commit 4890879

Browse files
committed
Remove context validation logic
1 parent fd2b71c commit 4890879

1 file changed

Lines changed: 0 additions & 76 deletions

File tree

lib/rbs/cli/validate.rb

Lines changed: 0 additions & 76 deletions
Original file line numberDiff line numberDiff line change
@@ -112,9 +112,6 @@ def validate_class_module_definition
112112
entry.each_decl do |decl|
113113
if super_class = decl.super_class
114114
super_class.args.each do |arg|
115-
void_type_context_validator(arg, true)
116-
no_self_type_validator(arg)
117-
no_classish_type_validator(arg)
118115
@validator.validate_type(arg, context: nil)
119116
end
120117
end
@@ -123,9 +120,6 @@ def validate_class_module_definition
123120
entry.each_decl do |decl|
124121
decl.self_types.each do |self_type|
125122
self_type.args.each do |arg|
126-
void_type_context_validator(arg, true)
127-
no_self_type_validator(arg)
128-
no_classish_type_validator(arg)
129123
@validator.validate_type(arg, context: nil)
130124
end
131125

@@ -153,16 +147,10 @@ def validate_class_module_definition
153147

154148
d.type_params.each do |param|
155149
if ub = param.upper_bound_type
156-
void_type_context_validator(ub)
157-
no_self_type_validator(ub)
158-
no_classish_type_validator(ub)
159150
@validator.validate_type(ub, context: nil)
160151
end
161152

162153
if dt = param.default_type
163-
void_type_context_validator(dt, true)
164-
no_self_type_validator(dt)
165-
no_classish_type_validator(dt)
166154
@validator.validate_type(dt, context: nil)
167155
end
168156
end
@@ -176,18 +164,7 @@ def validate_class_module_definition
176164
case member
177165
when AST::Members::MethodDefinition
178166
@validator.validate_method_definition(member, type_name: name)
179-
member.overloads.each do |ov|
180-
void_type_context_validator(ov.method_type)
181-
end
182-
when AST::Members::Attribute
183-
void_type_context_validator(member.type)
184167
when AST::Members::Mixin
185-
member.args.each do |arg|
186-
no_self_type_validator(arg)
187-
unless arg.is_a?(Types::Bases::Void)
188-
void_type_context_validator(arg, true)
189-
end
190-
end
191168
params =
192169
if member.name.class?
193170
module_decl = @env.normalized_module_entry(member.name) or raise
@@ -199,10 +176,6 @@ def validate_class_module_definition
199176
InvalidTypeApplicationError.check!(type_name: member.name, params: params, args: member.args, location: member.location)
200177
when AST::Members::Var
201178
@validator.validate_variable(member)
202-
void_type_context_validator(member.type)
203-
if member.is_a?(AST::Members::ClassVariable)
204-
no_self_type_validator(member.type)
205-
end
206179
end
207180
end
208181
else
@@ -238,16 +211,10 @@ def validate_interface
238211

239212
decl.decl.type_params.each do |param|
240213
if ub = param.upper_bound_type
241-
void_type_context_validator(ub)
242-
no_self_type_validator(ub)
243-
no_classish_type_validator(ub)
244214
@validator.validate_type(ub, context: nil)
245215
end
246216

247217
if dt = param.default_type
248-
void_type_context_validator(dt, true)
249-
no_self_type_validator(dt)
250-
no_classish_type_validator(dt)
251218
@validator.validate_type(dt, context: nil)
252219
end
253220
end
@@ -258,10 +225,6 @@ def validate_interface
258225
case member
259226
when AST::Members::MethodDefinition
260227
@validator.validate_method_definition(member, type_name: name)
261-
member.overloads.each do |ov|
262-
void_type_context_validator(ov.method_type)
263-
no_classish_type_validator(ov.method_type)
264-
end
265228
end
266229
end
267230
rescue BaseError => error
@@ -274,9 +237,6 @@ def validate_constant
274237
RBS.logger.info "Validating constant: `#{name}`..."
275238
@validator.validate_type const.decl.type, context: const.context
276239
@builder.ensure_namespace!(name.namespace, location: const.decl.location)
277-
no_self_type_validator(const.decl.type)
278-
no_classish_type_validator(const.decl.type)
279-
void_type_context_validator(const.decl.type)
280240
rescue BaseError => error
281241
@errors.add(error)
282242
end
@@ -286,9 +246,6 @@ def validate_global
286246
@env.global_decls.each do |name, global|
287247
RBS.logger.info "Validating global: `#{name}`..."
288248
@validator.validate_type global.decl.type, context: nil
289-
no_self_type_validator(global.decl.type)
290-
no_classish_type_validator(global.decl.type)
291-
void_type_context_validator(global.decl.type)
292249
rescue BaseError => error
293250
@errors.add(error)
294251
end
@@ -311,52 +268,19 @@ def validate_type_alias
311268

312269
decl.decl.type_params.each do |param|
313270
if ub = param.upper_bound_type
314-
void_type_context_validator(ub)
315-
no_self_type_validator(ub)
316-
no_classish_type_validator(ub)
317271
@validator.validate_type(ub, context: nil)
318272
end
319273

320274
if dt = param.default_type
321-
void_type_context_validator(dt, true)
322-
no_self_type_validator(dt)
323-
no_classish_type_validator(dt)
324275
@validator.validate_type(dt, context: nil)
325276
end
326277
end
327278

328279
TypeParamDefaultReferenceError.check!(decl.decl.type_params)
329-
330-
no_self_type_validator(decl.decl.type)
331-
no_classish_type_validator(decl.decl.type)
332-
void_type_context_validator(decl.decl.type)
333280
rescue BaseError => error
334281
@errors.add(error)
335282
end
336283
end
337-
338-
private
339-
340-
def no_self_type_validator(type)
341-
if type.has_self_type?
342-
@errors.add WillSyntaxError.new("`self` type is not allowed in this context", location: type.location)
343-
end
344-
end
345-
346-
def no_classish_type_validator(type)
347-
if type.has_classish_type?
348-
@errors.add WillSyntaxError.new("`instance` or `class` type is not allowed in this context", location: type.location)
349-
end
350-
end
351-
352-
def void_type_context_validator(type, allowed_here = false)
353-
if allowed_here
354-
return if type.is_a?(Types::Bases::Void)
355-
end
356-
if type.with_nonreturn_void?
357-
@errors.add WillSyntaxError.new("`void` type is only allowed in return type or generics parameter", location: type.location)
358-
end
359-
end
360284
end
361285
end
362286
end

0 commit comments

Comments
 (0)