Skip to content

Implement S7_on_unload()#698

Merged
hadley merged 21 commits into
mainfrom
auto-unregister
Jun 17, 2026
Merged

Implement S7_on_unload()#698
hadley merged 21 commits into
mainfrom
auto-unregister

Conversation

@hadley

@hadley hadley commented Jun 12, 2026

Copy link
Copy Markdown
Member

Perform the opposite role as S7_on_load(). Fixes #316.

NB: for a full fix, this requires pkgload 1.5.3 which now actually calls the unload hooks.

@hadley hadley requested a review from t-kalinowski June 16, 2026 13:37
@hadley

hadley commented Jun 16, 2026

Copy link
Copy Markdown
Member Author

@t-kalinowski this doesn't need a full review, but I've gotten stuck in the weeds of refactoring and I think it would be useful to get some high level feedback before I go too far.

@t-kalinowski t-kalinowski left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It looks good to me so far, I like this approach.

@hadley hadley requested a review from t-kalinowski June 17, 2026 17:08
@hadley

hadley commented Jun 17, 2026

Copy link
Copy Markdown
Member Author

I'll do another round of refactoring as part of #660, but the tests are much easier to understand now.

@t-kalinowski t-kalinowski left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I reviewed this and think the PR is good to go. I pushed a few additions while looking through unload cleanup. The main change is that S7_on_unload() now only unregisters an external S7 method if the unloading package still owns the active method.

There are a few supporting changes for that: package-registered S7 methods now carry owner metadata, unload skips external generics when the upstream package is unavailable or too old for the declared minimum version, and hook cleanup still removes stale hooks after an external method has been deleted. I added regression tests for those cases and updated NEWS/docs to match.

Please take a close look at the additions. If you think some of this is more edge-case handling than we want in this PR, I’m fine with dropping it.

https://diffshub.com/RConsortium/S7/compare/09dfb7aabce6b4975d0b3238282b9aa3bb1bf170...d6567f1632d0e89774b41731ee501ddd0dad6313

@hadley

hadley commented Jun 17, 2026

Copy link
Copy Markdown
Member Author

Yeah, I'm not sure I would have gone that far, but it makes sense, and no need to undo it 😄

@hadley hadley merged commit def9a8f into main Jun 17, 2026
13 checks passed
@hadley hadley deleted the auto-unregister branch June 17, 2026 22:34
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Unregister methods on unload

2 participants