Bug 16973 - callNextMethod() not finding the correct "next method"
Summary: callNextMethod() not finding the correct "next method"
Status: CLOSED FIXED
Alias: None
Product: R
Classification: Unclassified
Component: S4methods (show other bugs)
Version: R-devel (trunk)
Hardware: All All
: P5 normal
Assignee: R-core
URL:
Depends on:
Blocks:
 
Reported: 2016-06-28 19:19 UTC by Hervé Pagès
Modified: 2016-06-29 12:53 UTC (History)
1 user (show)

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Hervé Pagès 2016-06-28 19:19:14 UTC
Here is how to reproduce:

  setClass("A", slots=c(stuff="ANY"))
  setClass("B", contains="A")
  setClass("C", contains="B")
  a <- new("A")
  b <- new("B")
  c <- new("C")

  setGeneric("foo", function(x) standardGeneric("foo"))
  setMethod("foo", "A", function(x) "A")
  setMethod("foo", "C", function(x) c(callNextMethod(x), "C"))

  foo(a) # A
  foo(b) # A
  foo(c) # A C

  setMethod("foo", "B", function(x) c(callNextMethod(x), "B"))

  foo(a) # A
  foo(b) # A B
  foo(c) # A C <--- wrong!

Looks like some caching is getting in the way.

Problem goes away when defining the foo#C method again:

  setMethod("foo", "C", function(x) c(callNextMethod(x), "C"))

  foo(a) # A
  foo(b) # A B
  foo(c) # A B C <--- ok

Thanks,
H.
Comment 1 Michael Lawrence 2016-06-29 12:53:26 UTC
Thanks, I've fixed this. Just need to test and commit.