lib/rbs/variance_calculator.rb in rbs-1.8.1 vs lib/rbs/variance_calculator.rb in rbs-2.0.0.pre1
- old
+ new
@@ -139,17 +139,18 @@
when Types::Alias
env.alias_decls[type.name].decl.type_params
end
type.args.each.with_index do |ty, i|
- var = type_params.params[i]
- case var&.variance
- when :invariant
- type(ty, result: result, context: :invariant)
- when :covariant
- type(ty, result: result, context: context)
- when :contravariant
- type(ty, result: result, context: negate(context))
+ if var = type_params[i]
+ case var.variance
+ when :invariant
+ type(ty, result: result, context: :invariant)
+ when :covariant
+ type(ty, result: result, context: context)
+ when :contravariant
+ type(ty, result: result, context: negate(context))
+ end
end
end
when Types::Proc
function(type.type, result: result, context: context)
else