@@ -2462,7 +2462,7 @@ function(package, dir, lib.loc = NULL)
24622462
24632463 code_env <- asNamespace(package )
24642464 if (! is_base ) {
2465- S3_methods_info <- getNamespaceInfo(code_env , " S3methods" )
2465+ S3_methods_info <- . getNamespaceInfo(code_env , " S3methods" )
24662466 exports <- getNamespaceExports(code_env )
24672467 }
24682468 }
@@ -2897,26 +2897,28 @@ function(package, dir, lib.loc = NULL)
28972897 if (! is.null(ns_S3_methods_db )) {
28982898 ns_S3_generics <- as.character(ns_S3_methods_db [, 1L ])
28992899 ns_S3_methods <- ns_S3_methods_db [, 3L ]
2900- if (! is.character(ns_S3_methods )) {
2901- # # As of 2018-07, direct calls to registerS3method()
2902- # # could have registered a function object (not name).
2903- ind <- vapply(ns_S3_methods , is.character , NA )
2904- ns_S3_methods [! ind ] <- " "
2900+ if (has_S3_fun_obj <- ! is.character(ns_S3_methods )) {
2901+ # # registerS3method() may have registered a function object (not name), e.g. in S7
2902+ nonCh <- ! vapply(ns_S3_methods , is.character , NA )
2903+ # # keep these to check for <last argument name> == 'value', below:
2904+ S3_fun_obj <- ns_S3_methods [nonCh ]
2905+ ns_S3_methods [nonCh ] <- " "
29052906 ns_S3_methods <- as.character(ns_S3_methods )
29062907 }
29072908 # # S3 replacement methods from namespace registration?
29082909 replace_funs <- ns_S3_methods [endsWith(ns_S3_generics , " <-" )]
29092910 # # Now remove the functions registered as S3 methods.
29102911 objects_in_code <- setdiff(objects_in_code , ns_S3_methods )
2911- }
2912+ } else
2913+ has_S3_fun_obj <- FALSE
29122914
29132915 replace_funs <-
2914- c(replace_funs , grep(" <-" , objects_in_code , value = TRUE ))
2916+ c(replace_funs , grep(" <-$ " , objects_in_code , value = TRUE ))
29152917 # # Drop %xxx% binops.
29162918 # # Spotted by Hugh Parsonage <[email protected] >. 29172919 replace_funs <-
29182920 replace_funs [! (startsWith(replace_funs , " %" ) &
2919- endsWith(replace_funs , " %" ))]
2921+ endsWith (replace_funs , " %" ))]
29202922
29212923 .check_last_formal_arg <- function (f ) {
29222924 arg_names <- names(formals(f ))
@@ -2929,7 +2931,7 @@ function(package, dir, lib.loc = NULL)
29292931 # # Find the replacement functions (which have formal arguments) with
29302932 # # last arg not named 'value'.
29312933 bad_replace_funs <- if (length(replace_funs )) {
2932- Filter(function (f ) {
2934+ Filter(function (f ) nzchar( f ) && {
29332935 # # Always get the functions from code_env ...
29342936 # # Should maybe get S3 methods from the registry ...
29352937 f <- get(f , envir = code_env ) # get is expensive
@@ -2938,6 +2940,12 @@ function(package, dir, lib.loc = NULL)
29382940 replace_funs )
29392941 } else character ()
29402942
2943+ if (has_S3_fun_obj ) {
2944+ if (! all(ok_lastArg <- vapply(S3_fun_obj , .check_last_formal_arg , NA )))
2945+ bad_replace_funs <-
2946+ c(bad_replace_funs , paste0(ns_S3_generics [nonCh ], " .:." , # not "." on purpose
2947+ ns_S3_methods_db [nonCh , 2L ]))
2948+ }
29412949 if (.isMethodsDispatchOn()) {
29422950 S4_generics <- .get_S4_generics(code_env )
29432951 # # Assume that the ones with names ending in '<-' are always
@@ -4035,7 +4043,7 @@ function(x)
40354043 if (length(bad <- x [[" bad_authors_at_R_field_has_persons_with_dup_ROR_identifiers" ]])) {
40364044 c(gettext(" Authors@R field gives persons with duplicated ROR identifiers:" ),
40374045 paste0(" " , bad ))
4038- }
4046+ }
40394047 )
40404048}
40414049
@@ -5240,7 +5248,7 @@ function(dir, doDelete = FALSE)
52405248 all_files <- mydir(demo_dir )
52415249 demo_files <- list_files_with_type(demo_dir , " demo" ,
52425250 full.names = FALSE )
5243- save_files <- paste0(sub(" r$" , " R" , demo_files ), " out.save" )
5251+ save_files <- paste0(sub(" r$" , " R" , demo_files ), " out.save" )
52445252 wrong <- setdiff(all_files ,
52455253 c(" 00Index" , demo_files , save_files ))
52465254 if (length(wrong )) {
@@ -8243,7 +8251,7 @@ function(dir, localOnly = FALSE, pkgSize = NA)
82438251 if (config_val_to_logical(Sys.getenv(" _R_CHECK_CRAN_INCOMING_DROP_SUBMISSION_ONLY_" ,
82448252 " FALSE" ))) {
82458253 out [c(" descr_bad_initial" ,
8246- " descr_bad_start" ,
8254+ " descr_bad_start" ,
82478255 " title_includes_name" ,
82488256 " title_case" ,
82498257 " extensions" ,
@@ -9267,6 +9275,7 @@ function(package, dir, lib.loc = NULL, chkInternal = NULL)
92679275 out <- list ()
92689276 class(out ) <- " checkRdContents" # was "check_Rd_contents"
92699277
9278+ # ## FIXME? much of the following copy-pasted from checkDocFiles() above
92709279 # # Argument handling.
92719280 if (! missing(package )) {
92729281 if (length(package ) != 1L )
0 commit comments