You are an expert in writing code in many different languages. Your goal is to perform code completion for the following code, keeping in mind the rest of the code and the file meta data.
    Metadata details:
    filename: casts.rb
    path of file: ./repos/sorbet/gems/sorbet-runtime/lib/types/private
    
    the code of the file until where you have to start completion: # frozen_string_literal: true
# typed: false

module T::Private
  module Casts
    def self.cast(value, type, cast_method)
      begin
        coerced_type = T::Utils::Private.coerce_and_check_module_types(type, value, true)
        return value unless coerced_type

        error
    
    def self.cast(value, type, cast_method)
      begin
        coerced_type = T::Utils::Private.coerce_and_check_module_types(type, value, true)
        return value unless coerced_type

        error = coerced_type.error_message_for_obj(value)
        return value unless error

        caller_loc = T.must(caller_locations(2..2)).first

        suffix = "Caller: #{T.must(caller_loc).path}:#{T.must(caller_loc).lineno}"

        raise TypeError.new("#{cast_method}: #{error}\n#{suffix}")
      rescue TypeError => e # raise into rescue to ensure e.backtrace is populated
        T::Configuration.inline_type_error_handler(e, {kind: cast_method, value: value, type: type})
        value
      end