Join GitHub today
GitHub is home to over 50 million developers working together to host and review code, manage projects, and build software together.
Sign upobject 'super' not found (when using active members and clones) #119
Comments
|
This sounds like a duplicate of #108. |
|
It turns out this is actually different from #108. The problem doesn't have to do with active bindings per se, but it happens to come up in classes with active bindings, because of the way that Here's a minimal example: library(R6)
A <- R6Class("A",
public = list(
methodA = function() "A"
),
active = list(
x = function() "x"
)
)
B <- R6Class("B",
inherit = A,
public = list(
methodB = function() {
super$methodA()
}
)
)
C <- R6Class("C",
inherit = B,
public = list(
methodC = function() {
super$methodB()
}
)
)
C1 <- C$new()
C2 <- C1$clone()
C2$methodC()
# Error in super$methodB() : object 'super' not foundThe problem is in this line of code: https://github.com/wch/R6/blob/41f942af/R/clone.R#L58 It makes the assumption that all of the functions in the lapply(C1$.__enclos_env__$super, environment)
# $x
# <environment: 0x10da95228>
#
# $clone
# <environment: 0x10da8fce8>
#
# $methodB
# <environment: 0x10da8fce8>
#
# $A_method
# <environment: 0x10da95228> |
|
Thank you for the quick fix. 073b6f0 solved all my issues in the minimal example as well as my actual project. |
I currently have an issue with cloned objects. My setup looks roughtly like this
It seems like
Bcan't access the methods of its parentAvia a call tosuper(in line # 18). The error does not occur, if the active membernsis ommitedAny help would be appreciated!