-
Notifications
You must be signed in to change notification settings - Fork 32
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
R7 dispatch and S4 inheritance #252
Comments
Probably a bug. |
Having a closer look at https://github.com/RConsortium/OOP-WG/blob/879da2af57e24243f509e61778a480c9c5dc3ef0/R/S4.R#L81-L83 as it is a "Virtual Class". |
Hmm, I've not studied your code nor the details of However, there are many methods defined to dispatch for "sparseMatrix" so maybe there is a bug in |
Updated reprex: library(methods)
library(S7)
setClass("general")
setClass("specific", contains = "general")
fun <- new_generic("fun", "x")
method(fun, getClass("general")) <- function(x) "general"
fun(new("specific"))
#> Error: Can't find method for generic `fun()` with dispatch classes:
#> - x: S4/specific Created on 2023-04-14 with reprex v2.0.2 |
Or to give a bit more info about what S7 is actually trying: library(methods)
library(S7)
setClass("general")
setClass("specific", contains = "general")
fun <- new_generic("fun", "x")
method(fun, getClass("general")) <- function(x) "general"
method_explain(fun, object = new("specific"))
#> fun([S4/specific])
#> fun([ANY]) Created on 2023-04-15 with reprex v2.0.2 |
It looks like |
Is it not possible for an R7 generic to understand S4 inheritance? Is this an intentional limitation or a bug? (Or am I simply confused for expecting this to work?)
(I'm at
RConsortium/OOP-WG@879da2a
)The text was updated successfully, but these errors were encountered: