Skip to content

S7 methods defined for S7 classes cannot be traced #584

Description

@kevinushey

For example:

library(S7)

type <- new_generic("type", "x")
data <- new_class("data")
method(type, data) <- function(x) {
  typeof(x)
}

object <- data()
type(object)

We'd like to be able to set a breakpoint inside the body of the defined function using trace(). I think we'd do this with something like:

trace(data, where = type@methods)

but this fails with

> trace("data", where = type@methods)
c("Constructing traceable class \"S7_methodWithTrace\"", "Constructing traceable class \"functionWithTrace\"", "Constructing traceable class \"S7_objectWithTrace\"")
c("Environment of class \"S7_method\" is locked; using global environment for new class", "Environment of class \"function\" is locked; using global environment for new class", "Environment of class \"S7_object\" is locked; using global environment for new class")
Error in !is.null(prototype) && is.na(match(name, .BasicClasses)) :
  'length = 3' in coercion to 'logical(1)'

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    base Rbugan unexpected problem or unintended behavior

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions