[Bioc-devel] Versioned (Biobase) "initialize" method

Stravs, Michael Michael.Stravs at eawag.ch
Thu Jan 7 16:41:06 CET 2016


Hi,

The "initialize" method of the Versioned class in Biobase is defined in a way that breaks when inheriting classes want to define a copy constructor.

Code to reproduce:

library(Biobase)
setClass("A",
         representation = representation(var1="integer"),
         prototype=prototype(var1=integer(),
                             new("Versioned", versions=c(A = "0.1.0"))),
         contains="Versioned")

ia <- new("A")
ia2 <- new("A", ia)
# "ia" is mapped to the argument "versions" of the Versioned "initialize" method!

Full gist snippet including bugfix:
https://gist.github.com/meowcat/c51a4260fb710e2fa51a

For explanation, see:
http://stackoverflow.com/questions/16247583/inheritance-in-r/16248773#16248773

The Versioned class in Biobase has the following "initialize" method:

function (.Object, ...)
{
    .local <- function (.Object, versions = list(), ...)
    {
        .Object <- callNextMethod(.Object, ...)
        classVersion(.Object)[names(versions)] <- versions
        .Object
    }
    .local(.Object, ...)
}

Can you change it as follows:


function (.Object, ...)

{

    .local <- function (.Object, ..., versions = list())

    {

        .Object <- callNextMethod(.Object, ...)

        classVersion(.Object)[names(versions)] <- versions

        .Object

    }

    .local(.Object, ...)

}

This will fix the problem.


Michael Stravs
Eawag
Umweltchemie
BU E 23
Überlandstrasse 133
8600 Dübendorf
+41 58 765 6742


	[[alternative HTML version deleted]]



More information about the Bioc-devel mailing list