[ffigen] Fix category filtering bug - #3557
Open
liamappelbe wants to merge 58 commits into
Open
Conversation
PR HealthBreaking changes ✔️
This check can be disabled by tagging the PR with API leaks ✔️The following packages contain symbols visible in the public API, but not exported by the library. Export these symbols or remove them from your publicly visible API.
This check can be disabled by tagging the PR with Changelog Entry ✔️
Changes to files need to be accounted for in their respective changelogs. This check can be disabled by tagging the PR with |
liamappelbe
marked this pull request as ready for review
August 17, 2026 06:45
goderbauer
approved these changes
Aug 17, 2026
| // included by the config filters, since this method copying visit happens | ||
| // before the filtering visit. This is technically a bug, but it's unlikely | ||
| // to bother anyone, and the fix would be complicated. So we'll ignore it | ||
| // for now. |
Contributor
There was a problem hiding this comment.
😆 Great that we can fix this now!
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
ObjC categories map pretty neatly to Dart extension methods. The only issue we run into is methods returning
instancetype, which are special cased in ObjC to return an instance of the receiver type (ie, ifChildoverrides a method onBasethat returnsinstancetype, the method onBasereturnsBasewhile the method onChildreturnsChild), and can't be cleanly represented in Dart's inheritance semantics. So whenever we see a method returninginstancetype, we have to copy it to all the subtypes, and from a category to its parent interface.Before this PR there was a bug where that copying logic could bypass the usual filters. If a category was filtered out, we would still copy its
instancetypemethods to the parent interface. I had ignored it as an edge case, but I bumped into it again during theisIncludedPR, and it turns out to be fairly easy to fix now.Basically, we just track a method's
originCategory, then in apply_config_filterse if the origin category is filtered then we filter out the method.To avoid making breaking changes to package:objective_c, I then had to add explicit include rules for all the categories that added
instancetypemethods to an interface.Fixes #3546