Sha256: 59ff6d917bc30b1479c97b3ffb1ae53f6c8b1c7443e48b1009bfc8df5245ea72
Contents?: true
Size: 1.13 KB
Versions: 3
Compression:
Stored size: 1.13 KB
Contents
module Steep module Subtyping class VariableOccurence attr_reader :params attr_reader :returns def initialize @params = Set.new @returns = Set.new end def add_method_type(method_type) method_type.params.each_type do |type| each_var(type) do |var| params << var end end each_var(method_type.return_type) do |var| returns << var end method_type.block&.yield_self do |block| block.type.params.each_type do |type| each_var(type) do |var| params << var end end each_var(block.type.return_type) do |var| returns << var end end params.subtract(returns) end def each_var(type, &block) type.free_variables.each(&block) end def strictly_return?(var) !params.member?(var) && returns.member?(var) end def self.from_method_type(method_type) self.new.tap do |occurence| occurence.add_method_type(method_type) end end end end end
Version data entries
3 entries across 3 versions & 1 rubygems
Version | Path |
---|---|
steep-0.36.0 | lib/steep/subtyping/variable_occurrence.rb |
steep-0.35.0 | lib/steep/subtyping/variable_occurrence.rb |
steep-0.34.0 | lib/steep/subtyping/variable_occurrence.rb |