Skip to content

load_all() error when using setOldClass() with inheritance #848

@famuvie

Description

@famuvie

I have prepared a MRE for this issue, as a dummy package that can be installed and tested quickly.

In summary, I need to register some S3 classes with inheritance structure using setOldClass().

#' @importFrom methods setOldClass
methods::setOldClass(c('derived_class', 'my_class'))

When I load_all() for the first time, everything goes fine. But for successive times, it fails as follows:

Loading testpkg
Error in methods::setOldClass(c("derived_class", "my_class")) (from testmethod.R#3) : 
  inconsistent old-style class information for “derived_class”; the class is defined but does not extend “my_class” and is not valid as the data part

Variations:

  • The error does not occur if the class to be registered is single (i.e. setOldClass('my_class')).
  • Incomprehensibly, it does not occur either if the derived class name is 'splines' (!?!?)
  • Finally, the error still occurs if I register 'my_class' beforehand in a separate sentence.
> session_info()
Session info ---------------------------------------------------------------------------------------------------------------
 setting  value                       
 version  R version 3.2.0 (2015-04-16)
 system   x86_64, linux-gnu           
 ui       RStudio (0.99.441)          
 language (EN)                        
 collate  en_US.UTF-8                 
 tz       <NA>                        

Packages -------------------------------------------------------------------------------------------------------------------
 package    * version date       source        
 devtools     1.7.0   2015-01-17 CRAN (R 3.1.2)
 digest     * 0.6.8   2014-12-31 CRAN (R 3.2.0)
 memoise    * 0.2.1   2014-04-22 CRAN (R 3.1.2)
 Rcpp       * 0.11.5  2015-03-06 CRAN (R 3.1.3)
 roxygen2   * 4.1.1   2015-04-15 CRAN (R 3.2.0)
 rstudioapi * 0.3.1   2015-04-07 CRAN (R 3.2.0)
 stringr    * 0.6.2   2012-12-06 CRAN (R 3.1.2)

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions