Skip to content

@exportS3Method fails when package not imported or already in global namespace #1085

@NikNakk

Description

@NikNakk

With the move to R 4.0.0, I've come across an issue with one of my packages where I wanted to include S3 methods without introducing a dependency on the package that defines the generic. I'd previously done this by @exporting the function without an @importFrom, which meant that an export rather than S3method directive was written to NAMESPACE. However, now that R 4.0.0 doesn't look in the global namespace for S3 methods, this no longer worked.

As per duckmayr's answer to my StackOverflow question, the answer comes from using @exportS3Method package::generic_function without an @importFrom. However, this fails unless the relevant package has already been loaded into the global namespace before a call to roxygen2::roxygenise. Within RStudio, this means that the Document option in the Build pane fails. Is there any chance of modifying the check that leads to the error @exportS3Method and @exportS3Method generic must be used with an S3 method' and therefore fails to include the relevant lines in NAMESPACE?

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions