module T::Private::Methods
def self.build_sig(hook_mod, method_name, original_method, current_declaration, loc)
def self.build_sig(hook_mod, method_name, original_method, current_declaration, loc) begin # We allow `sig` in the current module's context (normal case) and if hook_mod != current_declaration.mod && # inside `class << self`, and hook_mod.singleton_class != current_declaration.mod && # on `self` at the top level of a file current_declaration.mod != TOP_SELF raise "A method (#{method_name}) is being added on a different class/module (#{hook_mod}) than the " \ "last call to `sig` (#{current_declaration.mod}). Make sure each call " \ "to `sig` is immediately followed by a method definition on the same " \ "class/module." end signature = Signature.new( method: original_method, method_name: method_name, raw_arg_types: current_declaration.params, raw_return_type: current_declaration.returns, bind: current_declaration.bind, mode: current_declaration.mode, check_level: current_declaration.checked, on_failure: current_declaration.on_failure, override_allow_incompatible: current_declaration.override_allow_incompatible, ) SignatureValidation.validate(signature) signature rescue => e super_method = original_method&.super_method super_signature = signature_for_method(super_method) if super_method T::Configuration.sig_validation_error_handler( e, method: original_method, declaration: current_declaration, signature: signature, super_signature: super_signature ) Signature.new_untyped(method: original_method) end end