11# File src/library/methods/R/Methods.R
22# Part of the R package, https://www.R-project.org
33#
4- # Copyright (C) 1995-2023 The R Core Team
4+ # Copyright (C) 1995-2024 The R Core Team
55#
66# This program is free software; you can redistribute it and/or modify
77# it under the terms of the GNU General Public License as published by
1717# https://www.R-project.org/Licenses/
1818
1919# # copy here to avoid importing from stats and hence loading stats
20- # # namespace when methods if loaded
20+ # # namespace when methods is loaded
2121setNames <- stats :: setNames
2222
2323
@@ -351,7 +351,8 @@ getMethods <-
351351 function (f , where = topenv(parent.frame()), table = FALSE )
352352{
353353 if (! table )
354- .MlistDefunct(" getMethods" , " findMethods" )
354+ .MlistDefunct(" getMethods" , " findMethods" )
355+ else .Deprecated(" getMethodsForDispatch(f, TRUE)" )
355356 nowhere <- missing(where )
356357 fdef <- getGeneric(f , where = where )
357358 f <- fdef @ generic
@@ -366,41 +367,6 @@ getMethodsForDispatch <- function(fdef, inherited = FALSE)
366367 .getMethodsTable(fdef , environment(fdef ), inherited = inherited )
367368}
368369
369- # # Some functions used in MethodsListSelect, that must be safe against recursive
370- # # method selection.
371-
372- .setIfBase <- function (f , fdef , mlist ) {
373- if (is.null(f ))
374- FALSE
375- else {
376- found <- base :: exists(f , " package:base" )
377- if (found ) {
378- # # force (default) computation of mlist in MethodsListSelect
379- base :: assign(" .Methods" , envir = base :: environment(fdef ),
380- base :: get(f , " package:base" ))
381- }
382- found
383- }
384- }
385-
386- # # Must NOT use the standard version to prevent recursion {still true ?}
387- .getMethodsForDispatch <- function (fdef ) {
388- ev <- base :: environment(fdef )
389- if (base :: exists(" .Methods" , envir = ev ))
390- base :: get(" .Methods" , envir = ev )
391- # # else NULL
392- }
393-
394- .setMethodsForDispatch <- function (f , fdef , mlist ) {
395- ev <- environment(fdef )
396- if (! is(fdef , " genericFunction" ) ||
397- ! exists(" .Methods" , envir = ev , inherits = FALSE ))
398- stop(sprintf(" internal error: did not get a valid generic function object for function %s" ,
399- sQuote(f )),
400- domain = NA )
401- assign(" .Methods" , envir = ev , mlist )
402- }
403-
404370cacheMethod <-
405371 # # cache the given definition in the method metadata for f
406372 # # Support function: DON'T USE DIRECTLY (does no checking)
@@ -417,6 +383,7 @@ cacheMethod <-
417383 .getMethodsTable(fdef , ev , inherited = TRUE ))
418384 }
419385
386+ # # for .removeSubClass() and .removeSuperClass():
420387.removeCachedMethod <- function (f , sig , fdef = getGeneric(f ))
421388 cacheMethod(f , sig , NULL , names(sig ), fdef )
422389
0 commit comments