testInheritedMethods(f, signatures, test = TRUE, virtual = FALSE, groupMethods = TRUE, where = .GlobalEnv)
testInheritedMethods
. See the Details
for how this is done. This argument might be supplied after a call
with test = FALSE
, to test selection in batches.
FALSE
, returns just the list of relevant signatures for
subclasses, without calling selectMethod
for each signature.
If there are a very large number of signatures, you may want to collect the full list and then test them in batches.
"methodSelectionReport"
. The details of
this class are currently subject to change. It has slots
"target"
, "selected"
, "candidates"
, and
"note"
, all referring to the ambiguous cases (and so of length
0 if there were none). These slots are intended to be examined by the
programmer to detect and preferably fix ambiguous method selections.
The object contains in addition slots "generic"
, the name of
the generic function, and
"allSelections"
, giving the vector of labels for all
the signatures tested.
findMethodSignatures
.
From these all the known non-virtual subclasses are found for each
class that appears in the signature of some method.
These subclasses are split into groups according to which class they
inherit from, and only one subclass from each group is retained (for
each argument in the generic signature).
So if a method was defined with class "vector"
for some
argument, one actual vector class is chosen arbitrarily.
The case of "ANY"
is dealt with specially, since all classes
extend it. A dummy, nonvirtual class, ".Other"
, is used to
correspond to all classes that have no superclasses among those being
tested. All combinations of retained subclasses for the
arguments in the generic signature are then computed.
Each row of the resulting matrix is a signature to be tested by a call
to selectMethod
.
To collect information on ambiguous selections,
testInheritedMethods
establishes a calling handler for the
special signal "ambiguousMethodSelection"
, by setting the
corresponding option.
Chambers, John M. (2009) Class Inheritance in R https://statweb.stanford.edu/~jmc4/classInheritance.pdf.
## if no other attached packages have methods for `+` or its group
## generic functions, this returns a 16 by 2 matrix of selection
## patterns (in R 2.9.0)
testInheritedMethods("+")
Run the code above in your browser using DataLab