class RBS::RecursiveAncestorError

def initialize(ancestors:, location:)

def initialize(ancestors:, location:)
  @ancestors = ancestors
  @location = location
  names = ancestors.map do |ancestor|
    case ancestor
    when Definition::Ancestor::Singleton
      "singleton(#{ancestor.name})"
    when Definition::Ancestor::Instance
      if ancestor.args.empty?
        ancestor.name.to_s
      else
        "#{ancestor.name}[#{ancestor.args.join(", ")}]"
      end
    end
  end
  super "#{Location.to_string location}: Detected recursive ancestors: #{names.join(" < ")}"
end