Skip to content

Commit 9dcf69d

Browse files
committed
Add void as generics default type
1 parent a3bca67 commit 9dcf69d

File tree

1 file changed

+41
-1
lines changed

1 file changed

+41
-1
lines changed

lib/rbs/cli/validate.rb

Lines changed: 41 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -164,7 +164,7 @@ def validate_class_module_definition
164164
end
165165

166166
if dt = param.default_type
167-
void_type_context_validator(dt)
167+
void_type_context_validator(dt, true)
168168
no_self_type_validator(dt)
169169
no_classish_type_validator(dt)
170170
@validator.validate_type(dt, context: nil)
@@ -232,6 +232,22 @@ def validate_interface
232232
location: decl.decl.location&.aref(:type_params)
233233
)
234234

235+
decl.decl.type_params.each do |param|
236+
if ub = param.upper_bound_type
237+
void_type_context_validator(ub)
238+
no_self_type_validator(ub)
239+
no_classish_type_validator(ub)
240+
@validator.validate_type(ub, context: nil)
241+
end
242+
243+
if dt = param.default_type
244+
void_type_context_validator(dt, true)
245+
no_self_type_validator(dt)
246+
no_classish_type_validator(dt)
247+
@validator.validate_type(dt, context: nil)
248+
end
249+
end
250+
235251
decl.decl.members.each do |member|
236252
case member
237253
when AST::Members::MethodDefinition
@@ -278,7 +294,31 @@ def validate_type_alias
278294
@builder.expand_alias1(name).tap do |type|
279295
@validator.validate_type type, context: nil
280296
end
297+
281298
@validator.validate_type_alias(entry: decl)
299+
300+
@validator.validate_type_params(
301+
decl.decl.type_params,
302+
type_name: name,
303+
location: decl.decl.location&.aref(:type_params)
304+
)
305+
306+
decl.decl.type_params.each do |param|
307+
if ub = param.upper_bound_type
308+
void_type_context_validator(ub)
309+
no_self_type_validator(ub)
310+
no_classish_type_validator(ub)
311+
@validator.validate_type(ub, context: nil)
312+
end
313+
314+
if dt = param.default_type
315+
void_type_context_validator(dt, true)
316+
no_self_type_validator(dt)
317+
no_classish_type_validator(dt)
318+
@validator.validate_type(dt, context: nil)
319+
end
320+
end
321+
282322
no_self_type_validator(decl.decl.type)
283323
no_classish_type_validator(decl.decl.type)
284324
void_type_context_validator(decl.decl.type)

0 commit comments

Comments
 (0)