Skip to content

[swift2objc] Support Swift extension declarations#3236

Open
Hassnaa9 wants to merge 3 commits intodart-lang:mainfrom
Hassnaa9:feature/support-swift-extensions
Open

[swift2objc] Support Swift extension declarations#3236
Hassnaa9 wants to merge 3 commits intodart-lang:mainfrom
Hassnaa9:feature/support-swift-extensions

Conversation

@Hassnaa9
Copy link
Contributor

Support Swift extension declarations by routing members with a swiftExtension
field into ExtensionDeclaration nodes during parsing, then transforming and
generating them as @objc extension { ... } blocks.

Fixes: #1815

@Hassnaa9 Hassnaa9 force-pushed the feature/support-swift-extensions branch from 3dd7829 to 9e69a3d Compare March 14, 2026 06:29
...generateInitializer(declaration.wrapperInitializer, isPublic: false),
for (final init in declaration.initializers)
..._generateInitializer(init, isPublic: true),
...generateInitializer(init, isPublic: true),
Copy link
Contributor Author

Choose a reason for hiding this comment

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

I made _generateClassMethod, _generateClassProperty, and _generateInitializer public, so that extension_generator.dart could reuse them directly instead of duplicating the same logic.

@github-actions
Copy link

PR Health

Breaking changes ✔️
Package Change Current Version New Version Needed Version Looking good?

This check can be disabled by tagging the PR with skip-breaking-check.

Changelog Entry ✔️
Package Changed Files

Changes to files need to be accounted for in their respective changelogs.

This check can be disabled by tagging the PR with skip-changelog-check.

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.

Package Leaked API symbol Leaking sources

This check can be disabled by tagging the PR with skip-leaking-check.

@Hassnaa9
Copy link
Contributor Author

@liamappelbe I tried to fix the "designated initializer cannot be declared in an extension" failure by adding convenience to initializers generated inside @objc extension blocks. This error didn't appear locally because I'm on Linux i think. Could you please rerun the CI?

@liamappelbe
Copy link
Contributor

@Hassnaa9 If this is ready for review, click the request review button in the top right.

@Hassnaa9
Copy link
Contributor Author

@liamappelbe Yes it's ready, but i can't find the button
image

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[swift2objc] Support Extensions

2 participants