Skip to content

Commit 19072d9

Browse files
committed
Normalize type args before runtime type check
1 parent 9dcf69d commit 19072d9

File tree

1 file changed

+7
-0
lines changed

1 file changed

+7
-0
lines changed

lib/rbs/test/type_check.rb

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -260,6 +260,13 @@ def value(val, type)
260260
Test.call(val, IS_AP, instance_class)
261261
when Types::ClassInstance
262262
klass = get_class(type.name) or return false
263+
if params = builder.env.normalized_module_class_entry(type.name.absolute!)&.type_params
264+
args = AST::TypeParam.normalize_args(params, type.args)
265+
unless args == type.args
266+
type = Types::ClassInstance.new(name: type.name, args: args, location: type.location)
267+
end
268+
end
269+
263270
case
264271
when klass == ::Array
265272
Test.call(val, IS_AP, klass) && each_sample(val).all? {|v| value(v, type.args[0]) }

0 commit comments

Comments
 (0)