Skip to content

Commit

Permalink
Don't embed external generics
Browse files Browse the repository at this point in the history
Fixes #364
  • Loading branch information
hadley committed Nov 27, 2023
1 parent 3edbc1c commit 21bcd2d
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 2 deletions.
5 changes: 5 additions & 0 deletions NEWS.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,10 @@
# S7 (development version)

* `method<-` now returns an external generic when inside a package and defining
a method for a generic not found inside the package. This ensures that your
package end up with a copy of a generic from another package inside of it
(#364).

* S7 provides a new automatic backward compatibility mechanism to provide
a version of `@` that works in R before version 4.3 (#326).

Expand Down
1 change: 0 additions & 1 deletion R/method-register.R
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,6 @@
#' bizarro(head(mtcars))
`method<-` <- function(generic, signature, value) {
register_method(generic, signature, value, env = parent.frame())
invisible(generic)
}

register_method <- function(generic,
Expand Down
2 changes: 1 addition & 1 deletion tests/testthat/test-method-register.R
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ describe("method registration", {
expect_equal(sum(foo2()), "foo")

# and doesn't modify generic
expect_equal(sum, base::sum)
expect_equal(sum, new_external_generic("base", "sum", "__S3__"))
})

it("can register S7 method for S3 Ops generic", {
Expand Down

0 comments on commit 21bcd2d

Please sign in to comment.