Class: Steep::Diagnostic::Signature::RecursiveAncestor

Inherits:
Base
  • Object
show all
Defined in:
lib/steep/diagnostic/signature.rb

Instance Attribute Summary collapse

Attributes inherited from Base

#location

Instance Method Summary collapse

Methods inherited from Base

#detail_lines, #diagnostic_code, #path

Methods included from Helper

#error_name, #full_message

Constructor Details

#initialize(ancestors:, location:) ⇒ RecursiveAncestor

Returns a new instance of RecursiveAncestor.



188
189
190
191
# File 'lib/steep/diagnostic/signature.rb', line 188

def initialize(ancestors:, location:)
  super(location: location)
  @ancestors = ancestors
end

Instance Attribute Details

#ancestorsObject (readonly)

Returns the value of attribute ancestors.



186
187
188
# File 'lib/steep/diagnostic/signature.rb', line 186

def ancestors
  @ancestors
end

Instance Method Details

#header_lineObject



193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
# File 'lib/steep/diagnostic/signature.rb', line 193

def header_line
  names = ancestors.map do |ancestor|
    case ancestor
    when RBS::Definition::Ancestor::Singleton
      "singleton(#{ancestor.name})"
    when RBS::Definition::Ancestor::Instance
      if ancestor.args.empty?
        ancestor.name.to_s
      else
        "#{ancestor.name}[#{ancestor.args.join(", ")}]"
      end
    end
  end

  "Circular inheritance/mix-in is detected: #{names.join(" <: ")}"
end