R/is_s3_generic.R

# Do not edit this file. It is generated from transpiler/R/is_s3_generic.R
# by 'make transpiler-sync'. Edit the 'transpiler' package instead.

#' Check whether function is an S3 generic function
#'
#' @param fcn A function.
#'
#' @return
#' Return TRUE if `fcn` is an S3 generic function, otherwise FALSE.
#'
#' @noRd
is_s3_generic <- local({
  has_UseMethod <- function(expr) {
    if (is.call(expr)) {
      first <- expr[[1]]
      if (is.symbol(first) && identical(first, as.symbol("UseMethod"))) {
        return(TRUE)
      }
      for (ii in seq_along(expr)) {
        if (has_UseMethod(expr[[ii]])) return(TRUE)
      }
    }
    FALSE
  } ## has_UseMethod()

  function(fcn) {
    if (is.primitive(fcn)) return(FALSE)
    bd <- body(fcn)
    if (is.null(bd)) return(FALSE)
    has_UseMethod(bd)
  }
}) ## is_s3_generic()

Try the progressify package in your browser

Any scripts or data that you put into this service are public.

progressify documentation built on Nov. 23, 2026, 9:08 a.m.