I am trying to add a spatial method to merge which needs to be S4 (since it dispatches on the types of two different objects).
I have tried using an ear
The mis-dispatch occurs because the body of the generic is not "standard" (I think the rationale is that, since you've done something other than invoke standardGeneric("merge"), you know what you're doing so no automatic default; maybe I'm making this up and it's really a bug). Solutions are to set a standard generic allowing for the default dispatch
setGeneric("merge")
or to explicitly provide standard dispatch
setGeneric("merge", function(x, y, ...) standardGeneric("merge"))
or explicitly specify a default method
setGeneric("merge", function(x, y, ...){
cat("generic dispatch\n")
standardGeneric("merge")
}, useAsDefault=base::merge)