class RBS::Definition::Method

def ==(other)

def ==(other)
  other.is_a?(Method) &&
    other.super_method == super_method &&
    other.defs == defs &&
    other.accessibility == accessibility &&
    other.annotations == annotations &&
    other.alias_of == alias_of &&
    other.alias_member == alias_member
end

def comments

def comments
  @comments ||= defs.map(&:comment).compact.uniq
end

def defined_in

def defined_in
  @defined_in ||= begin
    last_def = defs.last or raise
    last_def.defined_in
  end
end

def hash

def hash
  self.class.hash ^ super_method.hash ^ defs.hash ^ accessibility.hash ^ annotations.hash ^ alias_of.hash
end

def implemented_in

def implemented_in
  @implemented_in ||= begin
    last_def = defs.last or raise
    last_def.implemented_in
  end
end

def initialize(super_method:, defs:, accessibility:, annotations: [], alias_of:, alias_member: nil)

def initialize(super_method:, defs:, accessibility:, annotations: [], alias_of:, alias_member: nil)
  @super_method = super_method
  @defs = defs
  @accessibility = accessibility
  @extra_annotations = []
  @annotations = []
  @alias_of = alias_of
  @alias_member = alias_member
end

def map_method_type(&block)

def map_method_type(&block)
  update(
    defs: defs.map {|defn| defn.update(type: yield(defn.type)) },
  )
end

def map_type(&block)

def map_type(&block)
  update(
    super_method: super_method&.map_type(&block),
    defs: defs.map {|defn| defn.update(type: defn.type.map_type(&block)) }
  )
end

def map_type_bound(&block)

def map_type_bound(&block)
  update(
    super_method: super_method&.map_type_bound(&block),
    defs: defs.map {|defn| defn.update(type: defn.type.map_type_bound(&block)) }
  )
end

def members

def members
  @members ||= defs.map(&:member).uniq
end

def method_types

def method_types
  @method_types ||= defs.map(&:type)
end

def private?

def private?
  @accessibility == :private
end

def public?

def public?
  @accessibility == :public
end

def sub(s)

def sub(s)
  return self if s.empty?
  update(
    super_method: super_method&.sub(s),
    defs: defs.map {|defn| defn.update(type: defn.type.sub(s)) }
  )
end

def update(super_method: self.super_method, defs: self.defs, accessibility: self.accessibility, alias_of: self.alias_of, annotations: self.annotations, alias_member: self.alias_member)

def update(super_method: self.super_method, defs: self.defs, accessibility: self.accessibility, alias_of: self.alias_of, annotations: self.annotations, alias_member: self.alias_member)
  self.class.new(
    super_method: super_method,
    defs: defs,
    accessibility: accessibility,
    alias_of: alias_of,
    alias_member: alias_member
  ).tap do |method|
    method.annotations.replace(annotations)
  end
end