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 inside `class << self` if hook_mod != current_declaration.mod && hook_mod.singleton_class != current_declaration.mod 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 if current_declaration.returns.equal?(ARG_NOT_PROVIDED) sig_error(loc, "You must provide a return type; use the `.returns` or `.void` builder methods. Method: #{original_method}") 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, soft_notify: current_declaration.soft_notify, override_allow_incompatible: current_declaration.override_allow_incompatible, generated: current_declaration.generated, ) SignatureValidation.validate(signature) signature rescue => e super_method = original_method&.super_method super_signature = signature_for_method(super_method) if super_method T::Private::ErrorHandler.handle_sig_validation_error( e, method: original_method, declaration: current_declaration, signature: signature, super_signature: super_signature ) Signature.new_untyped(method: original_method) end end