RConsortium / S7

S7: a new OO system for R
https://rconsortium.github.io/S7
Other
407 stars 37 forks source link

"Overwriting method ..." noise from `devtools::load_all()` #474

Open t-kalinowski opened 1 month ago

t-kalinowski commented 1 month ago

This might be better as a pkgload specific issue, but I'm raising it here first. In a package that exports methods, load_all() gets annoyingly noisy.

> devtools::load_all(".")
ℹ Loading r2f
Overwriting method convert(<double>, <integer>)
Overwriting method convert(<logical>, <integer>)
Overwriting method convert(<name>, <character>)
Overwriting method convert(<logical>, <character>)
Overwriting method convert(<double>, <integer>)
Overwriting method convert(<logical>, <integer>)
Overwriting method convert(<name>, <character>)
Overwriting method convert(<logical>, <character>)

Note that each method is overwritten twice: once when sourcing the package code, and then again in .onLoad/S7::methods_register().

hadley commented 1 month ago

I thought I noticed that too, but it turned out that I was accidentally duplicating method definitions.

t-kalinowski commented 1 month ago

I don't think I'm defining the method twice. A minimal package with just this is enough to show the warning twice:

#' @import S7
NULL

method(convert, list(class_double, class_integer)) <- 
  function(from, to, ...) as.integer(from)

.onLoad <- function(...) {
  S7::methods_register()
}
> devtools::load_all(".")
ℹ Loading r2f
Overwriting method convert(<double>, <integer>)
Overwriting method convert(<double>, <integer>)
hadley commented 1 month ago

Ooh, hmmmm, maybe it only occurs in the dev version?

lawremi commented 4 weeks ago

I've noticed this too when redefining methods at runtime during debugging, like with ESS's developer mode. It's a bit distracting.