module T::Private::Sealed

def self.validate_inheritance(caller_loc, parent, child, verb)

def self.validate_inheritance(caller_loc, parent, child, verb)
  this_file = caller_loc&.path
  decl_file = parent.instance_variable_get(:@sorbet_sealed_module_decl_file) if sealed_module?(parent)
  if !this_file
    raise "Could not use backtrace to determine file for #{verb} child #{child}"
  end
  if !decl_file
    raise "#{parent} does not seem to be a sealed module (#{verb} by #{child})"
  end
  if !this_file.start_with?(decl_file)
    whitelist = T::Configuration.sealed_violation_whitelist
    if !whitelist.nil? && whitelist.any? {|pattern| this_file =~ pattern}
      return
    end
    raise "#{parent} was declared sealed and can only be #{verb} in #{decl_file}, not #{this_file}"
  end
end