diff --git a/R/utils.R b/R/utils.R index 7e2a54a..3bacfad 100644 --- a/R/utils.R +++ b/R/utils.R @@ -38,7 +38,19 @@ unique_obj <- function(name, pkgs) { objs <- lapply(pkgs, getExportedValue, name) names(objs) <- pkgs - pkgs[!duplicated(objs)] + env_names <- map_chr(objs, function(obj) { + tryCatch( + getNamespaceName(environment(obj)), + error = function(e) "" + ) + }) + + env_names <- unique(env_names[env_names != ""]) + + canonical_objs <- c(objs[env_names], objs) + canonical_pkgs <- c(env_names, pkgs) + + canonical_pkgs[!duplicated(canonical_objs)] } style_object <- function(pkg, name, winner = FALSE) {