Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Bugzilla#18786] make showMethods() display a syntactic name #179

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions src/library/methods/R/show.R
Original file line number Diff line number Diff line change
Expand Up @@ -109,6 +109,7 @@ show <- function(object) showDefault(object)
nam %in% names(.getNamespaceInfo(ns, "exports"))
showGen <- if(exported) nam # was dQuote(nam, NULL)
else paste(pkg, nam, sep=":::")
if (make.names(showGen) != showGen) showGen <- paste0("`", showGen, "`")
cat("Methods may be defined for arguments: ",
paste0(object@signature, collapse=", "), "\n",
"Use showMethods(", showGen,
Expand Down
3 changes: 3 additions & 0 deletions tests/reg-S4.R
Original file line number Diff line number Diff line change
Expand Up @@ -888,3 +888,6 @@ setClass("foo")
sealClass("foo") # failed in R < 4.5.0
stopifnot(isSealedClass("foo"))
stopifnot(removeClass("foo"))

# show(<non-syntactic name>) should recommend backticks for showMethods()
stopifnot(any(grepl("showMethods(`body<-`)", capture.output(show(`body<-`)), fixed=TRUE)))
3 changes: 3 additions & 0 deletions tests/reg-S4.Rout.save
Original file line number Diff line number Diff line change
Expand Up @@ -1187,3 +1187,6 @@ class(from) <- "foo"
> stopifnot(isSealedClass("foo"))
> stopifnot(removeClass("foo"))
>
> # show(<non-syntactic name>) should recommend backticks for showMethods()
> stopifnot(any(grepl("showMethods(`body<-`)", capture.output(show(`body<-`)), fixed=TRUE)))
>
Loading