Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(es/compat): Handle private names from class properties pass #8090

Merged
merged 107 commits into from
Nov 2, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
107 commits
Select commit Hold shift + click to select a range
b9de617
Add a test
kdy1 Oct 10, 2023
a7808e2
Add a test
kdy1 Oct 10, 2023
3b00983
fix
kdy1 Oct 10, 2023
fbc39b7
Update test refs
kdy1 Oct 10, 2023
b873c49
Add a pass
kdy1 Oct 11, 2023
5a1dc54
Add a test
kdy1 Oct 11, 2023
c13fbe9
Add a test, really
kdy1 Oct 11, 2023
f1c0f9c
Delete crates/swc/tests/fixture/issues-7xxx/7561/input/.swcrc
kdy1 Oct 11, 2023
82f0173
Update test refs
kdy1 Oct 11, 2023
4e0586d
fixture
kdy1 Oct 11, 2023
c5d517d
Update test refs
kdy1 Oct 11, 2023
7fe67d4
Revert "Delete crates/swc/tests/fixture/issues-7xxx/7561/input/.swcrc"
kdy1 Oct 11, 2023
118e4e0
Add tests
kdy1 Oct 11, 2023
25216c8
Add a test
kdy1 Oct 11, 2023
8cfb7a1
Update test refs
kdy1 Oct 11, 2023
137dbf3
Remove wrong
kdy1 Oct 12, 2023
150d1f0
WIP
kdy1 Oct 27, 2023
14ddb32
more match
kdy1 Oct 27, 2023
6e6207e
assert
kdy1 Oct 27, 2023
7c1c89a
Oh
kdy1 Oct 27, 2023
b68d2c6
some work
kdy1 Oct 27, 2023
1eb17c9
Copy opt chain
kdy1 Oct 27, 2023
15bb443
,unresolved_mark
kdy1 Oct 27, 2023
778e4ed
,unresolved_mark
kdy1 Oct 27, 2023
b4ae3f4
opt chain
kdy1 Oct 27, 2023
8d57935
Well
kdy1 Oct 27, 2023
f7a5db5
trivial refactor
kdy1 Oct 27, 2023
6318227
take_vars
kdy1 Oct 27, 2023
f918b4f
Not a public api
kdy1 Oct 27, 2023
ca9581d
One impl
kdy1 Oct 27, 2023
aec9fd9
assert
kdy1 Oct 27, 2023
78fb659
Remove needless code
kdy1 Oct 27, 2023
8780fa7
Fix some tests
kdy1 Oct 27, 2023
607a873
Fix some tests
kdy1 Oct 27, 2023
2f5ae42
Fix some tests
kdy1 Oct 27, 2023
54cf3ce
Fix some tests
kdy1 Oct 27, 2023
8fdd12b
Fix some tests
kdy1 Oct 27, 2023
7b855c2
Fix some tests
kdy1 Oct 27, 2023
1298ae5
Fix some tests
kdy1 Oct 27, 2023
f770713
Fix some tests
kdy1 Oct 27, 2023
f5e1c3d
Fix some tests
kdy1 Oct 27, 2023
ce527f8
Fix some tests
kdy1 Oct 27, 2023
39bd773
Fix some tests
kdy1 Oct 27, 2023
271fbb9
Fix some tests
kdy1 Oct 27, 2023
eee04dc
Fix some tests
kdy1 Oct 27, 2023
645e0c0
Fix some tests
kdy1 Oct 27, 2023
bcccedb
Fix some tests
kdy1 Oct 27, 2023
9654e72
Rename
kdy1 Oct 27, 2023
8e0aaf1
Rename
kdy1 Oct 27, 2023
7b79570
Fix some tests
kdy1 Oct 27, 2023
cea1f9c
Fix some tests
kdy1 Oct 27, 2023
2c77b21
Fix some tests
kdy1 Oct 27, 2023
ab5b779
Fix some tests
kdy1 Oct 27, 2023
67e9f35
Fix some tests
kdy1 Oct 27, 2023
2c50746
Fix some tests
kdy1 Oct 27, 2023
b805cf2
Fix some tests
kdy1 Oct 27, 2023
2fb2904
Fix some tests
kdy1 Oct 27, 2023
5d61615
Fix some tests
kdy1 Oct 27, 2023
ba3c276
Fix some tests
kdy1 Oct 27, 2023
42aa106
Fix some tests
kdy1 Oct 27, 2023
bf315b9
Fix some tests
kdy1 Oct 27, 2023
ce7d526
Fix some tests
kdy1 Oct 27, 2023
a286965
Fix some tests
kdy1 Oct 27, 2023
84f6afc
Fix some tests
kdy1 Oct 27, 2023
27612bb
Fix some tests
kdy1 Oct 27, 2023
5a09807
Fix some tests
kdy1 Oct 27, 2023
e99057d
Fix some tests
kdy1 Oct 27, 2023
44c51ab
Fix some tests
kdy1 Oct 27, 2023
ca8fab5
Fix some tests
kdy1 Oct 27, 2023
6f80161
Fix some tests
kdy1 Oct 27, 2023
5400f4c
Fix some tests
kdy1 Oct 27, 2023
ebe7480
let unresolved_mark = Mark::new();
kdy1 Oct 27, 2023
2679043
let unresolved_mark = Mark::new();
kdy1 Oct 27, 2023
2d543cb
let unresolved_mark = Mark::new();
kdy1 Oct 27, 2023
bc79073
Fix `swc`
kdy1 Oct 27, 2023
221d92c
let unresolved_mark = Mark::new();
kdy1 Oct 27, 2023
7906671
let unresolved_mark = Mark::new();
kdy1 Oct 27, 2023
9bb49a8
let unresolved_mark = Mark::new();
kdy1 Oct 27, 2023
7771b7b
Fix more
kdy1 Oct 27, 2023
dd2783b
Fix more
kdy1 Oct 27, 2023
a10084d
loose
kdy1 Oct 27, 2023
ec30e27
loose
kdy1 Oct 27, 2023
361e9ef
Update test refs
kdy1 Oct 27, 2023
58563b9
Update test refs
kdy1 Oct 27, 2023
014425b
no regression
kdy1 Oct 27, 2023
6a4da37
Update test refs
kdy1 Oct 27, 2023
7772e14
Fix more
kdy1 Oct 28, 2023
a708e7b
Fix more
kdy1 Oct 28, 2023
a88ea3d
Fix more
kdy1 Oct 28, 2023
1e57f4c
Fix more
kdy1 Oct 28, 2023
72be99a
Fix more
kdy1 Oct 28, 2023
1422a53
Fix more
kdy1 Oct 28, 2023
ad6c14b
Fix more
kdy1 Oct 28, 2023
df04e7f
Fix more
kdy1 Oct 28, 2023
efecbd3
Fix more
kdy1 Oct 28, 2023
419cf09
Update test refs
kdy1 Oct 29, 2023
85da7f5
Update test refs
kdy1 Oct 29, 2023
3013d85
Update test refs
kdy1 Oct 30, 2023
e198f2d
Add a test
kdy1 Oct 30, 2023
7c2071f
Change order
kdy1 Oct 30, 2023
a05a045
`this` to opt chain
kdy1 Oct 30, 2023
f433157
Update test refs
kdy1 Oct 30, 2023
76c85cb
Update test refs
kdy1 Oct 30, 2023
721d78a
`is_private_access`
kdy1 Oct 30, 2023
d8cbdb1
Update test refs
kdy1 Oct 30, 2023
dcc3aa9
Merge branch 'main' into issue-7561
kdy1 Nov 2, 2023
fb3ddbd
Merge branch 'main' into issue-7561
swc-bot Nov 2, 2023
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 3 additions & 1 deletion crates/swc/src/builder.rs
Original file line number Diff line number Diff line change
Expand Up @@ -223,8 +223,10 @@ impl<'a, 'b, P: swc_ecma_visit::Fold> PassBuilder<'a, 'b, P> {
set_public_fields: assumptions.set_public_class_fields,
no_document_all: assumptions.no_document_all,
static_blocks_mark: Mark::new(),
pure_getter: assumptions.pure_getters,
}
}
},
self.unresolved_mark
),
should_enable(self.target, EsVersion::Es2022)
),
Expand Down
19 changes: 19 additions & 0 deletions crates/swc/tests/fixture/issues-7xxx/7561/es2019/input/.swcrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
{
"jsc": {
"parser": {
"syntax": "ecmascript",
"jsx": false
},
"target": "es2019",
"loose": false,
"minify": {
"compress": false,
"mangle": false
}
},
"module": {
"type": "commonjs"
},
"minify": false,
"isModule": false
}
7 changes: 7 additions & 0 deletions crates/swc/tests/fixture/issues-7xxx/7561/es2019/input/1.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
class Foo {
#x;

test() {
this?.y.#x
}
}
15 changes: 15 additions & 0 deletions crates/swc/tests/fixture/issues-7xxx/7561/es2019/output/1.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
var _class_private_field_get = require("@swc/helpers/_/_class_private_field_get");
var _class_private_field_init = require("@swc/helpers/_/_class_private_field_init");
var _x = /*#__PURE__*/ new WeakMap();
class Foo {
test() {
var _this, _this_y;
Copy link
Member Author

Choose a reason for hiding this comment

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

This is not ideal

Copy link
Member Author

Choose a reason for hiding this comment

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

@jridgewell But let's fix correctness issues first.

(_this = this) === null || _this === void 0 ? void 0 : _class_private_field_get._(_this_y = _this.y, _x);
}
constructor(){
_class_private_field_init._(this, _x, {
writable: true,
value: void 0
});
}
}
19 changes: 19 additions & 0 deletions crates/swc/tests/fixture/issues-7xxx/7561/es2021/input/.swcrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
{
"jsc": {
"parser": {
"syntax": "ecmascript",
"jsx": false
},
"target": "es2021",
"loose": false,
"minify": {
"compress": false,
"mangle": false
}
},
"module": {
"type": "commonjs"
},
"minify": false,
"isModule": false
}
7 changes: 7 additions & 0 deletions crates/swc/tests/fixture/issues-7xxx/7561/es2021/input/1.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
class Foo {
#x;

test() {
this?.y.#x
}
}
15 changes: 15 additions & 0 deletions crates/swc/tests/fixture/issues-7xxx/7561/es2021/output/1.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
var _class_private_field_get = require("@swc/helpers/_/_class_private_field_get");
var _class_private_field_init = require("@swc/helpers/_/_class_private_field_init");
var _x = /*#__PURE__*/ new WeakMap();
class Foo {
test() {
var _this, _this_y;
(_this = this) === null || _this === void 0 ? void 0 : _class_private_field_get._(_this_y = _this.y, _x);
}
constructor(){
_class_private_field_init._(this, _x, {
writable: true,
value: void 0
});
}
}
19 changes: 19 additions & 0 deletions crates/swc/tests/fixture/issues-7xxx/7561/es2022/input/.swcrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
{
"jsc": {
"parser": {
"syntax": "ecmascript",
"jsx": false
},
"target": "es2022",
"loose": false,
"minify": {
"compress": false,
"mangle": false
}
},
"module": {
"type": "commonjs"
},
"minify": false,
"isModule": false
}
7 changes: 7 additions & 0 deletions crates/swc/tests/fixture/issues-7xxx/7561/es2022/input/1.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
class Foo {
#x;

test() {
this?.y.#x
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
class Foo {
#x;
test() {
this?.y.#x;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,9 @@ import { _ as _class_private_field_set } from "@swc/helpers/_/_class_private_fie
var _fieldFunc = /*#__PURE__*/ new WeakMap(), _fieldFunc2 = /*#__PURE__*/ new WeakMap();
class A {
test() {
var _class_private_field_get1;
var _this_getInstance;
var _this, _this1, _ref, _this_getInstance;
Copy link
Member Author

Choose a reason for hiding this comment

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

Previous output seems wrong

_class_private_field_get(this, _fieldFunc).call(this);
(_class_private_field_get1 = _class_private_field_get(this, _fieldFunc)) === null || _class_private_field_get1 === void 0 ? void 0 : _class_private_field_get1.call(this);
(_this = _class_private_field_get(_ref = _this1 = this, _fieldFunc)) === null || _this === void 0 ? void 0 : _this.call(_this1);
const func = _class_private_field_get(this, _fieldFunc);
func();
new (_class_private_field_get(this, _fieldFunc))();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,9 @@
import { _ as _class_static_private_field_spec_get } from "@swc/helpers/_/_class_static_private_field_spec_get";
class A {
test() {
var _class_static_private_field_spec_get1;
var _this;
_class_static_private_field_spec_get(A, A, _fieldFunc).call(A);
(_class_static_private_field_spec_get1 = _class_static_private_field_spec_get(A, A, _fieldFunc)) === null || _class_static_private_field_spec_get1 === void 0 ? void 0 : _class_static_private_field_spec_get1.call(A);
(_this = _class_static_private_field_spec_get(A, A, _fieldFunc)) === null || _this === void 0 ? void 0 : _this.call(A);
const func = _class_static_private_field_spec_get(A, A, _fieldFunc);
func();
new (_class_static_private_field_spec_get(A, A, _fieldFunc))();
Expand Down
1 change: 1 addition & 0 deletions crates/swc_ecma_compat_es2020/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ serde = { version = "1.0.188", features = ["derive"] }
swc_atoms = { version = "0.6.0", path = "../swc_atoms" }
swc_common = { version = "0.33.2", path = "../swc_common" }
swc_ecma_ast = { version = "0.110.2", path = "../swc_ecma_ast" }
swc_ecma_compat_es2022 = { version = "0.1.9", path = "../swc_ecma_compat_es2022" }
swc_ecma_transforms_base = { version = "0.134.13", path = "../swc_ecma_transforms_base" }
swc_ecma_utils = { version = "0.124.11", path = "../swc_ecma_utils" }
swc_ecma_visit = { version = "0.96.2", path = "../swc_ecma_visit" }
Expand Down
Loading
Loading