feat(macros): support symbol-named methods in #[boa(class)]#4697
Open
Yuvraj-cyborg wants to merge 3 commits intoboa-dev:mainfrom
Open
feat(macros): support symbol-named methods in #[boa(class)]#4697Yuvraj-cyborg wants to merge 3 commits intoboa-dev:mainfrom
Yuvraj-cyborg wants to merge 3 commits intoboa-dev:mainfrom
Conversation
Author
|
cc: @jedel1043 |
Test262 conformance changes
|
jedel1043
reviewed
Feb 25, 2026
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #4697 +/- ##
==========================================
+ Coverage 47.24% 57.17% +9.92%
==========================================
Files 476 550 +74
Lines 46892 60452 +13560
==========================================
+ Hits 22154 34561 +12407
- Misses 24738 25891 +1153 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
68e38f2 to
9c3b330
Compare
Author
|
cc: @jedel1043 |
Member
|
No need to CC me, just requesting a review already pings my notifications haha |
Author
bad habit :) |
jedel1043
requested changes
Feb 27, 2026
Member
jedel1043
left a comment
There was a problem hiding this comment.
Nice work! I have a suggestion to improve the maintainability of the code.
9c3b330 to
eebc6a4
Compare
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.
Summary
This PR adds support for well-known symbol-keyed methods, statics, and accessors
in the
#[boa(class)]macro. This allows builtins to declare them declarativelyinstead of manually patching prototypes after registration.
Closes: #4688
What Changed
core/macros/src/class.rsMethodNameenum (String | Symbol) replacing the rawStringname on:FunctionAccessorClassVisitorMethodName::to_key_tokens()now emits:js_string!(...)for string keysJsSymbol::iterator()(etc.) for symbol keysname_of()now:#[boa(symbol = "...")]first#[boa(rename = "...")]or default rename scheme otherwiseserialize_class_impl()now uses polymorphic key tokens for:builder.method()builder.static_method()builder.accessor()matchis handled viaIdent::new_rawsince it is a Rust keywordcore/macros/src/module.rsFunction::from_sigcallsite to wrap the name inMethodName::String(...)core/runtime/src/fetch/headers.rs#[boa(symbol = "iterator")]onJsHeaderstests/macros/tests/class.rsPairstruct with:#[boa(symbol = "toPrimitive")]#[boa(symbol = "iterator")]boa_class_symbol_methodstest covering:+p)p + 3)[...p])for...ofAccepted Symbol Names
The following well-known symbol names are supported:
asyncIteratorhasInstanceisConcatSpreadableiteratormatchmatchAllreplacesearchspeciessplittoPrimitivetoStringTagunscopablesUnknown names produce a compile-time error listing valid options.
Usage Example