module TypedRb::Types::Polymorphism::GenericVariables

Public Instance Methods

type_vars(options = { recursive: true }) click to toggle source
# File lib/typed/types/polymorphism/generic_variables.rb, line 5
def type_vars(options = { recursive: true })
  return @type_vars unless options[:recursive]
  return @type_vars if self.class == TypedRb::Types::TyGenericObject
  @type_vars.map do |type_var|
    if type_var.is_a?(Polymorphism::TypeVariable) && type_var.bound_to_generic?
      type_var.bound.type_vars
    elsif type_var.is_a?(Polymorphism::TypeVariable)
      type_var
    else
      type_var.type_vars
    end
  end.flatten
  #  .each_with_object({}) do |type_var, acc|
  #  acc[type_var.variable] = type_var
  #end.values
end
unbound_vars() click to toggle source
# File lib/typed/types/polymorphism/generic_variables.rb, line 22
def unbound_vars
  @type_vars.map do |type_var|
    if type_var.is_a?(Polymorphism::TypeVariable) && type_var.bound_to_generic?
      type_var.bound.unbound_vars
    elsif type_var.is_a?(Polymorphism::TypeVariable)
      type_var if type_var.bound.nil?
    else
      type_var.unbound_vars
    end
  end.flatten.reject(&:nil?)
end