Skip to content

Commit

Permalink
.requirePackage() should run *with* methods dispatch of primitive gen…
Browse files Browse the repository at this point in the history
…erics, notably `$`

git-svn-id: https://svn.r-project.org/R/trunk@87202 00db46b3-68df-0310-9c12-caf00c1e9a41
  • Loading branch information
maechler committed Sep 30, 2024
1 parent f844acd commit 3ef5beb
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 2 deletions.
5 changes: 5 additions & 0 deletions doc/NEWS.Rd
Original file line number Diff line number Diff line change
Expand Up @@ -299,6 +299,11 @@
\item Informational messages of e.g., \code{print(1:1e4, max=1000)},
now correctly mention \code{max} in addition to
\code{getOption("max.print")}.
\item \pkg{methods}' internal \code{.requirePackage()} now re-enables
primitive method dispatch when needed; thanks to \I{Ivan Krylov}
for demystifying CRAN package check failures on the R*devel mailing
lists.
}
}
}
Expand Down
4 changes: 4 additions & 0 deletions src/library/methods/R/RClassUtils.R
Original file line number Diff line number Diff line change
Expand Up @@ -1833,6 +1833,10 @@ substituteFunctionArgs <-
if(!is.null(pkgN <- get0(".packageName", topEnv, inherits=TRUE)) &&
.identC(package, pkgN))
return(topEnv) # kludge for source'ing package code
## If called from .findInheritedMethods which disables S4 primitive dispatch,
## allow it here, as namespace loading hooks may need it:
if(!.allowPrimitiveMethods(TRUE))
on.exit(.allowPrimitiveMethods(FALSE))
if(nzchar(package) && require(package, character.only = TRUE)) {}
else {
if(mustFind)
Expand Down
4 changes: 2 additions & 2 deletions src/library/methods/R/methodsTable.R
Original file line number Diff line number Diff line change
Expand Up @@ -454,8 +454,8 @@
where = environment(fdef))
{
## to avoid infinite recursion, and somewhat for speed, turn off S4 methods for primitives
primMethods <- .allowPrimitiveMethods(FALSE)
on.exit(.allowPrimitiveMethods(primMethods))
if(.allowPrimitiveMethods(FALSE)) # if it was true, revert on exit
on.exit(.allowPrimitiveMethods(TRUE))
## classes is a list of the class(x) for each arg in generic
## signature, with "missing" for missing args
if(!is.environment(table)) {
Expand Down

0 comments on commit 3ef5beb

Please sign in to comment.