Skip to content

Commit

Permalink
clearing out unused register fns
Browse files Browse the repository at this point in the history
  • Loading branch information
dgkf committed Jan 22, 2023
1 parent 8ae2698 commit 4c0b646
Showing 1 changed file with 0 additions and 52 deletions.
52 changes: 0 additions & 52 deletions R/register-s3.R
Original file line number Diff line number Diff line change
Expand Up @@ -133,55 +133,3 @@ s3_register <- function(generic, class, method = NULL) {

invisible()
}

.rlang_s3_register_compat <- function(fn, try_rlang = TRUE) {
# Compats that behave the same independently of rlang's presence
out <- switch(
fn,
is_installed = return(function(pkg) requireNamespace(pkg, quietly = TRUE))
)

# Only use rlang if it is fully loaded (#1482)
if (try_rlang &&
requireNamespace("rlang", quietly = TRUE) &&
environmentIsLocked(asNamespace("rlang"))) {
switch(
fn,
is_interactive = return(rlang::is_interactive)
)

# Make sure rlang knows about "x" and "i" bullets
if (utils::packageVersion("rlang") >= "0.4.2") {
switch(
fn,
abort = return(rlang::abort),
warn = return((rlang::warn)),
inform = return(rlang::inform)
)
}
}

# Fall back to base compats

is_interactive_compat <- function() {
opt <- getOption("rlang_interactive")
if (!is.null(opt)) {
opt
} else {
interactive()
}
}

format_msg <- function(x) paste(x, collapse = "\n")
switch(
fn,
is_interactive = return(is_interactive_compat),
abort = return(function(msg) stop(format_msg(msg), call. = FALSE)),
warn = return(function(msg) warning(format_msg(msg), call. = FALSE)),
inform = return(function(msg) message(format_msg(msg)))
)

stop(sprintf("Internal error in rlang shims: Unknown function `%s()`.", fn))
}

# nocov end

0 comments on commit 4c0b646

Please sign in to comment.