Skip to content

Commit c335b7a

Browse files
Special-case S7 class names for S7::class_any and S7::class_missing (#1873)
1 parent 39e12bd commit c335b7a

2 files changed

Lines changed: 11 additions & 0 deletions

File tree

R/object-from-call.R

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -289,6 +289,10 @@ s7_class_name <- function(cls, block) {
289289
unlist(lapply(cls$classes, s7_class_name, block = block))
290290
} else if (inherits(cls, "S7_S3_class")) {
291291
cls$class
292+
} else if (inherits(cls, "S7_any")) {
293+
"any"
294+
} else if (inherits(cls, "S7_missing")) {
295+
"missing"
292296
} else {
293297
warn_roxy_block(block, "Unknown S7 class type")
294298
paste0(deparse(cls), collapse = " ")

tests/testthat/test-object-from-call.R

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -327,6 +327,13 @@ test_that("S7 method on S3 generic includes package prefix in class name", {
327327
expect_equal(obj$value$generic, "print")
328328
})
329329

330+
test_that("S7 method with special classes any and missing", {
331+
skip_unless_r(">= 4.3.0")
332+
block <- roxy_block(tags = list(), file = "test.R", line = 1, call = quote(x))
333+
expect_equal(s7_class_name(S7::class_any, block), "any")
334+
expect_equal(s7_class_name(S7::class_missing, block), "missing")
335+
})
336+
330337
test_that("S7 method with unknown class type warns", {
331338
skip_unless_r(">= 4.3.0")
332339
block <- roxy_block(tags = list(), file = "test.R", line = 1, call = quote(x))

0 commit comments

Comments
 (0)