module T::Private::Methods::SignatureValidation

def self.validate_override_mode(signature, super_signature)

def self.validate_override_mode(signature, super_signature)
  case signature.mode
  when *Modes::OVERRIDE_MODES
    # Peaceful
  when Modes.abstract
    # Either the parent method is abstract, or it's not.
    #
    # If it's abstract, we want to allow overriding abstract with abstract to
    # possibly narrow the type or provide more specific documentation.
    #
    # If it's not, then marking this method `abstract` will silently be a no-op.
    # That's bad and we probably want to report an error, but fixing that
    # will have to be a separate fix (that bad behavior predates this current
    # comment, introduced when we fixed the abstract/abstract case).
    #
    # Therefore:
    # Peaceful (mostly)
  when *Modes::NON_OVERRIDE_MODES
    if super_signature.mode == Modes.standard
      # Peaceful
    elsif super_signature.mode == Modes.abstract
      raise "You must use `.override` when overriding the abstract method `#{signature.method_name}`.\n" \
            "  Abstract definition: #{method_loc_str(super_signature.method)}\n" \
            "  Implementation definition: #{method_loc_str(signature.method)}\n"
    elsif super_signature.mode != Modes.untyped
      raise "You must use `.override` when overriding the existing method `#{signature.method_name}`.\n" \
            "  Parent definition: #{method_loc_str(super_signature.method)}\n" \
            "  Child definition:  #{method_loc_str(signature.method)}\n"
    end
  else
    raise "Unexpected mode: #{signature.mode}. Please report this bug at https://github.com/sorbet/sorbet/issues"
  end
end