Skip to content
Prev 46577 / 63421 Next

"False" warning on "replacing previous import" when re-exporting identical object

On Fri, Aug 30, 2013 at 11:51 AM, Henrik Bengtsson <hb at biostat.ucsf.edu> wrote:
Ok, if import(PkgA, PkgB) and PkgB reexports a *different* foo() than
PkgA::foo(), say PkgZ::foo so identical(PkgB::foo, PkgA::foo) is
FALSE, then there is indeed a conflict.  An alternative patch:
Index: namespace.R
===================================================================
--- namespace.R (revision 63776)
+++ namespace.R (working copy)
@@ -871,6 +871,11 @@
     }
     for (n in impnames)
        if (exists(n, envir = impenv, inherits = FALSE)) {
+            ## warn only if imported variable is non-identical to
+            ## the one already imported
+            getImp <- get(n, envir = impenv)
+            obj <- get(n, envir = ns)
+            if (identical(obj, getImp)) next
            if (.isMethodsDispatchOn() && methods:::isGeneric(n, ns)) {
                ## warn only if generic overwrites a function which
                ## it was not derived from

/Henrik