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 protoInit call injection timing #16235

Merged
merged 2 commits into from Jan 26, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
Expand Up @@ -1138,20 +1138,20 @@ function transformClass(
if (element.node) {
element.node.decorators = null;
}
}

if (
fieldInitializerAssignments.length > 0 &&
!isStatic &&
(kind === FIELD || kind === ACCESSOR)
) {
prependExpressionsToFieldInitializer(
fieldInitializerAssignments,
element as NodePath<
t.ClassProperty | t.ClassPrivateProperty | t.ClassAccessorProperty
>,
);
fieldInitializerAssignments = [];
}
if (
fieldInitializerAssignments.length > 0 &&
!isStatic &&
(kind === FIELD || kind === ACCESSOR)
) {
prependExpressionsToFieldInitializer(
fieldInitializerAssignments,
element as NodePath<
t.ClassProperty | t.ClassPrivateProperty | t.ClassAccessorProperty
>,
);
fieldInitializerAssignments = [];
}
}
}
Expand Down
Expand Up @@ -7,8 +7,7 @@ class Foo {
get: _get_a,
set: void 0
});
babelHelpers.defineProperty(this, "value", 1);
_initProto(this);
babelHelpers.defineProperty(this, "value", (_initProto(this), 1));
}
getA() {
return babelHelpers.classPrivateFieldGet(this, _a);
Expand Down
Expand Up @@ -2,8 +2,7 @@ var _initProto, _Foo;
const dec = () => {};
class Foo {
constructor() {
babelHelpers.defineProperty(this, "value", 1);
_initProto(this);
babelHelpers.defineProperty(this, "value", (_initProto(this), 1));
}
get a() {
return this.value;
Expand Down
Expand Up @@ -7,8 +7,7 @@ class Foo {
get: _get_a,
set: _set_a
});
babelHelpers.defineProperty(this, "value", 1);
_initProto(this);
babelHelpers.defineProperty(this, "value", (_initProto(this), 1));
}
getA() {
return babelHelpers.classPrivateFieldGet(this, _a);
Expand Down
Expand Up @@ -2,8 +2,7 @@ var _initProto, _Foo;
const dec = () => {};
class Foo {
constructor() {
babelHelpers.defineProperty(this, "value", 1);
_initProto(this);
babelHelpers.defineProperty(this, "value", (_initProto(this), 1));
}
get a() {
return this.value;
Expand Down
Expand Up @@ -8,10 +8,7 @@ class Foo {
this.value = v;
}]], []);
}
constructor() {
_initProto(this);
}
value = 1;
value = (_initProto(this), 1);
get #a() {
return _call_a(this);
}
Expand Down
Expand Up @@ -4,10 +4,7 @@ class Foo {
static {
[_initProto] = babelHelpers.applyDecs(this, [[dec, 3, "a"], [dec, 4, "a"], [dec, 3, 'b'], [dec, 4, 'b']], []);
}
constructor() {
_initProto(this);
}
value = 1;
value = (_initProto(this), 1);
get a() {
return this.value;
}
Expand Down
Expand Up @@ -6,10 +6,7 @@ class Foo {
return this.value;
}]], []);
}
constructor() {
_initProto(this);
}
value = 1;
value = (_initProto(this), 1);
get #a() {
return _call_a(this);
}
Expand Down
Expand Up @@ -4,10 +4,7 @@ class Foo {
static {
[_initProto] = babelHelpers.applyDecs(this, [[dec, 3, "a"], [dec, 3, 'b']], []);
}
constructor() {
_initProto(this);
}
value = 1;
value = (_initProto(this), 1);
get a() {
return this.value;
}
Expand Down
Expand Up @@ -7,8 +7,7 @@ class Foo {
writable: true,
value: _call_a
});
babelHelpers.defineProperty(this, "value", 1);
_initProto(this);
babelHelpers.defineProperty(this, "value", (_initProto(this), 1));
}
callA() {
return babelHelpers.classPrivateFieldGet(this, _a).call(this);
Expand Down
Expand Up @@ -2,8 +2,7 @@ var _initProto, _Foo;
const dec = () => {};
class Foo {
constructor() {
babelHelpers.defineProperty(this, "value", 1);
_initProto(this);
babelHelpers.defineProperty(this, "value", (_initProto(this), 1));
}
a() {
return this.value;
Expand Down
Expand Up @@ -6,11 +6,8 @@ class Foo {
return this.value;
}]], []);
}
constructor() {
_initProto(this);
}
#a = _call_a;
value = 1;
value = (_initProto(this), 1);
callA() {
return this.#a();
}
Expand Down
Expand Up @@ -4,10 +4,7 @@ class Foo {
static {
[_initProto] = babelHelpers.applyDecs(this, [[dec, 2, "a"], [dec, 2, 'b']], []);
}
constructor() {
_initProto(this);
}
value = 1;
value = (_initProto(this), 1);
a() {
return this.value;
}
Expand Down
Expand Up @@ -11,9 +11,8 @@ class Foo {
constructor() {
babelHelpers.classPrivateFieldInitSpec(this, _a, {
writable: true,
value: void 0
value: void _initProto(this)
});
_initProto(this);
}
method() {}
makeClass() {
Expand Down
Expand Up @@ -76,12 +76,12 @@
[_initProto3] = babelHelpers.applyDecs(this, [[dec, 2, "method"]], []);
}
constructor() {
log.push(_initProto3(super(6)).method());
log.push(super(6).method());
}
method() {
return this.a;
}
[_computedKey];
[_computedKey] = void _initProto3(this);
}
new A();
}
Expand Down
Expand Up @@ -10,10 +10,7 @@ class Foo {
static {
[_initProto, _Foo, _initClass] = babelHelpers.applyDecs(this, [[[dec, _dec, _dec2, _dec3, _dec4], 2, "method"]], _classDecs);
}
constructor() {
_initProto(this);
}
#a;
#a = void _initProto(this);
method() {}
makeClass() {
var _dec5, _init_bar;
Expand Down
Expand Up @@ -7,8 +7,7 @@ class Foo {
get: void 0,
set: _set_a
});
babelHelpers.defineProperty(this, "value", 1);
_initProto(this);
babelHelpers.defineProperty(this, "value", (_initProto(this), 1));
}
setA(v) {
babelHelpers.classPrivateFieldSet(this, _a, v);
Expand Down
Expand Up @@ -2,8 +2,7 @@ var _initProto, _Foo;
const dec = () => {};
class Foo {
constructor() {
babelHelpers.defineProperty(this, "value", 1);
_initProto(this);
babelHelpers.defineProperty(this, "value", (_initProto(this), 1));
}
set a(v) {
return this.value = v;
Expand Down
Expand Up @@ -6,10 +6,7 @@ class Foo {
return this.value = v;
}]], []);
}
constructor() {
_initProto(this);
}
value = 1;
value = (_initProto(this), 1);
set #a(v) {
_call_a(this, v);
}
Expand Down
Expand Up @@ -4,10 +4,7 @@ class Foo {
static {
[_initProto] = babelHelpers.applyDecs(this, [[dec, 4, "a"], [dec, 4, 'b']], []);
}
constructor() {
_initProto(this);
}
value = 1;
value = (_initProto(this), 1);
set a(v) {
return this.value = v;
}
Expand Down
Expand Up @@ -7,8 +7,7 @@ class Foo {
get: _get_a,
set: void 0
});
babelHelpers.defineProperty(this, "value", 1);
_initProto(this);
babelHelpers.defineProperty(this, "value", (_initProto(this), 1));
}
getA() {
return babelHelpers.classPrivateFieldGet(this, _a);
Expand Down
Expand Up @@ -2,8 +2,7 @@ var _initProto, _Foo;
const dec = () => {};
class Foo {
constructor() {
babelHelpers.defineProperty(this, "value", 1);
_initProto(this);
babelHelpers.defineProperty(this, "value", (_initProto(this), 1));
}
get a() {
return this.value;
Expand Down
Expand Up @@ -7,8 +7,7 @@ class Foo {
get: _get_a,
set: _set_a
});
babelHelpers.defineProperty(this, "value", 1);
_initProto(this);
babelHelpers.defineProperty(this, "value", (_initProto(this), 1));
}
getA() {
return babelHelpers.classPrivateFieldGet(this, _a);
Expand Down
Expand Up @@ -2,8 +2,7 @@ var _initProto, _Foo;
const dec = () => {};
class Foo {
constructor() {
babelHelpers.defineProperty(this, "value", 1);
_initProto(this);
babelHelpers.defineProperty(this, "value", (_initProto(this), 1));
}
get a() {
return this.value;
Expand Down
Expand Up @@ -8,10 +8,7 @@ class Foo {
this.value = v;
}]], []).e;
}
constructor() {
_initProto(this);
}
value = 1;
value = (_initProto(this), 1);
get #a() {
return _call_a(this);
}
Expand Down
Expand Up @@ -4,10 +4,7 @@ class Foo {
static {
[_initProto] = babelHelpers.applyDecs2203R(this, [[dec, 3, "a"], [dec, 4, "a"], [dec, 3, 'b'], [dec, 4, 'b']], []).e;
}
constructor() {
_initProto(this);
}
value = 1;
value = (_initProto(this), 1);
get a() {
return this.value;
}
Expand Down
Expand Up @@ -6,10 +6,7 @@ class Foo {
return this.value;
}]], []).e;
}
constructor() {
_initProto(this);
}
value = 1;
value = (_initProto(this), 1);
get #a() {
return _call_a(this);
}
Expand Down
Expand Up @@ -4,10 +4,7 @@ class Foo {
static {
[_initProto] = babelHelpers.applyDecs2203R(this, [[dec, 3, "a"], [dec, 3, 'b']], []).e;
}
constructor() {
_initProto(this);
}
value = 1;
value = (_initProto(this), 1);
get a() {
return this.value;
}
Expand Down
Expand Up @@ -7,8 +7,7 @@ class Foo {
writable: true,
value: _call_a
});
babelHelpers.defineProperty(this, "value", 1);
_initProto(this);
babelHelpers.defineProperty(this, "value", (_initProto(this), 1));
}
callA() {
return babelHelpers.classPrivateFieldGet(this, _a).call(this);
Expand Down
Expand Up @@ -2,8 +2,7 @@ var _initProto, _Foo;
const dec = () => {};
class Foo {
constructor() {
babelHelpers.defineProperty(this, "value", 1);
_initProto(this);
babelHelpers.defineProperty(this, "value", (_initProto(this), 1));
}
a() {
return this.value;
Expand Down
Expand Up @@ -6,11 +6,8 @@ class Foo {
return this.value;
}]], []).e;
}
constructor() {
_initProto(this);
}
#a = _call_a;
value = 1;
value = (_initProto(this), 1);
callA() {
return this.#a();
}
Expand Down
Expand Up @@ -4,10 +4,7 @@ class Foo {
static {
[_initProto] = babelHelpers.applyDecs2203R(this, [[dec, 2, "a"], [dec, 2, 'b']], []).e;
}
constructor() {
_initProto(this);
}
value = 1;
value = (_initProto(this), 1);
a() {
return this.value;
}
Expand Down
Expand Up @@ -71,7 +71,7 @@
_computedKey = babelHelpers.toPropertyKey((key = super(5).method(), log.push(key), key));
class A extends B {
constructor() {
log.push(_initProto3((super(6), babelHelpers.defineProperty(this, _computedKey, void 0))).method());
log.push((super(6), babelHelpers.defineProperty(this, _computedKey, void _initProto3(this))).method());
}
method() {
return this.a;
Expand Down