Class: RBS::VarianceCalculator::Result
Relationships & Source Files | |
Inherits: | Object |
Defined in: | lib/rbs/variance_calculator.rb |
Class Method Summary
- .new(variables:) ⇒ Result constructor
Instance Attribute Summary
- #result readonly
Instance Method Summary
Constructor Details
.new(variables:) ⇒ Result
Instance Attribute Details
#result (readonly)
[ GitHub ]# File 'lib/rbs/variance_calculator.rb', line 6
attr_reader :result
Instance Method Details
#compatible?(var, with_annotation:) ⇒ Boolean
#contravariant(x)
[ GitHub ]#covariant(x)
[ GitHub ]# File '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)
[ GitHub ]# File 'lib/rbs/variance_calculator.rb', line 37
def each(&block) result.each(&block) end
#include?(name) ⇒ Boolean
# File 'lib/rbs/variance_calculator.rb', line 41
def include?(name) result.key?(name) end
#incompatible?(params) ⇒ Boolean
# File '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)
[ GitHub ]# File 'lib/rbs/variance_calculator.rb', line 33
def invariant(x) result[x] = :invariant end