fix(es/decorators): Fix bugs of 2022-03 implementation (#9145)

**Description:**

I extracted some changes from https://github.com/swc-project/swc/pull/8970
This commit is contained in:
Donny/강동윤 2024-07-05 17:02:43 +09:00 committed by GitHub
parent ce454176ba
commit 8a3ae44370
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
32 changed files with 489 additions and 360 deletions

View File

@ -42,6 +42,7 @@ use swc_ecma_minifier::option::terser::TerserTopLevelOptions;
#[allow(deprecated)]
pub use swc_ecma_parser::JscTarget;
use swc_ecma_parser::{parse_file_as_expr, Syntax, TsSyntax};
pub use swc_ecma_transforms::proposals::DecoratorVersion;
use swc_ecma_transforms::{
feature::FeatureFlag,
hygiene, modules,
@ -676,6 +677,18 @@ impl Options {
{
Box::new(plugin_transforms)
} else {
let decorator_pass: Box<dyn Fold> =
match transform.decorator_version.unwrap_or_default() {
DecoratorVersion::V202112 => Box::new(decorators(decorators::Config {
legacy: transform.legacy_decorator.into_bool(),
emit_metadata: transform.decorator_metadata.into_bool(),
use_define_for_class_fields: !assumptions.set_public_class_fields,
})),
DecoratorVersion::V202203 => Box::new(
swc_ecma_transforms::proposals::decorator_2022_03::decorator_2022_03(),
),
};
Box::new(chain!(
lint_to_fold(swc_ecma_lints::rules::all(LintParams {
program: &program,
@ -686,23 +699,7 @@ impl Options {
source_map: cm.clone(),
})),
// Decorators may use type information
Optional::new(
match transform.decorator_version.unwrap_or_default() {
DecoratorVersion::V202112 => {
Either::Left(decorators(decorators::Config {
legacy: transform.legacy_decorator.into_bool(),
emit_metadata: transform.decorator_metadata.into_bool(),
use_define_for_class_fields: !assumptions.set_public_class_fields,
}))
}
DecoratorVersion::V202203 => {
Either::Right(
swc_ecma_transforms::proposals::decorator_2022_03::decorator_2022_03(),
)
}
},
syntax.decorators()
),
Optional::new(decorator_pass, syntax.decorators()),
Optional::new(
explicit_resource_management(),
syntax.explicit_resource_management()
@ -1446,17 +1443,6 @@ pub struct TransformConfig {
pub decorator_version: Option<DecoratorVersion>,
}
#[derive(Debug, Default, Clone, Copy, Serialize, Deserialize)]
#[serde(deny_unknown_fields, rename_all = "camelCase")]
pub enum DecoratorVersion {
#[default]
#[serde(rename = "2021-12")]
V202112,
#[serde(rename = "2022-03")]
V202203,
}
#[derive(Debug, Default, Clone, Serialize, Deserialize, Merge)]
#[serde(deny_unknown_fields, rename_all = "camelCase")]
pub struct HiddenTransformConfig {

View File

@ -13,11 +13,11 @@ use swc_ecma_utils::{
use swc_ecma_visit::{as_folder, noop_visit_mut_type, Fold, VisitMut, VisitMutWith};
pub fn decorator_2022_03() -> impl VisitMut + Fold {
as_folder(Decorator202203::default())
as_folder(Decorator2022_03::default())
}
#[derive(Default)]
struct Decorator202203 {
struct Decorator2022_03 {
/// Variables without initializer.
extra_vars: Vec<VarDeclarator>,
@ -35,6 +35,8 @@ struct Decorator202203 {
#[derive(Default)]
struct ClassState {
private_id_index: u32,
static_lhs: Vec<Ident>,
proto_lhs: Vec<Ident>,
@ -55,7 +57,7 @@ struct ClassState {
super_class: Option<Ident>,
}
impl Decorator202203 {
impl Decorator2022_03 {
fn preserve_side_effect_of_decorators(
&mut self,
decorators: Vec<Decorator>,
@ -463,6 +465,7 @@ impl Decorator202203 {
let has_static_member = body.iter().any(|m| match m {
ClassMember::Method(m) => m.is_static,
ClassMember::PrivateMethod(m) => m.is_static,
ClassMember::AutoAccessor(m) => m.is_static,
ClassMember::ClassProp(ClassProp { is_static, .. })
| ClassMember::PrivateProp(PrivateProp { is_static, .. }) => *is_static,
ClassMember::StaticBlock(_) => true,
@ -527,7 +530,9 @@ impl Decorator202203 {
for m in body.iter_mut() {
match m {
ClassMember::ClassProp(..) | ClassMember::PrivateProp(..) => {
ClassMember::ClassProp(..)
| ClassMember::PrivateProp(..)
| ClassMember::AutoAccessor(..) => {
replace_ident(m, c.ident.to_id(), &new_class_name);
}
@ -568,6 +573,13 @@ impl Decorator202203 {
p.is_static = false;
}
}
ClassMember::AutoAccessor(p) => {
if p.is_static {
should_move = true;
p.is_static = false;
}
}
_ => (),
}
@ -753,7 +765,7 @@ impl Decorator202203 {
}
}
impl VisitMut for Decorator202203 {
impl VisitMut for Decorator2022_03 {
noop_visit_mut_type!();
fn visit_mut_class(&mut self, n: &mut Class) {
@ -932,6 +944,8 @@ impl VisitMut for Decorator202203 {
for mut m in members.take() {
match m {
ClassMember::AutoAccessor(mut accessor) => {
accessor.value.visit_mut_with(self);
let name;
let init;
let field_name_like: JsWord;
@ -947,9 +961,14 @@ impl VisitMut for Decorator202203 {
init = private_ident!(format!("_init_{}", k.id.sym));
field_name_like = format!("__{}", k.id.sym).into();
self.state.private_id_index += 1;
PrivateName {
span: k.span,
id: Ident::new(format!("__{}", k.id.sym).into(), k.id.span),
id: Ident::new(
format!("__{}_{}", k.id.sym, self.state.private_id_index)
.into(),
k.id.span,
),
}
}
Key::Public(k) => {
@ -958,10 +977,16 @@ impl VisitMut for Decorator202203 {
.replacen("init", "private", 1)
.into();
self.state.private_id_index += 1;
PrivateName {
span: init.span.with_ctxt(SyntaxContext::empty()),
id: Ident::new(
field_name_like.clone(),
format!(
"{field_name_like}_{}",
self.state.private_id_index
)
.into(),
init.span.with_ctxt(SyntaxContext::empty()),
),
}
@ -1310,7 +1335,9 @@ impl VisitMut for Decorator202203 {
for mut m in new.take() {
match m {
ClassMember::Method(..) | ClassMember::PrivateMethod(..) => {}
ClassMember::Method(..)
| ClassMember::PrivateMethod(..)
| ClassMember::AutoAccessor(..) => {}
_ => {
if !m.span().is_dummy() {

View File

@ -1,11 +1,24 @@
#![deny(clippy::all)]
#![allow(clippy::vec_box)]
use serde::{Deserialize, Serialize};
pub use self::{
decorators::decorators, export_default_from::export_default_from,
import_assertions::import_assertions,
};
#[derive(Debug, Default, Clone, Copy, Serialize, Deserialize)]
#[serde(deny_unknown_fields, rename_all = "camelCase")]
pub enum DecoratorVersion {
#[default]
#[serde(rename = "2021-12")]
V202112,
#[serde(rename = "2022-03")]
V202203,
}
pub mod decorator_2022_03;
pub mod decorators;
pub mod explicit_resource_management;

View File

@ -1 +0,0 @@
run-decorator-tests.js

View File

@ -0,0 +1,39 @@
(() => {
let old;
let block;
class Bar {
}
const dec = (cls, ctx) => {
old = cls;
return Bar;
};
const Foo =
@dec
class Foo {
static { block = Foo; }
method() { return Foo; }
static method() { return Foo; }
field = Foo;
static field = Foo;
get getter() { return Foo; }
static get getter() { return Foo; }
set setter(x) { x.foo = Foo; }
static set setter(x) { x.foo = Foo; }
accessor accessor = Foo;
static accessor accessor = Foo;
};
const foo = new old;
let obj;
assertEq(() => Foo !== old, true);
assertEq(() => Foo, Bar);
assertEq(() => block, Bar);
assertEq(() => Foo.field, Bar);
assertEq(() => foo.field, Bar);
assertEq(() => old.getter, Bar);
assertEq(() => foo.getter, Bar);
assertEq(() => (obj = { foo: null }, old.setter = obj, obj.foo), Bar);
assertEq(() => (obj = { foo: null }, foo.setter = obj, obj.foo), Bar);
// The specification for accessors is potentially wrong at the moment: https://github.com/tc39/proposal-decorators/issues/529
// assertEq(() => old.accessor, Bar)
// assertEq(() => foo.accessor, Bar)
})();

View File

@ -0,0 +1,38 @@
(() => {
let old;
let block;
class Bar {
}
const dec = (cls, ctx) => {
old = cls;
return Bar;
};
@dec
class Foo {
static { block = Foo; }
method() { return Foo; }
static method() { return Foo; }
field = Foo;
static field = Foo;
get getter() { return Foo; }
static get getter() { return Foo; }
set setter(x) { x.foo = Foo; }
static set setter(x) { x.foo = Foo; }
accessor accessor = Foo;
static accessor accessor = Foo;
}
const foo = new old;
let obj;
assertEq(() => Foo !== old, true);
assertEq(() => Foo, Bar);
assertEq(() => block, Bar);
assertEq(() => Foo.field, Bar);
assertEq(() => foo.field, Bar);
assertEq(() => old.getter, Bar);
assertEq(() => foo.getter, Bar);
assertEq(() => (obj = { foo: null }, old.setter = obj, obj.foo), Bar);
assertEq(() => (obj = { foo: null }, foo.setter = obj, obj.foo), Bar);
// The specification for accessors is potentially wrong at the moment: https://github.com/tc39/proposal-decorators/issues/529
// assertEq(() => old.accessor, Bar)
// assertEq(() => foo.accessor, Bar)
})();

View File

@ -65,4 +65,23 @@
assertEq(() => Object.getPrototypeOf(foo), null);
assertEq(() => order(bar), '0,1,2,3,11,12,13,14,4,5,6,7,15,16,17,18,8,19,9,20,10,21');
assertEq(() => Object.getPrototypeOf(bar), foo);
// Test an undecorated class
const FooNoDec = class {
};
const BarNoDec = class extends FooNoDec {
};
assertEq(() => FooNoDec[Symbol.metadata], null);
assertEq(() => BarNoDec[Symbol.metadata], null);
// Test a class with no class decorator
const FooOneDec = class {
@dec
x;
};
const BarOneDec = class extends FooOneDec {
@dec
y;
};
assertEq(() => JSON.stringify(FooOneDec[Symbol.metadata]), JSON.stringify({ x: 22 }));
assertEq(() => JSON.stringify(BarOneDec[Symbol.metadata]), JSON.stringify({ y: 23 }));
assertEq(() => Object.getPrototypeOf(BarOneDec[Symbol.metadata]), FooOneDec[Symbol.metadata]);
})();

View File

@ -64,4 +64,23 @@
assertEq(() => Object.getPrototypeOf(foo), null);
assertEq(() => order(bar), '0,1,2,3,11,12,13,14,4,5,6,7,15,16,17,18,8,19,9,20,10,21');
assertEq(() => Object.getPrototypeOf(bar), foo);
// Test an undecorated class
class FooNoDec {
}
class BarNoDec extends FooNoDec {
}
assertEq(() => FooNoDec[Symbol.metadata], null);
assertEq(() => BarNoDec[Symbol.metadata], null);
// Test a class with no class decorator
class FooOneDec {
@dec
x;
}
class BarOneDec extends FooOneDec {
@dec
y;
}
assertEq(() => JSON.stringify(FooOneDec[Symbol.metadata]), JSON.stringify({ x: 22 }));
assertEq(() => JSON.stringify(BarOneDec[Symbol.metadata]), JSON.stringify({ y: 23 }));
assertEq(() => Object.getPrototypeOf(BarOneDec[Symbol.metadata]), FooOneDec[Symbol.metadata]);
})();

View File

@ -1,81 +0,0 @@
use std::{fs, process::Command};
use swc_common::Mark;
use swc_ecma_ast::EsVersion;
use swc_ecma_codegen::to_code;
use swc_ecma_parser::parse_file_as_program;
use swc_ecma_transforms_base::{
fixer::fixer,
helpers::{inject_helpers, Helpers, HELPERS},
hygiene::hygiene,
resolver,
};
use swc_ecma_transforms_proposal::decorator_2022_03::decorator_2022_03;
use swc_ecma_visit::VisitMutWith;
use testing::find_executable;
#[test]
#[ignore = "TODO: Fix this test"]
fn execute() {
testing::run_test(false, |cm, handler| {
let node = find_executable("node").expect("node not found");
let fm = cm
.load_file("tests/decorator-tests/decorator-tests.js".as_ref())
.expect("failed to load file");
let code = {
// Transpile with swc
let mut errors = vec![];
let program = parse_file_as_program(
&fm,
swc_ecma_parser::Syntax::Es(swc_ecma_parser::EsSyntax {
decorators: true,
auto_accessors: true,
..Default::default()
}),
EsVersion::EsNext,
None,
&mut errors,
);
let mut program = match program {
Ok(v) => v,
Err(e) => {
e.into_diagnostic(handler).emit();
return Err(());
}
};
for e in errors {
e.into_diagnostic(handler).emit();
}
HELPERS.set(&Helpers::new(false), || {
let unresolved_mark = Mark::new();
let top_level_mark = Mark::new();
program.visit_mut_with(&mut resolver(unresolved_mark, top_level_mark, false));
program.visit_mut_with(&mut decorator_2022_03());
program.visit_mut_with(&mut inject_helpers(unresolved_mark));
program.visit_mut_with(&mut hygiene());
program.visit_mut_with(&mut fixer(None));
});
to_code(&program)
};
fs::write("tests/run-decorator-tests.js", code).expect("failed to write file");
let status = Command::new(node)
.arg("tests/run-decorator-tests.js")
.status()
.expect("failed to execute process");
assert!(status.success());
Ok(())
})
.unwrap()
}

View File

@ -0,0 +1,70 @@
use std::{fs, path::PathBuf};
use swc_ecma_parser::{EsSyntax, Syntax};
use swc_ecma_transforms_proposal::decorator_2022_03::decorator_2022_03;
use swc_ecma_transforms_testing::exec_tr;
use swc_ecma_visit::as_folder;
const HELPERS: &str = r###"
function assertEq(callback, expected) {
let details;
try {
let x = callback();
if (x === expected)
return true;
details = ` Expected: ${prettyPrint(expected)}\n Observed: ${prettyPrint(x)}`;
}
catch (error) {
details = ` Throws: ${error}`;
}
const code = callback.toString().replace(/^\(\) => /, '').replace(/\s+/g, ' ');
console.log(`\n Code: ${code}\n${details}\n`);
return false;
}
function assertThrows(callback, expected) {
let details;
try {
let x = callback();
details = ` Expected: throws instanceof ${expected.name}\n Observed: returns ${prettyPrint(x)}`;
}
catch (error) {
if (error instanceof expected)
return true;
details = ` Expected: throws instanceof ${expected.name}\n Observed: throws ${error}`;
}
const code = callback.toString().replace(/^\(\) => /, '').replace(/\s+/g, ' ');
console.log(`\n Code: ${code}\n${details}\n`);
return false;
}
"###;
// TODO: Unignore tests
#[testing::fixture(
"tests/decorator-evanw-split/*.js",
exclude(
"Decorator-list-evaluation-await-class-statement.js",
"Decorator-list-evaluation-Inner-private-name-class-statement.js",
"Decorator-list-evaluation-Inner-private-name-class-expression.js"
)
)]
fn fixture(input: PathBuf) {
let code = fs::read_to_string(&input).unwrap();
let code = format!(
"{HELPERS}
{code}"
);
exec_tr(
&input.file_name().unwrap().to_string_lossy(),
Syntax::Es(EsSyntax {
decorators: true,
auto_accessors: true,
..Default::default()
}),
|_| as_folder(decorator_2022_03()),
&code,
);
}

View File

@ -9,7 +9,7 @@ use serde::Deserialize;
use swc_common::{chain, comments::SingleThreadedComments, Mark};
use swc_ecma_parser::{EsSyntax, Syntax, TsSyntax};
use swc_ecma_transforms_base::{assumptions::Assumptions, resolver};
use swc_ecma_transforms_proposal::decorator_2022_03::decorator_2022_03;
use swc_ecma_transforms_proposal::{decorator_2022_03::decorator_2022_03, DecoratorVersion};
use swc_ecma_transforms_testing::{test_fixture, FixtureTestConfig};
use swc_ecma_visit::Fold;
@ -82,7 +82,7 @@ fn fixture_inner(input: PathBuf) {
}
#[derive(Debug, Deserialize)]
#[serde(deny_unknown_fields, rename_all = "camelCase")]
#[serde(rename_all = "camelCase")]
struct BabelTestOptions {
#[serde(default)]
assumptions: Assumptions,
@ -107,36 +107,17 @@ enum BabelPluginEntry {
#[derive(Debug, Deserialize)]
#[serde(deny_unknown_fields, untagged, rename_all = "camelCase")]
enum BabelPluginOption {
Decorator { version: String },
}
fn read_options_json(input: &Path) -> BabelTestOptions {
let mut options_path = input.to_path_buf();
options_path.set_file_name("options.json");
if options_path.exists() {
let s = std::fs::read_to_string(&options_path).unwrap();
println!("Options: {}", s);
return serde_json::from_str(&s).expect("failed to read options.json");
}
println!("Reading options from {:?}", options_path);
// Look for parent directory
read_options_json(options_path.parent().unwrap())
Decorator { version: DecoratorVersion },
}
fn create_pass(comments: Rc<SingleThreadedComments>, input: &Path) -> Box<dyn Fold> {
let options_json = read_options_json(input);
let options_json: BabelTestOptions =
swc_ecma_transforms_testing::parse_options(input.parent().unwrap());
let unresolved_mark = Mark::new();
let top_level_mark = Mark::new();
let mut pass: Box<dyn Fold> = Box::new(chain!(
resolver(unresolved_mark, top_level_mark, false),
decorator_2022_03()
));
let mut pass: Box<dyn Fold> = Box::new(resolver(unresolved_mark, top_level_mark, false));
macro_rules! add {
($e:expr) => {{
@ -178,7 +159,22 @@ fn create_pass(comments: Rc<SingleThreadedComments>, input: &Path) -> Box<dyn Fo
}
_ => {}
},
BabelPluginEntry::WithConfig(name, config) => {}
BabelPluginEntry::WithConfig(name, config) => match &**name {
"proposal-decorators" => match config {
BabelPluginOption::Decorator { version } => match version {
// DecoratorVersion::V202311 => {
// add!(decorator_2023_11());
// }
DecoratorVersion::V202112 => todo!(),
DecoratorVersion::V202203 => {
add!(decorator_2022_03());
}
},
},
_ => {
panic!("Unknown plugin: {}", name);
}
},
}
dbg!(&plugin);

View File

@ -1,6 +1,6 @@
var _init_a, _get___a, _set___a, _init_b, _get___b, _set___b, _initProto;
const dec = ()=>{};
var ___a = /*#__PURE__*/ new WeakMap(), _a = /*#__PURE__*/ new WeakMap(), ___b = /*#__PURE__*/ new WeakMap(), _b = /*#__PURE__*/ new WeakMap();
var ___a_1 = /*#__PURE__*/ new WeakMap(), _a = /*#__PURE__*/ new WeakMap(), ___b_2 = /*#__PURE__*/ new WeakMap(), _b = /*#__PURE__*/ new WeakMap();
class Foo {
constructor(){
_class_private_field_init(this, _a, {
@ -11,11 +11,11 @@ class Foo {
get: get_b,
set: set_b
});
_class_private_field_init(this, ___a, {
_class_private_field_init(this, ___a_1, {
writable: true,
value: (_initProto(this), _init_a(this))
});
_class_private_field_init(this, ___b, {
_class_private_field_init(this, ___b_2, {
writable: true,
value: _init_b(this, 123)
});
@ -29,10 +29,10 @@ var __ = {
1,
"a",
function() {
return _class_private_field_get(this, ___a);
return _class_private_field_get(this, ___a_1);
},
function(_v) {
_class_private_field_set(this, ___a, _v);
_class_private_field_set(this, ___a_1, _v);
}
],
[
@ -40,10 +40,10 @@ var __ = {
1,
"b",
function() {
return _class_private_field_get(this, ___b);
return _class_private_field_get(this, ___b_2);
},
function(_v) {
_class_private_field_set(this, ___b, _v);
_class_private_field_set(this, ___b_2, _v);
}
]
], [])

View File

@ -1,37 +1,37 @@
var _init_a, _init_b, _computedKey, _init_computedKey, _initProto;
const dec = ()=>{};
_computedKey = 'c';
var ____private_a = /*#__PURE__*/ new WeakMap(), ____private_b = /*#__PURE__*/ new WeakMap(), ____private_computedKey = /*#__PURE__*/ new WeakMap();
var ____private_a_1 = /*#__PURE__*/ new WeakMap(), ____private_b_2 = /*#__PURE__*/ new WeakMap(), ____private_computedKey_3 = /*#__PURE__*/ new WeakMap();
let _computedKey1 = _computedKey, _computedKey2 = _computedKey;
class Foo {
get a() {
return _class_private_field_get(this, ____private_a);
return _class_private_field_get(this, ____private_a_1);
}
set a(_v) {
_class_private_field_set(this, ____private_a, _v);
_class_private_field_set(this, ____private_a_1, _v);
}
get b() {
return _class_private_field_get(this, ____private_b);
return _class_private_field_get(this, ____private_b_2);
}
set b(_v) {
_class_private_field_set(this, ____private_b, _v);
_class_private_field_set(this, ____private_b_2, _v);
}
get [_computedKey1]() {
return _class_private_field_get(this, ____private_computedKey);
return _class_private_field_get(this, ____private_computedKey_3);
}
set [_computedKey2](_v) {
_class_private_field_set(this, ____private_computedKey, _v);
_class_private_field_set(this, ____private_computedKey_3, _v);
}
constructor(){
_class_private_field_init(this, ____private_a, {
_class_private_field_init(this, ____private_a_1, {
writable: true,
value: (_initProto(this), _init_a(this))
});
_class_private_field_init(this, ____private_b, {
_class_private_field_init(this, ____private_b_2, {
writable: true,
value: _init_b(this, 123)
});
_class_private_field_init(this, ____private_computedKey, {
_class_private_field_init(this, ____private_computedKey_3, {
writable: true,
value: _init_computedKey(this, 456)
});

View File

@ -19,10 +19,10 @@ var __ = {
6,
"a",
function() {
return _class_static_private_field_spec_get(this, Foo, ___a);
return _class_static_private_field_spec_get(this, Foo, ___a_1);
},
function(_v) {
_class_static_private_field_spec_set(this, Foo, ___a, _v);
_class_static_private_field_spec_set(this, Foo, ___a_1, _v);
}
],
[
@ -30,21 +30,21 @@ var __ = {
6,
"b",
function() {
return _class_static_private_field_spec_get(this, Foo, ___b);
return _class_static_private_field_spec_get(this, Foo, ___b_2);
},
function(_v) {
_class_static_private_field_spec_set(this, Foo, ___b, _v);
_class_static_private_field_spec_set(this, Foo, ___b_2, _v);
}
]
], []));
_initStatic(Foo);
})()
};
var ___a = {
var ___a_1 = {
writable: true,
value: _init_a(Foo)
};
var ___b = {
var ___b_2 = {
writable: true,
value: _init_b(Foo, 123)
};

View File

@ -4,22 +4,22 @@ _computedKey = 'c';
let _computedKey1 = _computedKey, _computedKey2 = _computedKey;
class Foo {
static get a() {
return _class_static_private_field_spec_get(this, Foo, ____private_a);
return _class_static_private_field_spec_get(this, Foo, ____private_a_1);
}
static set a(_v) {
_class_static_private_field_spec_set(this, Foo, ____private_a, _v);
_class_static_private_field_spec_set(this, Foo, ____private_a_1, _v);
}
static get b() {
return _class_static_private_field_spec_get(this, Foo, ____private_b);
return _class_static_private_field_spec_get(this, Foo, ____private_b_2);
}
static set b(_v) {
_class_static_private_field_spec_set(this, Foo, ____private_b, _v);
_class_static_private_field_spec_set(this, Foo, ____private_b_2, _v);
}
static get [_computedKey1]() {
return _class_static_private_field_spec_get(this, Foo, ____private_computedKey);
return _class_static_private_field_spec_get(this, Foo, ____private_computedKey_3);
}
static set [_computedKey2](_v) {
_class_static_private_field_spec_set(this, Foo, ____private_computedKey, _v);
_class_static_private_field_spec_set(this, Foo, ____private_computedKey_3, _v);
}
}
var __ = {
@ -45,15 +45,15 @@ var __ = {
_initStatic(Foo);
})()
};
var ____private_a = {
var ____private_a_1 = {
writable: true,
value: _init_a(Foo)
};
var ____private_b = {
var ____private_b_2 = {
writable: true,
value: _init_b(Foo, 123)
};
var ____private_computedKey = {
var ____private_computedKey_3 = {
writable: true,
value: _init_computedKey(Foo, 456)
};

View File

@ -1,5 +1,5 @@
const dec = ()=>{};
var ___a = /*#__PURE__*/ new WeakMap(), _a = /*#__PURE__*/ new WeakMap(), ___b = /*#__PURE__*/ new WeakMap(), _b = /*#__PURE__*/ new WeakMap();
var ___a_1 = /*#__PURE__*/ new WeakMap(), _a = /*#__PURE__*/ new WeakMap(), ___b_2 = /*#__PURE__*/ new WeakMap(), _b = /*#__PURE__*/ new WeakMap();
class Foo {
constructor(){
_class_private_field_init(this, _a, {
@ -10,25 +10,25 @@ class Foo {
get: get_b,
set: set_b
});
_class_private_field_init(this, ___a, {
_class_private_field_init(this, ___a_1, {
writable: true,
value: void 0
});
_class_private_field_init(this, ___b, {
_class_private_field_init(this, ___b_2, {
writable: true,
value: 123
});
}
}
function get_a() {
return _class_private_field_get(this, ___a);
return _class_private_field_get(this, ___a_1);
}
function set_a(_v) {
_class_private_field_set(this, ___a, _v);
_class_private_field_set(this, ___a_1, _v);
}
function get_b() {
return _class_private_field_get(this, ___b);
return _class_private_field_get(this, ___b_2);
}
function set_b(_v) {
_class_private_field_set(this, ___b, _v);
_class_private_field_set(this, ___b_2, _v);
}

View File

@ -1,37 +1,37 @@
var _computedKey;
const dec = ()=>{};
_computedKey = 'c';
var ____private_a = /*#__PURE__*/ new WeakMap(), ____private_b = /*#__PURE__*/ new WeakMap(), ____private_computedKey = /*#__PURE__*/ new WeakMap();
var ____private_a_1 = /*#__PURE__*/ new WeakMap(), ____private_b_2 = /*#__PURE__*/ new WeakMap(), ____private_computedKey_3 = /*#__PURE__*/ new WeakMap();
let _computedKey1 = _computedKey, _computedKey2 = _computedKey;
class Foo {
get a() {
return _class_private_field_get(this, ____private_a);
return _class_private_field_get(this, ____private_a_1);
}
set a(_v) {
_class_private_field_set(this, ____private_a, _v);
_class_private_field_set(this, ____private_a_1, _v);
}
get b() {
return _class_private_field_get(this, ____private_b);
return _class_private_field_get(this, ____private_b_2);
}
set b(_v) {
_class_private_field_set(this, ____private_b, _v);
_class_private_field_set(this, ____private_b_2, _v);
}
get [_computedKey1]() {
return _class_private_field_get(this, ____private_computedKey);
return _class_private_field_get(this, ____private_computedKey_3);
}
set [_computedKey2](_v) {
_class_private_field_set(this, ____private_computedKey, _v);
_class_private_field_set(this, ____private_computedKey_3, _v);
}
constructor(){
_class_private_field_init(this, ____private_a, {
_class_private_field_init(this, ____private_a_1, {
writable: true,
value: void 0
});
_class_private_field_init(this, ____private_b, {
_class_private_field_init(this, ____private_b_2, {
writable: true,
value: 123
});
_class_private_field_init(this, ____private_computedKey, {
_class_private_field_init(this, ____private_computedKey_3, {
writable: true,
value: 456
});

View File

@ -9,23 +9,23 @@ var _b = {
get: get_b,
set: set_b
};
var ___a = {
var ___a_1 = {
writable: true,
value: void 0
};
var ___b = {
var ___b_2 = {
writable: true,
value: 123
};
function get_a() {
return _class_static_private_field_spec_get(this, Foo, ___a);
return _class_static_private_field_spec_get(this, Foo, ___a_1);
}
function set_a(_v) {
_class_static_private_field_spec_set(this, Foo, ___a, _v);
_class_static_private_field_spec_set(this, Foo, ___a_1, _v);
}
function get_b() {
return _class_static_private_field_spec_get(this, Foo, ___b);
return _class_static_private_field_spec_get(this, Foo, ___b_2);
}
function set_b(_v) {
_class_static_private_field_spec_set(this, Foo, ___b, _v);
_class_static_private_field_spec_set(this, Foo, ___b_2, _v);
}

View File

@ -4,33 +4,33 @@ _computedKey = 'c';
let _computedKey1 = _computedKey, _computedKey2 = _computedKey;
class Foo {
static get a() {
return _class_static_private_field_spec_get(this, Foo, ____private_a);
return _class_static_private_field_spec_get(this, Foo, ____private_a_1);
}
static set a(_v) {
_class_static_private_field_spec_set(this, Foo, ____private_a, _v);
_class_static_private_field_spec_set(this, Foo, ____private_a_1, _v);
}
static get b() {
return _class_static_private_field_spec_get(this, Foo, ____private_b);
return _class_static_private_field_spec_get(this, Foo, ____private_b_2);
}
static set b(_v) {
_class_static_private_field_spec_set(this, Foo, ____private_b, _v);
_class_static_private_field_spec_set(this, Foo, ____private_b_2, _v);
}
static get [_computedKey1]() {
return _class_static_private_field_spec_get(this, Foo, ____private_computedKey);
return _class_static_private_field_spec_get(this, Foo, ____private_computedKey_3);
}
static set [_computedKey2](_v) {
_class_static_private_field_spec_set(this, Foo, ____private_computedKey, _v);
_class_static_private_field_spec_set(this, Foo, ____private_computedKey_3, _v);
}
}
var ____private_a = {
var ____private_a_1 = {
writable: true,
value: void 0
};
var ____private_b = {
var ____private_b_2 = {
writable: true,
value: 123
};
var ____private_computedKey = {
var ____private_computedKey_3 = {
writable: true,
value: 456
};

View File

@ -8,10 +8,10 @@ class Foo {
1,
"a",
function() {
return this.#__a;
return this.#__a_1;
},
function(_v) {
this.#__a = _v;
this.#__a_1 = _v;
}
],
[
@ -19,22 +19,22 @@ class Foo {
1,
"b",
function() {
return this.#__b;
return this.#__b_2;
},
function(_v) {
this.#__b = _v;
this.#__b_2 = _v;
}
]
], []));
}
#__a = (_initProto(this), _init_a(this));
#__a_1 = (_initProto(this), _init_a(this));
get #a() {
return _get___a(this);
}
set #a(_v) {
_set___a(this, _v);
}
#__b = _init_b(this, 123);
#__b_2 = _init_b(this, 123);
get #b() {
return _get___b(this);
}

View File

@ -21,25 +21,25 @@ class Foo {
]
], []));
}
#___private_a = (_initProto(this), _init_a(this));
#___private_a_1 = (_initProto(this), _init_a(this));
get a() {
return this.#___private_a;
return this.#___private_a_1;
}
set a(_v) {
this.#___private_a = _v;
this.#___private_a_1 = _v;
}
#___private_b = _init_b(this, 123);
#___private_b_2 = _init_b(this, 123);
get b() {
return this.#___private_b;
return this.#___private_b_2;
}
set b(_v) {
this.#___private_b = _v;
this.#___private_b_2 = _v;
}
#___private_computedKey = _init_computedKey(this, 456);
#___private_computedKey_3 = _init_computedKey(this, 456);
get [_computedKey]() {
return this.#___private_computedKey;
return this.#___private_computedKey_3;
}
set [_computedKey](_v) {
this.#___private_computedKey = _v;
this.#___private_computedKey_3 = _v;
}
}

View File

@ -8,10 +8,10 @@ class Foo {
6,
"a",
function() {
return this.#__a;
return this.#__a_1;
},
function(_v) {
this.#__a = _v;
this.#__a_1 = _v;
}
],
[
@ -19,23 +19,23 @@ class Foo {
6,
"b",
function() {
return this.#__b;
return this.#__b_2;
},
function(_v) {
this.#__b = _v;
this.#__b_2 = _v;
}
]
], []));
_initStatic(this);
}
static #__a = _init_a(this);
static #__a_1 = _init_a(this);
static get #a() {
return _get___a(this);
}
static set #a(_v) {
_set___a(this, _v);
}
static #__b = _init_b(this, 123);
static #__b_2 = _init_b(this, 123);
static get #b() {
return _get___b(this);
}

View File

@ -22,25 +22,25 @@ class Foo {
], []));
_initStatic(this);
}
static #___private_a = _init_a(this);
static #___private_a_1 = _init_a(this);
static get a() {
return this.#___private_a;
return this.#___private_a_1;
}
static set a(_v) {
this.#___private_a = _v;
this.#___private_a_1 = _v;
}
static #___private_b = _init_b(this, 123);
static #___private_b_2 = _init_b(this, 123);
static get b() {
return this.#___private_b;
return this.#___private_b_2;
}
static set b(_v) {
this.#___private_b = _v;
this.#___private_b_2 = _v;
}
static #___private_computedKey = _init_computedKey(this, 456);
static #___private_computedKey_3 = _init_computedKey(this, 456);
static get [_computedKey]() {
return this.#___private_computedKey;
return this.#___private_computedKey_3;
}
static set [_computedKey](_v) {
this.#___private_computedKey = _v;
this.#___private_computedKey_3 = _v;
}
}

View File

@ -1,17 +1,17 @@
const dec = ()=>{};
class Foo {
#__a;
#__a_1;
get #a() {
return this.#__a;
return this.#__a_1;
}
set #a(_v) {
this.#__a = _v;
this.#__a_1 = _v;
}
#__b = 123;
#__b_2 = 123;
get #b() {
return this.#__b;
return this.#__b_2;
}
set #b(_v) {
this.#__b = _v;
this.#__b_2 = _v;
}
}

View File

@ -2,25 +2,25 @@ var _computedKey;
const dec = ()=>{};
_computedKey = 'c';
class Foo {
#___private_a;
#___private_a_1;
get a() {
return this.#___private_a;
return this.#___private_a_1;
}
set a(_v) {
this.#___private_a = _v;
this.#___private_a_1 = _v;
}
#___private_b = 123;
#___private_b_2 = 123;
get b() {
return this.#___private_b;
return this.#___private_b_2;
}
set b(_v) {
this.#___private_b = _v;
this.#___private_b_2 = _v;
}
#___private_computedKey = 456;
#___private_computedKey_3 = 456;
get [_computedKey]() {
return this.#___private_computedKey;
return this.#___private_computedKey_3;
}
set [_computedKey](_v) {
this.#___private_computedKey = _v;
this.#___private_computedKey_3 = _v;
}
}

View File

@ -1,17 +1,17 @@
const dec = ()=>{};
class Foo {
static #__a;
static #__a_1;
static get #a() {
return this.#__a;
return this.#__a_1;
}
static set #a(_v) {
this.#__a = _v;
this.#__a_1 = _v;
}
static #__b = 123;
static #__b_2 = 123;
static get #b() {
return this.#__b;
return this.#__b_2;
}
static set #b(_v) {
this.#__b = _v;
this.#__b_2 = _v;
}
}

View File

@ -2,25 +2,25 @@ var _computedKey;
const dec = ()=>{};
_computedKey = 'c';
class Foo {
static #___private_a;
static #___private_a_1;
static get a() {
return this.#___private_a;
return this.#___private_a_1;
}
static set a(_v) {
this.#___private_a = _v;
this.#___private_a_1 = _v;
}
static #___private_b = 123;
static #___private_b_2 = 123;
static get b() {
return this.#___private_b;
return this.#___private_b_2;
}
static set b(_v) {
this.#___private_b = _v;
this.#___private_b_2 = _v;
}
static #___private_computedKey = 456;
static #___private_computedKey_3 = 456;
static get [_computedKey]() {
return this.#___private_computedKey;
return this.#___private_computedKey_3;
}
static set [_computedKey](_v) {
this.#___private_computedKey = _v;
this.#___private_computedKey_3 = _v;
}
}

View File

@ -52,10 +52,10 @@ new class extends _identity {
6,
"r",
function() {
return this.#__r;
return this.#__r_4;
},
function(_v) {
this.#__r = _v;
this.#__r_4 = _v;
}
],
[
@ -117,10 +117,10 @@ new class extends _identity {
1,
"h",
function() {
return this.#__h;
return this.#__h_2;
},
function(_v) {
this.#__h = _v;
this.#__h_2 = _v;
}
],
[
@ -148,12 +148,12 @@ new class extends _identity {
b() {}
get c() {}
set c(v) {}
#___private_d = (_initProto(this), _init_d(this));
#___private_d_1 = (_initProto(this), _init_d(this));
get d() {
return this.#___private_d;
return this.#___private_d_1;
}
set d(_v) {
this.#___private_d = _v;
this.#___private_d_1 = _v;
}
#e = _init_e(this);
get #f() {
@ -165,7 +165,7 @@ new class extends _identity {
set #g(v) {
return _call_g1(this, v);
}
#__h = _init_h(this);
#__h_2 = _init_h(this);
get #h() {
return _get___h(this);
}
@ -177,14 +177,14 @@ new class extends _identity {
static get k() {}
static set l(v) {}
static get m() {
return this.#___private_m;
return this.#___private_m_3;
}
static set m(_v) {
this.#___private_m = _v;
this.#___private_m_3 = _v;
}
}
}
#___private_m = _init_m(this);
#___private_m_3 = _init_m(this);
#n = _init_n(this);
get #o() {
return _call_o;
@ -195,7 +195,7 @@ new class extends _identity {
set #q(v) {
return _call_q(this, v);
}
#__r = _init_r(this);
#__r_4 = _init_r(this);
get #r() {
return _get___r(this);
}

View File

@ -2,12 +2,12 @@ const dec = ()=>{};
class A {
#A = 1;
static B = class B extends A {
#___private_a = 2;
#___private_a_1 = 2;
get a() {
return this.#___private_a;
return this.#___private_a_1;
}
set a(_v) {
this.#___private_a = _v;
this.#___private_a_1 = _v;
}
getA() {
return this.#A;

View File

@ -1,6 +1,11 @@
var _initClass, _init_b, _init_c, _get___c, _set___c, _call_d, _initProto, _initStatic;
let _A;
class A {
new class extends _identity {
constructor(){
super(_A), _initClass();
}
static{
class A {
static{
({ e: [_init_b, _init_c, _get___c, _set___c, _call_d, _initProto, _initStatic], c: [_A, _initClass] } = _apply_decs_2203_r(this, [
[
@ -13,10 +18,10 @@ class A {
6,
"c",
function() {
return this.#__c;
return this.#__c_2;
},
function(_v) {
this.#__c = _v;
this.#__c_2 = _v;
}
],
[
@ -39,24 +44,23 @@ class A {
_initProto(this);
}
a() {}
static #___private_b = _init_b(this);
static get b() {
return this.#___private_b;
return this.#___private_b_1;
}
static set b(_v) {
this.#___private_b = _v;
}
static #__c = _init_c(this);
static get #c() {
return _get___c(this);
}
static set #c(_v) {
_set___c(this, _v);
this.#___private_b_1 = _v;
}
get #d() {
return _call_d;
}
static{
_initClass();
}
}
}
#___private_b_1 = _init_b(this);
#__c_2 = _init_c(this);
get #c() {
return _get___c(this);
}
set #c(_v) {
_set___c(this, _v);
}
}();

View File

@ -44,10 +44,10 @@ new class extends _identity {
1,
"d",
function() {
return this.#__d;
return this.#__d_2;
},
function(_v) {
this.#__d = _v;
this.#__d_2 = _v;
}
]
], [
@ -56,15 +56,15 @@ new class extends _identity {
]));
_initStatic(this);
}
#___private_a = (_initProto(this), _init_a(this));
#___private_a_1 = (_initProto(this), _init_a(this));
get a() {
return this.#___private_a;
return this.#___private_a_1;
}
set a(_v) {
this.#___private_a = _v;
this.#___private_a_1 = _v;
}
static b() {}
#__d = _init_d(this);
#__d_2 = _init_d(this);
get #d() {
return _get___d(this);
}

View File

@ -42,10 +42,10 @@ new class extends _identity {
6,
"g",
function() {
return this.#__g;
return this.#__g_3;
},
function(_v) {
this.#__g = _v;
this.#__g_3 = _v;
}
],
[
@ -81,10 +81,10 @@ new class extends _identity {
1,
"h",
function() {
return this.#__h;
return this.#__h_4;
},
function(_v) {
this.#__h = _v;
this.#__h_4 = _v;
}
]
], [
@ -98,20 +98,20 @@ new class extends _identity {
get #d() {
return _call_d;
}
#___private_e = (_initProto(this), _init_e(this));
#___private_e_1 = (_initProto(this), _init_e(this));
get e() {
return this.#___private_e;
return this.#___private_e_1;
}
set e(_v) {
this.#___private_e = _v;
this.#___private_e_1 = _v;
}
static get f() {
return this.#___private_f;
return this.#___private_f_2;
}
static set f(_v) {
this.#___private_f = _v;
this.#___private_f_2 = _v;
}
#__h = _init_h(this);
#__h_4 = _init_h(this);
get #h() {
return _get___h(this);
}
@ -123,8 +123,8 @@ new class extends _identity {
get #c() {
return _call_c;
}
#___private_f = _init_f(this);
#__g = _init_g(this);
#___private_f_2 = _init_f(this);
#__g_3 = _init_g(this);
get #g() {
return _get___g(this);
}