module T::Private::Methods
def self._handle_missing_method_signature(receiver, original_method, callee)
def self._handle_missing_method_signature(receiver, original_method, callee) method_sig = T::Private::Methods.signature_for_method(original_method) if !method_sig raise "`sig` not present for method `#{callee}` on #{receiver.inspect} but you're trying to run it anyways. " \ "This should only be executed if you used `alias_method` to grab a handle to a method after `sig`ing it, but that clearly isn't what you are doing. " \ "Maybe look to see if an exception was thrown in your `sig` lambda or somehow else your `sig` wasn't actually applied to the method." end if receiver.class <= original_method.owner receiving_class = receiver.class elsif receiver.singleton_class <= original_method.owner receiving_class = receiver.singleton_class elsif receiver.is_a?(Module) && receiver <= original_method.owner receiving_class = receiver else raise "#{receiver} is not related to #{original_method} - how did we get here?" end # Check for a case where `alias` or `alias_method` was called for a # method which had already had a `sig` applied. In that case, we want # to avoid hitting this slow path again, by moving to a faster validator # just like we did or will for the original method. # # If this isn't an `alias` or `alias_method` case, we're probably in the # middle of some metaprogramming using a Method object, e.g. a pattern like # `arr.map(&method(:foo))`. There's nothing really we can do to optimize # that here. receiving_method = receiving_class.instance_method(callee) if receiving_method != original_method && receiving_method.original_name == original_method.name aliasing_mod = receiving_method.owner method_sig = method_sig.as_alias(callee) unwrap_method(aliasing_mod, method_sig, original_method) end method_sig end