Skip to content

Commit

Permalink
TODO comment
Browse files Browse the repository at this point in the history
  • Loading branch information
overlookmotel committed Nov 30, 2024
1 parent 4bce4f7 commit 5c867b5
Showing 1 changed file with 24 additions and 0 deletions.
24 changes: 24 additions & 0 deletions crates/oxc_transformer/src/es2022/class_properties/static_prop.rs
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,30 @@ impl<'a, 'ctx, 'v> StaticInitializerVisitor<'a, 'ctx, 'v> {
}

impl<'a, 'ctx, 'v> VisitMut<'a> for StaticInitializerVisitor<'a, 'ctx, 'v> {
// TODO: Also need to call class visitors so private props stack is in correct state.
// Otherwise, in this example, `#x` in `getInnerX` is resolved incorrectly
// and `getInnerX()` will return 1 instead of 2.
// We have to visit the inner class now rather than later after exiting outer class so that
// `#y` in `getOuterY` resolves correctly too.
// ```js
// class Outer {
// #x = 1;
// #y = 1;
// static inner = class Inner {
// #x = 2;
// getInnerX() {
// return this.#x; // Should equal 2
// }
// getOuterY() {
// return this.#y; // Should equal 1
// }
// };
// }
// ```
//
// Need to save all per-class state (`insert_before` etc), and restore it again after.
// Using a stack would be overkill because nested classes in static blocks will be rare.

#[inline]
fn visit_expression(&mut self, expr: &mut Expression<'a>) {
match expr {
Expand Down

0 comments on commit 5c867b5

Please sign in to comment.