module RBS::Types::Application

def ==(other)

def ==(other)
  other.is_a?(self.class) && other.name == name && other.args == args
end

def each_type(&block)

def each_type(&block)
  if block
    args.each(&block)
  else
    enum_for :each_type
  end
end

def free_variables(set = Set.new)

def free_variables(set = Set.new)
  set.tap do
    args.each do |arg|
      arg.free_variables(set)
    end
  end
end

def has_classish_type?

def has_classish_type?
  each_type.any? {|type| type.has_classish_type? }
end

def has_self_type?

def has_self_type?
  each_type.any? {|type| type.has_self_type? }
end

def hash

def hash
  name.hash ^ args.hash
end

def to_s(level = 0)

def to_s(level = 0)
  if args.empty?
    name.to_s
  else
    "#{name}[#{args.join(", ")}]"
  end
end

def with_nonreturn_void?

def with_nonreturn_void?
  each_type.any? do |type|
    if type.is_a?(Bases::Void)
      # `void` in immediate generics parameter is allowed
      false
    else
      type.with_nonreturn_void?
    end
  end
end