module T::Private::Methods::SignatureValidation
def self.validate_non_override_mode(signature)
def self.validate_non_override_mode(signature) case signature.mode when Modes.override raise "You marked `#{signature.method_name}` as #{pretty_mode(signature)}, but that method doesn't already exist in this class/module to be overriden.\n" \ " Either check for typos and for missing includes or super classes to make the parent method shows up\n" \ " ... or remove #{pretty_mode(signature)} here: #{method_loc_str(signature.method)}\n" when Modes.standard, *Modes::NON_OVERRIDE_MODES # Peaceful nil when *Modes::IMPLEMENT_MODES raise "You marked `#{signature.method_name}` as #{pretty_mode(signature)}, but it doesn't match up with a corresponding abstract method.\n" \ " Either check for typos and for missing includes or super classes to make the parent method shows up\n" \ " ... or remove #{pretty_mode(signature)} here: #{method_loc_str(signature.method)}\n" else raise "Unexpected mode: #{signature.mode}. Please report to #dev-productivity." end owner = signature.method.owner if (signature.mode == Modes.abstract || Modes::OVERRIDABLE_MODES.include?(signature.mode)) && owner.singleton_class? # Given a singleton class, we can check if it belongs to a # module by looking at its superclass; given `module M`, # `M.singleton_class.superclass == Module`, which is not true # for any class. if owner.superclass == Module raise "Defining an overridable class method (via #{pretty_mode(signature)}) " \ "on a module is not allowed. Class methods on " \ "modules do not get inherited and thus cannot be overridden. For help, ask in " \ "#dev-productivity." end end end