module T::Private::CallerUtils

def self.find_caller

RUBY_VERSION >= "3.2"
def self.find_caller
  skipped_first = false
  Thread.each_caller_location do |loc|
    unless skipped_first
      skipped_first = true
      next
    end
    next if loc.path&.start_with?("<internal:")
    return loc if yield(loc)
  end
  nil
end

def self.find_caller

def self.find_caller
  caller_locations(2).find do |loc|
    !loc.path&.start_with?("<internal:") && yield(loc)
  end
end