class RBS::VarianceCalculator::Result
属性
result[R]
公共类方法
new(variables:) 点击切换源代码
# File rbs-3.8.0/lib/rbs/variance_calculator.rb, line 8 def initialize(variables:) @result = {} variables.each do |x| result[x] = :unused end end
公共实例方法
compatible?(var, with_annotation:) 点击切换源代码
# File rbs-3.8.0/lib/rbs/variance_calculator.rb, line 45 def compatible?(var, with_annotation:) variance = result[var] case when variance == :unused true when with_annotation == :invariant true when variance == with_annotation true else false end end
contravariant(x) 点击切换源代码
# File rbs-3.8.0/lib/rbs/variance_calculator.rb, line 24 def contravariant(x) case result[x] when :unused result[x] = :contravariant when :covariant result[x] = :invariant end end
covariant(x) 点击切换源代码
# File rbs-3.8.0/lib/rbs/variance_calculator.rb, line 15 def covariant(x) case result[x] when :unused result[x] = :covariant when :contravariant result[x] = :invariant end end
each(&block) 点击切换源代码
# File rbs-3.8.0/lib/rbs/variance_calculator.rb, line 37 def each(&block) result.each(&block) end
include?(name) 点击切换源代码
# File rbs-3.8.0/lib/rbs/variance_calculator.rb, line 41 def include?(name) result.key?(name) end
incompatible?(params) 点击切换源代码
# File rbs-3.8.0/lib/rbs/variance_calculator.rb, line 60 def incompatible?(params) # @type set: Hash[Symbol] set = Set[] params.each do |param| unless compatible?(param.name, with_annotation: param.variance) set << param.name end end unless set.empty? set end end
invariant(x) 点击切换源代码
# File rbs-3.8.0/lib/rbs/variance_calculator.rb, line 33 def invariant(x) result[x] = :invariant end