fix(mix_generator): accept visible typedefs whose expansion names hidden types - #1058
Merged
Merged
Conversation
…den types `firstInvisibleTypeName` recursed into a type alias's expansion, so a typedef the annotated library can see was still rejected when the aliased declaration mentioned a type that library does not import. Generated code only ever writes the alias name, never its expansion, so the expansion's own types do not need to be visible. Returning null for a visible alias matches what `typeCode` already emits. Without this, a spec whose field type is a visible callback typedef over a hidden type fails generation with a spurious visibility error.
tilucasoli
added a commit
that referenced
this pull request
Sep 23, 2026
Co-authored-by: Claude Opus 5 (1M context) <noreply@anthropic.com>
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.
Related issue
Not linked to an open issue.
Description
Splits the one behavioural change to a published package out of #1056, where it currently rides along with a new experimental package.
firstInvisibleTypeNamedecides whether a type can be named from the library being generated into. For a type alias it recursed into the alias's expansion, so a typedef the annotated library can see was still rejected whenever the aliased declaration mentioned a type that library does not import.Generated code only ever writes the alias name, never its expansion, so the expansion's own types do not need to be visible. Returning
nullfor a visible alias is whattypeCodealready assumes — it emitsVisibleCallback, not the expanded function type.The user-visible symptom: a spec whose field type is a visible callback typedef over a hidden type fails generation with a spurious visibility error.
Changes
packages/mix_generator/lib/src/core/helpers/library_scope.dart— returnnullonce the alias itself is visible, instead of falling through to the expansion walk. Four lines, one of them a comment.packages/mix_generator/test/core/helpers/library_scope_test.dart— regression test.visible.dartgainstypedef VisibleCallback = void Function(HiddenType value);andhidden.darta function returning it, so the fixture reproduces the exact shape: a visible alias whose expansion names a hidden type.Verification
mix_generatortestsdart analyzedart format --set-exit-if-changedThe regression test was confirmed to be real, not just additive. Reverting only
library_scope.dartand re-running it fails as expected:Why separate
This is a bug fix in a package that ships to pub, and it is the prerequisite that lets #1056's specs generate at all. Reviewing and releasing it on its own means the fix is not gated on decisions about an experimental package's API surface, and it gets its own
mix_generatorchangelog entry rather than being folded into amix_markdownone.The patch is byte-identical to the one on
claude/package-setup-simplify-3kwvvm, so once this lands, rebasing #1056 drops the duplicate commit automatically.Review Checklist