feat(es/compat): Simplify static blocks in classes (#7056)

This commit is contained in:
magic-akari 2023-03-11 08:30:49 +08:00 committed by GitHub
parent d4ebb5e6ef
commit b78ce8b7c2
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
46 changed files with 675 additions and 1145 deletions

View File

@ -221,7 +221,8 @@ impl<'a, 'b, P: swc_ecma_visit::Fold> PassBuilder<'a, 'b, P> {
private_as_properties: assumptions.private_fields_as_properties,
constant_super: assumptions.constant_super,
set_public_fields: assumptions.set_public_class_fields,
no_document_all: assumptions.no_document_all
no_document_all: assumptions.no_document_all,
static_blocks_mark: Mark::new(),
}
}
),

View File

@ -2,10 +2,7 @@
const a = 2;
class C {
}
var __ = {
writable: true,
value: (()=>{
const a = 1;
a;
})()
};
(()=>{
const a = 1;
a;
})();

View File

@ -5,10 +5,7 @@ var C = function C() {
"use strict";
_class_call_check(this, C);
};
var __ = {
writable: true,
value: function() {
var a = 1;
a;
}()
};
(function() {
var a = 1;
a;
})();

View File

@ -8,24 +8,18 @@ function f() {
const b1 = 22;
class C1 {
}
var __ = {
writable: true,
value: (()=>{
var a1 = 111;
var a2 = 111;
const b1 = 222;
const b2 = 222;
})()
};
}
class C2 {
}
var __ = {
writable: true,
value: (()=>{
(()=>{
var a1 = 111;
var a2 = 111;
const b1 = 222;
const b2 = 222;
})()
};
})();
}
class C2 {
}
(()=>{
var a1 = 111;
var a2 = 111;
const b1 = 222;
const b2 = 222;
})();

View File

@ -11,26 +11,20 @@ function f() {
"use strict";
_class_call_check(this, C1);
};
var __ = {
writable: true,
value: function() {
var a1 = 111;
var a2 = 111;
var b1 = 222;
var b2 = 222;
}()
};
(function() {
var a1 = 111;
var a2 = 111;
var b1 = 222;
var b2 = 222;
})();
}
var C2 = function C2() {
"use strict";
_class_call_check(this, C2);
};
var __ = {
writable: true,
value: function() {
var a1 = 111;
var a2 = 111;
var b1 = 222;
var b2 = 222;
}()
};
(function() {
var a1 = 111;
var a2 = 111;
var b1 = 222;
var b2 = 222;
})();

View File

@ -13,10 +13,7 @@ class C {
_class_private_field_set(this, _x, x);
}
}
var __ = {
writable: true,
value: (()=>{
// getX has privileged access to #x
getX = (obj)=>_class_private_field_get(obj, _x);
})()
};
(()=>{
// getX has privileged access to #x
getX = (obj)=>_class_private_field_get(obj, _x);
})();

View File

@ -6,9 +6,6 @@ var _x = {
writable: true,
value: 1
};
var __ = {
writable: true,
value: (()=>{
_class_static_private_field_spec_get(C, C, _x);
})()
};
(()=>{
_class_static_private_field_spec_get(C, C, _x);
})();

View File

@ -9,9 +9,6 @@ var _x = {
writable: true,
value: 123
};
var __ = {
writable: true,
value: (()=>{
console.log(_class_static_private_field_spec_get(C, C, _x));
})()
};
(()=>{
console.log(_class_static_private_field_spec_get(C, C, _x));
})();

View File

@ -13,27 +13,9 @@ var __5 = {
writable: true,
value: 1
};
var __ = {
writable: true,
value: (()=>{})()
};
var __2 = {
writable: true,
value: (()=>{})()
};
var __4 = {
writable: true,
value: (()=>{})()
};
var __6 = {
writable: true,
value: (()=>{})()
};
var __7 = {
writable: true,
value: (()=>{})()
};
var __8 = {
writable: true,
value: (()=>{})()
};
(()=>{})();
(()=>{})();
(()=>{})();
(()=>{})();
(()=>{})();
(()=>{})();

View File

@ -14,28 +14,10 @@ var __5 = {
writable: true,
value: 5
};
var __ = {
writable: true,
value: (()=>{})()
};
var __2 = {
writable: true,
value: (()=>{})()
};
var __4 = {
writable: true,
value: (()=>{})()
};
var __6 = {
writable: true,
value: (()=>{})()
};
var __7 = {
writable: true,
value: (()=>{})()
};
var __8 = {
writable: true,
value: (()=>{})()
};
(()=>{})();
(()=>{})();
(()=>{})();
(()=>{})();
(()=>{})();
(()=>{})();
console.log(_C__1);

View File

@ -16,19 +16,16 @@ class A {
_class_private_field_set(this, _x, v);
}
}
var __ = {
writable: true,
value: (()=>{
friendA = {
getX (obj) {
return _class_private_field_get(obj, _x);
},
setX (obj, value) {
_class_private_field_set(obj, _x, value);
}
};
})()
};
(()=>{
friendA = {
getX (obj) {
return _class_private_field_get(obj, _x);
},
setX (obj, value) {
_class_private_field_set(obj, _x, value);
}
};
})();
class B {
constructor(a){
const x = friendA.getX(a); // ok

View File

@ -1,18 +1,12 @@
//// [classStaticBlock18.ts]
function foo() {
var _class, __;
var _class;
return _class = class {
}, _class.foo = 1, __ = {
writable: true,
value: (()=>{
var _class, __;
const c = (_class = class {
}, _class.bar = 2, __ = {
writable: true,
value: (()=>{
// do
})()
}, _class);
})()
}, _class;
}, _class.foo = 1, (()=>{
var _class;
const c = (_class = class {
}, _class.bar = 2, (()=>{
// do
})(), _class);
})(), _class;
}

View File

@ -1,23 +1,17 @@
//// [classStaticBlock18.ts]
import _class_call_check from "@swc/helpers/src/_class_call_check.mjs";
function foo() {
var _class, __;
var _class;
return _class = function _class() {
"use strict";
_class_call_check(this, _class);
}, _class.foo = 1, __ = {
writable: true,
value: function() {
var _class, __;
var c = (_class = function _class() {
"use strict";
_class_call_check(this, _class);
}, _class.bar = 2, __ = {
writable: true,
value: function() {
// do
}()
}, _class);
}()
}, _class;
}, _class.foo = 1, function() {
var _class;
var c = (_class = function _class() {
"use strict";
_class_call_check(this, _class);
}, _class.bar = 2, function() {
// do
}(), _class);
}(), _class;
}

View File

@ -3,19 +3,13 @@ const a = 1;
const b = 2;
class C {
}
var __ = {
writable: true,
value: (()=>{
const a = 11;
a;
b;
})()
};
var __1 = {
writable: true,
value: (()=>{
const a = 11;
a;
b;
})()
};
(()=>{
const a = 11;
a;
b;
})();
(()=>{
const a = 11;
a;
b;
})();

View File

@ -6,19 +6,13 @@ var C = function C() {
"use strict";
_class_call_check(this, C);
};
var __ = {
writable: true,
value: function() {
var a = 11;
a;
b;
}()
};
var __1 = {
writable: true,
value: function() {
var a = 11;
a;
b;
}()
};
(function() {
var a = 11;
a;
b;
})();
(function() {
var a = 11;
a;
b;
})();

View File

@ -4,9 +4,6 @@ var C = function C() {
"use strict";
_class_call_check(this, C);
};
var __ = {
writable: true,
value: function() {
// something
}()
};
(function() {
// something
})();

View File

@ -19,10 +19,7 @@ define([
"use strict";
_classCallCheck(this, C);
};
var __ = {
writable: true,
value: function() {
C.x = 1;
}()
};
(function() {
C.x = 1;
})();
});

View File

@ -14,9 +14,6 @@ var C = function C() {
"use strict";
_classCallCheck(this, C);
};
var __ = {
writable: true,
value: function() {
C.x = 1;
}()
};
(function() {
C.x = 1;
})();

View File

@ -4,9 +4,6 @@ export var C = function C() {
"use strict";
_class_call_check(this, C);
};
var __ = {
writable: true,
value: function() {
C.x = 1;
}()
};
(function() {
C.x = 1;
})();

View File

@ -3,7 +3,7 @@ System.register([
"@swc/helpers/src/_class_call_check.mjs"
], function(_export, _context) {
"use strict";
var _class_call_check, C, __;
var _class_call_check, C;
return {
setters: [
function(_classCallCheck) {
@ -15,12 +15,9 @@ System.register([
"use strict";
_class_call_check(this, C);
});
__ = {
writable: true,
value: function() {
C.x = 1;
}()
};
(function() {
C.x = 1;
})();
}
};
});

View File

@ -22,10 +22,7 @@
"use strict";
_classCallCheck(this, C);
};
var __ = {
writable: true,
value: function() {
C.x = 1;
}()
};
(function() {
C.x = 1;
})();
});

View File

@ -1,26 +1,17 @@
//// [classStaticBlock27.ts]
// https://github.com/microsoft/TypeScript/issues/44872
import _class_call_check from "@swc/helpers/src/_class_call_check.mjs";
var _Foo, __, __1, __2;
var _Foo;
void (_Foo = function Foo() {
"use strict";
_class_call_check(this, Foo);
}, _Foo.prop = 1, __ = {
writable: true,
value: function() {
console.log(_Foo.prop);
_Foo.prop++;
}()
}, __1 = {
writable: true,
value: function() {
console.log(_Foo.prop);
_Foo.prop++;
}()
}, __2 = {
writable: true,
value: function() {
console.log(_Foo.prop);
_Foo.prop++;
}()
}, _Foo);
}, _Foo.prop = 1, function() {
console.log(_Foo.prop);
_Foo.prop++;
}(), function() {
console.log(_Foo.prop);
_Foo.prop++;
}(), function() {
console.log(_Foo.prop);
_Foo.prop++;
}(), _Foo);

View File

@ -5,10 +5,7 @@ var C = function C() {
"use strict";
_class_call_check(this, C);
};
var __ = {
writable: true,
value: function() {
foo = 1;
}()
};
(function() {
foo = 1;
})();
console.log(foo);

View File

@ -9,11 +9,8 @@ class C extends B {
}
C.b = 3;
C.c = _get(_get_prototype_of(C), "a", C);
var __ = {
writable: true,
value: (()=>{
C.b;
_get(_get_prototype_of(C), "b", C);
_get(_get_prototype_of(C), "a", C);
})()
};
(()=>{
C.b;
_get(_get_prototype_of(C), "b", C);
_get(_get_prototype_of(C), "a", C);
})();

View File

@ -22,11 +22,8 @@ var C = /*#__PURE__*/ function(B) {
}(B);
C.b = 3;
C.c = _get(_get_prototype_of(C), "a", C);
var __ = {
writable: true,
value: function() {
C.b;
_get(_get_prototype_of(C), "b", C);
_get(_get_prototype_of(C), "a", C);
}()
};
(function() {
C.b;
_get(_get_prototype_of(C), "b", C);
_get(_get_prototype_of(C), "a", C);
})();

View File

@ -2,10 +2,7 @@
class A {
}
A.bar = A.foo + 1;
var __ = {
writable: true,
value: (()=>{
A.foo + 2;
})()
};
(()=>{
A.foo + 2;
})();
A.foo = 1;

View File

@ -5,10 +5,7 @@ var A = function A() {
_class_call_check(this, A);
};
A.bar = A.foo + 1;
var __ = {
writable: true,
value: function() {
A.foo + 2;
}()
};
(function() {
A.foo + 2;
})();
A.foo = 1;

View File

@ -10,33 +10,24 @@ var A = /*#__PURE__*/ function() {
};
return A;
}();
var __ = {
writable: true,
value: function() {
A.doSomething(); // should not error
}()
};
(function() {
A.doSomething(); // should not error
})();
var Baz = function Baz() {
"use strict";
_class_call_check(this, Baz);
};
var __1 = {
writable: true,
value: function() {
console.log(FOO); // should error
}()
};
(function() {
console.log(FOO); // should error
})();
var FOO = "FOO";
var Bar = function Bar() {
"use strict";
_class_call_check(this, Bar);
};
var __2 = {
writable: true,
value: function() {
console.log(FOO); // should not error
}()
};
(function() {
console.log(FOO); // should not error
})();
var u = "FOO";
var CFA = /*#__PURE__*/ function() {
"use strict";
@ -46,18 +37,12 @@ var CFA = /*#__PURE__*/ function() {
CFA.doSomething = function doSomething() {};
return CFA;
}();
var __3 = {
writable: true,
value: function() {
u = "BAR";
u; // should be "BAR"
}()
};
(function() {
u = "BAR";
u; // should be "BAR"
})();
CFA.t = 1;
var __11 = {
writable: true,
value: function() {
u; // should be "BAR"
}()
};
(function() {
u; // should be "BAR"
})();
u; // should be "BAR"

View File

@ -65,93 +65,60 @@ C._ = [
_get(_get_prototype_of(C), "w", C).call(C);
})()
];
var __ = {
writable: true,
value: (()=>{
var { Reflect } = {
Reflect: null
}; // collision (es2015-es2021 only)
_get(_get_prototype_of(C), "w", C).call(C);
})()
};
var __1 = {
writable: true,
value: (()=>{
var [Reflect] = [
null
]; // collision (es2015-es2021 only)
_get(_get_prototype_of(C), "w", C).call(C);
})()
};
var __2 = {
writable: true,
value: (()=>{
var Reflect; // collision (es2015-es2021 only)
_get(_get_prototype_of(C), "w", C).call(C);
})()
};
var __3 = {
writable: true,
value: (()=>{
class Reflect {
} // collision (es2015-es2021 only)
_get(_get_prototype_of(C), "w", C).call(C);
})()
};
var __4 = {
writable: true,
value: (()=>{
function Reflect() {} // collision (es2015-es2021 only)
_get(_get_prototype_of(C), "w", C).call(C);
})()
};
var __5 = {
writable: true,
value: (()=>{
let Reflect// collision (es2015-es2021 only)
;
(function(Reflect) {})(Reflect || (Reflect = {}));
_get(_get_prototype_of(C), "w", C).call(C);
})()
};
var __6 = {
writable: true,
value: (()=>{
let Reflect// collision (es2015-es2021 only)
;
(function(Reflect) {})(Reflect || (Reflect = {}));
_get(_get_prototype_of(C), "w", C).call(C);
})()
};
var __7 = {
writable: true,
value: (()=>{
_get(_get_prototype_of(C), "w", C).call(C);
})()
};
var __8 = {
writable: true,
value: (()=>{
_get(_get_prototype_of(C), "w", C).call(C);
})()
};
var __9 = {
writable: true,
value: (()=>{
(class Reflect {
} // no collision
);
_get(_get_prototype_of(C), "w", C).call(C);
})()
};
var __10 = {
writable: true,
value: (()=>{
(function Reflect() {} // no collision
);
_get(_get_prototype_of(C), "w", C).call(C);
})()
};
(()=>{
var { Reflect } = {
Reflect: null
}; // collision (es2015-es2021 only)
_get(_get_prototype_of(C), "w", C).call(C);
})();
(()=>{
var [Reflect] = [
null
]; // collision (es2015-es2021 only)
_get(_get_prototype_of(C), "w", C).call(C);
})();
(()=>{
var Reflect; // collision (es2015-es2021 only)
_get(_get_prototype_of(C), "w", C).call(C);
})();
(()=>{
class Reflect {
} // collision (es2015-es2021 only)
_get(_get_prototype_of(C), "w", C).call(C);
})();
(()=>{
function Reflect() {} // collision (es2015-es2021 only)
_get(_get_prototype_of(C), "w", C).call(C);
})();
(()=>{
let Reflect// collision (es2015-es2021 only)
;
(function(Reflect) {})(Reflect || (Reflect = {}));
_get(_get_prototype_of(C), "w", C).call(C);
})();
(()=>{
let Reflect// collision (es2015-es2021 only)
;
(function(Reflect) {})(Reflect || (Reflect = {}));
_get(_get_prototype_of(C), "w", C).call(C);
})();
(()=>{
_get(_get_prototype_of(C), "w", C).call(C);
})();
(()=>{
_get(_get_prototype_of(C), "w", C).call(C);
})();
(()=>{
(class Reflect {
} // no collision
);
_get(_get_prototype_of(C), "w", C).call(C);
})();
(()=>{
(function Reflect() {} // no collision
);
_get(_get_prototype_of(C), "w", C).call(C);
})();
export { };
//// [varInContainingScopeStaticField1.ts]
import _get from "@swc/helpers/src/_get.mjs";
@ -187,12 +154,9 @@ import _get_prototype_of from "@swc/helpers/src/_get_prototype_of.mjs";
var Reflect = null; // collision (es2015-es2021 only)
class C extends B {
}
var __ = {
writable: true,
value: (()=>{
_get(_get_prototype_of(C), "w", C).call(C);
})()
};
(()=>{
_get(_get_prototype_of(C), "w", C).call(C);
})();
export { };
//// [varInContainingScopeStaticBlock2.ts]
import _get from "@swc/helpers/src/_get.mjs";
@ -202,12 +166,9 @@ var { Reflect } = {
}; // collision (es2015-es2021 only)
class C extends B {
}
var __ = {
writable: true,
value: (()=>{
_get(_get_prototype_of(C), "w", C).call(C);
})()
};
(()=>{
_get(_get_prototype_of(C), "w", C).call(C);
})();
export { };
//// [varInContainingScopeStaticBlock3.ts]
import _get from "@swc/helpers/src/_get.mjs";
@ -217,12 +178,9 @@ var [Reflect] = [
]; // collision (es2015-es2021 only)
class C extends B {
}
var __ = {
writable: true,
value: (()=>{
_get(_get_prototype_of(C), "w", C).call(C);
})()
};
(()=>{
_get(_get_prototype_of(C), "w", C).call(C);
})();
export { };
//// [classDeclInContainingScopeStaticField.ts]
import _get from "@swc/helpers/src/_get.mjs";
@ -240,12 +198,9 @@ class Reflect {
} // collision (es2015-es2021 only)
class C extends B {
}
var __ = {
writable: true,
value: (()=>{
_get(_get_prototype_of(C), "w", C).call(C);
})()
};
(()=>{
_get(_get_prototype_of(C), "w", C).call(C);
})();
export { };
//// [funcDeclInContainingScopeStaticField.ts]
import _get from "@swc/helpers/src/_get.mjs";
@ -261,12 +216,9 @@ import _get_prototype_of from "@swc/helpers/src/_get_prototype_of.mjs";
function Reflect() {} // collision (es2015-es2021 only)
class C extends B {
}
var __ = {
writable: true,
value: (()=>{
_get(_get_prototype_of(C), "w", C).call(C);
})()
};
(()=>{
_get(_get_prototype_of(C), "w", C).call(C);
})();
export { };
//// [valueNamespaceInContainingScopeStaticField.ts]
import _get from "@swc/helpers/src/_get.mjs";
@ -280,12 +232,9 @@ import _get from "@swc/helpers/src/_get.mjs";
import _get_prototype_of from "@swc/helpers/src/_get_prototype_of.mjs";
class C extends B {
}
var __ = {
writable: true,
value: (()=>{
_get(_get_prototype_of(C), "w", C).call(C);
})()
};
(()=>{
_get(_get_prototype_of(C), "w", C).call(C);
})();
export { };
//// [enumInContainingScopeStaticField.ts]
import _get from "@swc/helpers/src/_get.mjs";
@ -305,12 +254,9 @@ var Reflect// collision (es2015-es2021 only)
(function(Reflect) {})(Reflect || (Reflect = {}));
class C extends B {
}
var __ = {
writable: true,
value: (()=>{
_get(_get_prototype_of(C), "w", C).call(C);
})()
};
(()=>{
_get(_get_prototype_of(C), "w", C).call(C);
})();
export { };
//// [constEnumInContainingScopeStaticField.ts]
import _get from "@swc/helpers/src/_get.mjs";
@ -330,12 +276,9 @@ var Reflect// collision (es2015-es2021 only)
(function(Reflect) {})(Reflect || (Reflect = {}));
class C extends B {
}
var __ = {
writable: true,
value: (()=>{
_get(_get_prototype_of(C), "w", C).call(C);
})()
};
(()=>{
_get(_get_prototype_of(C), "w", C).call(C);
})();
export { };
//// [namespaceImportInContainingScopeStaticField.ts]
import _get from "@swc/helpers/src/_get.mjs";
@ -349,12 +292,9 @@ import _get from "@swc/helpers/src/_get.mjs";
import _get_prototype_of from "@swc/helpers/src/_get_prototype_of.mjs";
class C extends B {
}
var __ = {
writable: true,
value: (()=>{
_get(_get_prototype_of(C), "w", C).call(C);
})()
};
(()=>{
_get(_get_prototype_of(C), "w", C).call(C);
})();
export { };
//// [namedImportInContainingScopeStaticField.ts]
import _get from "@swc/helpers/src/_get.mjs";
@ -368,12 +308,9 @@ import _get from "@swc/helpers/src/_get.mjs";
import _get_prototype_of from "@swc/helpers/src/_get_prototype_of.mjs";
class C extends B {
}
var __ = {
writable: true,
value: (()=>{
_get(_get_prototype_of(C), "w", C).call(C);
})()
};
(()=>{
_get(_get_prototype_of(C), "w", C).call(C);
})();
export { };
//// [namedImportOfInterfaceInContainingScopeStaticField.ts]
import _get from "@swc/helpers/src/_get.mjs";
@ -387,12 +324,9 @@ import _get from "@swc/helpers/src/_get.mjs";
import _get_prototype_of from "@swc/helpers/src/_get_prototype_of.mjs";
class C extends B {
}
var __ = {
writable: true,
value: (()=>{
_get(_get_prototype_of(C), "w", C).call(C);
})()
};
(()=>{
_get(_get_prototype_of(C), "w", C).call(C);
})();
export { };
//// [namedImportOfUninstantiatedNamespaceInContainingScopeStaticField.ts]
import _get from "@swc/helpers/src/_get.mjs";
@ -406,12 +340,9 @@ import _get from "@swc/helpers/src/_get.mjs";
import _get_prototype_of from "@swc/helpers/src/_get_prototype_of.mjs";
class C extends B {
}
var __ = {
writable: true,
value: (()=>{
_get(_get_prototype_of(C), "w", C).call(C);
})()
};
(()=>{
_get(_get_prototype_of(C), "w", C).call(C);
})();
export { };
//// [namedImportOfConstEnumInContainingScopeStaticField.ts]
import _get from "@swc/helpers/src/_get.mjs";
@ -425,12 +356,9 @@ import _get from "@swc/helpers/src/_get.mjs";
import _get_prototype_of from "@swc/helpers/src/_get_prototype_of.mjs";
class C extends B {
}
var __ = {
writable: true,
value: (()=>{
_get(_get_prototype_of(C), "w", C).call(C);
})()
};
(()=>{
_get(_get_prototype_of(C), "w", C).call(C);
})();
export { };
//// [typeOnlyNamedImportInContainingScopeStaticField.ts]
import _get from "@swc/helpers/src/_get.mjs";
@ -444,12 +372,9 @@ import _get from "@swc/helpers/src/_get.mjs";
import _get_prototype_of from "@swc/helpers/src/_get_prototype_of.mjs";
class C extends B {
}
var __ = {
writable: true,
value: (()=>{
_get(_get_prototype_of(C), "w", C).call(C);
})()
};
(()=>{
_get(_get_prototype_of(C), "w", C).call(C);
})();
export { };
//// [defaultImportInContainingScopeStaticField.ts]
import _get from "@swc/helpers/src/_get.mjs";
@ -463,12 +388,9 @@ import _get from "@swc/helpers/src/_get.mjs";
import _get_prototype_of from "@swc/helpers/src/_get_prototype_of.mjs";
class C extends B {
}
var __ = {
writable: true,
value: (()=>{
_get(_get_prototype_of(C), "w", C).call(C);
})()
};
(()=>{
_get(_get_prototype_of(C), "w", C).call(C);
})();
export { };
//// [typeOnlyDefaultImportInContainingScopeStaticField.ts]
import _get from "@swc/helpers/src/_get.mjs";
@ -482,12 +404,9 @@ import _get from "@swc/helpers/src/_get.mjs";
import _get_prototype_of from "@swc/helpers/src/_get_prototype_of.mjs";
class C extends B {
}
var __ = {
writable: true,
value: (()=>{
_get(_get_prototype_of(C), "w", C).call(C);
})()
};
(()=>{
_get(_get_prototype_of(C), "w", C).call(C);
})();
export { };
//// [typeInContainingScopeStaticField.ts]
import _get from "@swc/helpers/src/_get.mjs";
@ -501,12 +420,9 @@ import _get from "@swc/helpers/src/_get.mjs";
import _get_prototype_of from "@swc/helpers/src/_get_prototype_of.mjs";
class C extends B {
}
var __ = {
writable: true,
value: (()=>{
_get(_get_prototype_of(C), "w", C).call(C);
})()
};
(()=>{
_get(_get_prototype_of(C), "w", C).call(C);
})();
export { };
//// [interfaceInContainingScopeStaticField.ts]
import _get from "@swc/helpers/src/_get.mjs";
@ -520,12 +436,9 @@ import _get from "@swc/helpers/src/_get.mjs";
import _get_prototype_of from "@swc/helpers/src/_get_prototype_of.mjs";
class C extends B {
}
var __ = {
writable: true,
value: (()=>{
_get(_get_prototype_of(C), "w", C).call(C);
})()
};
(()=>{
_get(_get_prototype_of(C), "w", C).call(C);
})();
export { };
//// [uninstantiatedNamespaceInContainingScopeStaticField.ts]
import _get from "@swc/helpers/src/_get.mjs";
@ -539,12 +452,9 @@ import _get from "@swc/helpers/src/_get.mjs";
import _get_prototype_of from "@swc/helpers/src/_get_prototype_of.mjs";
class C extends B {
}
var __ = {
writable: true,
value: (()=>{
_get(_get_prototype_of(C), "w", C).call(C);
})()
};
(()=>{
_get(_get_prototype_of(C), "w", C).call(C);
})();
export { };
//// [classExprInContainingScopeStaticField.ts]
import _get from "@swc/helpers/src/_get.mjs";
@ -562,45 +472,33 @@ import _get_prototype_of from "@swc/helpers/src/_get_prototype_of.mjs";
}); // no collision
class C extends B {
}
var __ = {
writable: true,
value: (()=>{
_get(_get_prototype_of(C), "w", C).call(C);
})()
};
(()=>{
_get(_get_prototype_of(C), "w", C).call(C);
})();
export { };
//// [inContainingClassExprStaticField.ts]
import _get from "@swc/helpers/src/_get.mjs";
import _get_prototype_of from "@swc/helpers/src/_get_prototype_of.mjs";
var _Reflect, __;
var _Reflect;
_Reflect = class Reflect {
}, __ = {
writable: true,
value: (()=>{
class C extends B {
}
C._ = _get(_get_prototype_of(C), "w", C).call(C);
})()
}, _Reflect;
}, (()=>{
class C extends B {
}
C._ = _get(_get_prototype_of(C), "w", C).call(C);
})(), _Reflect;
export { };
//// [inContainingClassExprStaticBlock.ts]
import _get from "@swc/helpers/src/_get.mjs";
import _get_prototype_of from "@swc/helpers/src/_get_prototype_of.mjs";
var _Reflect, __;
var _Reflect;
_Reflect = class Reflect {
}, __ = {
writable: true,
value: (()=>{
class C extends B {
}
var __ = {
writable: true,
value: (()=>{
_get(_get_prototype_of(C), "w", C).call(C);
})()
};
})()
}, _Reflect;
}, (()=>{
class C extends B {
}
(()=>{
_get(_get_prototype_of(C), "w", C).call(C);
})();
})(), _Reflect;
export { };
//// [funcExprInContainingScopeStaticField.ts]
import _get from "@swc/helpers/src/_get.mjs";
@ -616,12 +514,9 @@ import _get_prototype_of from "@swc/helpers/src/_get_prototype_of.mjs";
(function Reflect() {}); // no collision
class C extends B {
}
var __ = {
writable: true,
value: (()=>{
_get(_get_prototype_of(C), "w", C).call(C);
})()
};
(()=>{
_get(_get_prototype_of(C), "w", C).call(C);
})();
export { };
//// [inContainingFuncExprStaticField.ts]
import _get from "@swc/helpers/src/_get.mjs";
@ -638,11 +533,8 @@ import _get_prototype_of from "@swc/helpers/src/_get_prototype_of.mjs";
(function Reflect() {
class C extends B {
}
var __ = {
writable: true,
value: (()=>{
_get(_get_prototype_of(C), "w", C).call(C);
})()
};
(()=>{
_get(_get_prototype_of(C), "w", C).call(C);
})();
});
export { };

View File

@ -65,93 +65,60 @@ C._ = [
_get(_get_prototype_of(C), "w", C).call(C);
})()
];
var __ = {
writable: true,
value: (()=>{
var { Reflect } = {
Reflect: null
}; // collision (es2015-es2021 only)
_get(_get_prototype_of(C), "w", C).call(C);
})()
};
var __1 = {
writable: true,
value: (()=>{
var [Reflect] = [
null
]; // collision (es2015-es2021 only)
_get(_get_prototype_of(C), "w", C).call(C);
})()
};
var __2 = {
writable: true,
value: (()=>{
var Reflect; // collision (es2015-es2021 only)
_get(_get_prototype_of(C), "w", C).call(C);
})()
};
var __3 = {
writable: true,
value: (()=>{
class Reflect {
} // collision (es2015-es2021 only)
_get(_get_prototype_of(C), "w", C).call(C);
})()
};
var __4 = {
writable: true,
value: (()=>{
function Reflect() {} // collision (es2015-es2021 only)
_get(_get_prototype_of(C), "w", C).call(C);
})()
};
var __5 = {
writable: true,
value: (()=>{
let Reflect// collision (es2015-es2021 only)
;
(function(Reflect) {})(Reflect || (Reflect = {}));
_get(_get_prototype_of(C), "w", C).call(C);
})()
};
var __6 = {
writable: true,
value: (()=>{
let Reflect// collision (es2015-es2021 only)
;
(function(Reflect) {})(Reflect || (Reflect = {}));
_get(_get_prototype_of(C), "w", C).call(C);
})()
};
var __7 = {
writable: true,
value: (()=>{
_get(_get_prototype_of(C), "w", C).call(C);
})()
};
var __8 = {
writable: true,
value: (()=>{
_get(_get_prototype_of(C), "w", C).call(C);
})()
};
var __9 = {
writable: true,
value: (()=>{
(class Reflect {
} // no collision
);
_get(_get_prototype_of(C), "w", C).call(C);
})()
};
var __10 = {
writable: true,
value: (()=>{
(function Reflect() {} // no collision
);
_get(_get_prototype_of(C), "w", C).call(C);
})()
};
(()=>{
var { Reflect } = {
Reflect: null
}; // collision (es2015-es2021 only)
_get(_get_prototype_of(C), "w", C).call(C);
})();
(()=>{
var [Reflect] = [
null
]; // collision (es2015-es2021 only)
_get(_get_prototype_of(C), "w", C).call(C);
})();
(()=>{
var Reflect; // collision (es2015-es2021 only)
_get(_get_prototype_of(C), "w", C).call(C);
})();
(()=>{
class Reflect {
} // collision (es2015-es2021 only)
_get(_get_prototype_of(C), "w", C).call(C);
})();
(()=>{
function Reflect() {} // collision (es2015-es2021 only)
_get(_get_prototype_of(C), "w", C).call(C);
})();
(()=>{
let Reflect// collision (es2015-es2021 only)
;
(function(Reflect) {})(Reflect || (Reflect = {}));
_get(_get_prototype_of(C), "w", C).call(C);
})();
(()=>{
let Reflect// collision (es2015-es2021 only)
;
(function(Reflect) {})(Reflect || (Reflect = {}));
_get(_get_prototype_of(C), "w", C).call(C);
})();
(()=>{
_get(_get_prototype_of(C), "w", C).call(C);
})();
(()=>{
_get(_get_prototype_of(C), "w", C).call(C);
})();
(()=>{
(class Reflect {
} // no collision
);
_get(_get_prototype_of(C), "w", C).call(C);
})();
(()=>{
(function Reflect() {} // no collision
);
_get(_get_prototype_of(C), "w", C).call(C);
})();
export { };
//// [varInContainingScopeStaticField1.ts]
import _get from "@swc/helpers/src/_get.mjs";
@ -187,12 +154,9 @@ import _get_prototype_of from "@swc/helpers/src/_get_prototype_of.mjs";
var Reflect = null; // collision (es2015-es2021 only)
class C extends B {
}
var __ = {
writable: true,
value: (()=>{
_get(_get_prototype_of(C), "w", C).call(C);
})()
};
(()=>{
_get(_get_prototype_of(C), "w", C).call(C);
})();
export { };
//// [varInContainingScopeStaticBlock2.ts]
import _get from "@swc/helpers/src/_get.mjs";
@ -202,12 +166,9 @@ var { Reflect } = {
}; // collision (es2015-es2021 only)
class C extends B {
}
var __ = {
writable: true,
value: (()=>{
_get(_get_prototype_of(C), "w", C).call(C);
})()
};
(()=>{
_get(_get_prototype_of(C), "w", C).call(C);
})();
export { };
//// [varInContainingScopeStaticBlock3.ts]
import _get from "@swc/helpers/src/_get.mjs";
@ -217,12 +178,9 @@ var [Reflect] = [
]; // collision (es2015-es2021 only)
class C extends B {
}
var __ = {
writable: true,
value: (()=>{
_get(_get_prototype_of(C), "w", C).call(C);
})()
};
(()=>{
_get(_get_prototype_of(C), "w", C).call(C);
})();
export { };
//// [classDeclInContainingScopeStaticField.ts]
import _get from "@swc/helpers/src/_get.mjs";
@ -240,12 +198,9 @@ class Reflect {
} // collision (es2015-es2021 only)
class C extends B {
}
var __ = {
writable: true,
value: (()=>{
_get(_get_prototype_of(C), "w", C).call(C);
})()
};
(()=>{
_get(_get_prototype_of(C), "w", C).call(C);
})();
export { };
//// [funcDeclInContainingScopeStaticField.ts]
import _get from "@swc/helpers/src/_get.mjs";
@ -261,12 +216,9 @@ import _get_prototype_of from "@swc/helpers/src/_get_prototype_of.mjs";
function Reflect() {} // collision (es2015-es2021 only)
class C extends B {
}
var __ = {
writable: true,
value: (()=>{
_get(_get_prototype_of(C), "w", C).call(C);
})()
};
(()=>{
_get(_get_prototype_of(C), "w", C).call(C);
})();
export { };
//// [valueNamespaceInContainingScopeStaticField.ts]
import _get from "@swc/helpers/src/_get.mjs";
@ -280,12 +232,9 @@ import _get from "@swc/helpers/src/_get.mjs";
import _get_prototype_of from "@swc/helpers/src/_get_prototype_of.mjs";
class C extends B {
}
var __ = {
writable: true,
value: (()=>{
_get(_get_prototype_of(C), "w", C).call(C);
})()
};
(()=>{
_get(_get_prototype_of(C), "w", C).call(C);
})();
export { };
//// [enumInContainingScopeStaticField.ts]
import _get from "@swc/helpers/src/_get.mjs";
@ -305,12 +254,9 @@ var Reflect// collision (es2015-es2021 only)
(function(Reflect) {})(Reflect || (Reflect = {}));
class C extends B {
}
var __ = {
writable: true,
value: (()=>{
_get(_get_prototype_of(C), "w", C).call(C);
})()
};
(()=>{
_get(_get_prototype_of(C), "w", C).call(C);
})();
export { };
//// [constEnumInContainingScopeStaticField.ts]
import _get from "@swc/helpers/src/_get.mjs";
@ -330,12 +276,9 @@ var Reflect// collision (es2015-es2021 only)
(function(Reflect) {})(Reflect || (Reflect = {}));
class C extends B {
}
var __ = {
writable: true,
value: (()=>{
_get(_get_prototype_of(C), "w", C).call(C);
})()
};
(()=>{
_get(_get_prototype_of(C), "w", C).call(C);
})();
export { };
//// [namespaceImportInContainingScopeStaticField.ts]
import _get from "@swc/helpers/src/_get.mjs";
@ -349,12 +292,9 @@ import _get from "@swc/helpers/src/_get.mjs";
import _get_prototype_of from "@swc/helpers/src/_get_prototype_of.mjs";
class C extends B {
}
var __ = {
writable: true,
value: (()=>{
_get(_get_prototype_of(C), "w", C).call(C);
})()
};
(()=>{
_get(_get_prototype_of(C), "w", C).call(C);
})();
export { };
//// [namedImportInContainingScopeStaticField.ts]
import _get from "@swc/helpers/src/_get.mjs";
@ -368,12 +308,9 @@ import _get from "@swc/helpers/src/_get.mjs";
import _get_prototype_of from "@swc/helpers/src/_get_prototype_of.mjs";
class C extends B {
}
var __ = {
writable: true,
value: (()=>{
_get(_get_prototype_of(C), "w", C).call(C);
})()
};
(()=>{
_get(_get_prototype_of(C), "w", C).call(C);
})();
export { };
//// [namedImportOfInterfaceInContainingScopeStaticField.ts]
import _get from "@swc/helpers/src/_get.mjs";
@ -387,12 +324,9 @@ import _get from "@swc/helpers/src/_get.mjs";
import _get_prototype_of from "@swc/helpers/src/_get_prototype_of.mjs";
class C extends B {
}
var __ = {
writable: true,
value: (()=>{
_get(_get_prototype_of(C), "w", C).call(C);
})()
};
(()=>{
_get(_get_prototype_of(C), "w", C).call(C);
})();
export { };
//// [namedImportOfUninstantiatedNamespaceInContainingScopeStaticField.ts]
import _get from "@swc/helpers/src/_get.mjs";
@ -406,12 +340,9 @@ import _get from "@swc/helpers/src/_get.mjs";
import _get_prototype_of from "@swc/helpers/src/_get_prototype_of.mjs";
class C extends B {
}
var __ = {
writable: true,
value: (()=>{
_get(_get_prototype_of(C), "w", C).call(C);
})()
};
(()=>{
_get(_get_prototype_of(C), "w", C).call(C);
})();
export { };
//// [namedImportOfConstEnumInContainingScopeStaticField.ts]
import _get from "@swc/helpers/src/_get.mjs";
@ -425,12 +356,9 @@ import _get from "@swc/helpers/src/_get.mjs";
import _get_prototype_of from "@swc/helpers/src/_get_prototype_of.mjs";
class C extends B {
}
var __ = {
writable: true,
value: (()=>{
_get(_get_prototype_of(C), "w", C).call(C);
})()
};
(()=>{
_get(_get_prototype_of(C), "w", C).call(C);
})();
export { };
//// [typeOnlyNamedImportInContainingScopeStaticField.ts]
import _get from "@swc/helpers/src/_get.mjs";
@ -444,12 +372,9 @@ import _get from "@swc/helpers/src/_get.mjs";
import _get_prototype_of from "@swc/helpers/src/_get_prototype_of.mjs";
class C extends B {
}
var __ = {
writable: true,
value: (()=>{
_get(_get_prototype_of(C), "w", C).call(C);
})()
};
(()=>{
_get(_get_prototype_of(C), "w", C).call(C);
})();
export { };
//// [defaultImportInContainingScopeStaticField.ts]
import _get from "@swc/helpers/src/_get.mjs";
@ -463,12 +388,9 @@ import _get from "@swc/helpers/src/_get.mjs";
import _get_prototype_of from "@swc/helpers/src/_get_prototype_of.mjs";
class C extends B {
}
var __ = {
writable: true,
value: (()=>{
_get(_get_prototype_of(C), "w", C).call(C);
})()
};
(()=>{
_get(_get_prototype_of(C), "w", C).call(C);
})();
export { };
//// [typeOnlyDefaultImportInContainingScopeStaticField.ts]
import _get from "@swc/helpers/src/_get.mjs";
@ -482,12 +404,9 @@ import _get from "@swc/helpers/src/_get.mjs";
import _get_prototype_of from "@swc/helpers/src/_get_prototype_of.mjs";
class C extends B {
}
var __ = {
writable: true,
value: (()=>{
_get(_get_prototype_of(C), "w", C).call(C);
})()
};
(()=>{
_get(_get_prototype_of(C), "w", C).call(C);
})();
export { };
//// [typeInContainingScopeStaticField.ts]
import _get from "@swc/helpers/src/_get.mjs";
@ -501,12 +420,9 @@ import _get from "@swc/helpers/src/_get.mjs";
import _get_prototype_of from "@swc/helpers/src/_get_prototype_of.mjs";
class C extends B {
}
var __ = {
writable: true,
value: (()=>{
_get(_get_prototype_of(C), "w", C).call(C);
})()
};
(()=>{
_get(_get_prototype_of(C), "w", C).call(C);
})();
export { };
//// [interfaceInContainingScopeStaticField.ts]
import _get from "@swc/helpers/src/_get.mjs";
@ -520,12 +436,9 @@ import _get from "@swc/helpers/src/_get.mjs";
import _get_prototype_of from "@swc/helpers/src/_get_prototype_of.mjs";
class C extends B {
}
var __ = {
writable: true,
value: (()=>{
_get(_get_prototype_of(C), "w", C).call(C);
})()
};
(()=>{
_get(_get_prototype_of(C), "w", C).call(C);
})();
export { };
//// [uninstantiatedNamespaceInContainingScopeStaticField.ts]
import _get from "@swc/helpers/src/_get.mjs";
@ -539,12 +452,9 @@ import _get from "@swc/helpers/src/_get.mjs";
import _get_prototype_of from "@swc/helpers/src/_get_prototype_of.mjs";
class C extends B {
}
var __ = {
writable: true,
value: (()=>{
_get(_get_prototype_of(C), "w", C).call(C);
})()
};
(()=>{
_get(_get_prototype_of(C), "w", C).call(C);
})();
export { };
//// [classExprInContainingScopeStaticField.ts]
import _get from "@swc/helpers/src/_get.mjs";
@ -562,45 +472,33 @@ import _get_prototype_of from "@swc/helpers/src/_get_prototype_of.mjs";
}); // no collision
class C extends B {
}
var __ = {
writable: true,
value: (()=>{
_get(_get_prototype_of(C), "w", C).call(C);
})()
};
(()=>{
_get(_get_prototype_of(C), "w", C).call(C);
})();
export { };
//// [inContainingClassExprStaticField.ts]
import _get from "@swc/helpers/src/_get.mjs";
import _get_prototype_of from "@swc/helpers/src/_get_prototype_of.mjs";
var _Reflect, __;
var _Reflect;
_Reflect = class Reflect {
}, __ = {
writable: true,
value: (()=>{
class C extends B {
}
C._ = _get(_get_prototype_of(C), "w", C).call(C);
})()
}, _Reflect;
}, (()=>{
class C extends B {
}
C._ = _get(_get_prototype_of(C), "w", C).call(C);
})(), _Reflect;
export { };
//// [inContainingClassExprStaticBlock.ts]
import _get from "@swc/helpers/src/_get.mjs";
import _get_prototype_of from "@swc/helpers/src/_get_prototype_of.mjs";
var _Reflect, __;
var _Reflect;
_Reflect = class Reflect {
}, __ = {
writable: true,
value: (()=>{
class C extends B {
}
var __ = {
writable: true,
value: (()=>{
_get(_get_prototype_of(C), "w", C).call(C);
})()
};
})()
}, _Reflect;
}, (()=>{
class C extends B {
}
(()=>{
_get(_get_prototype_of(C), "w", C).call(C);
})();
})(), _Reflect;
export { };
//// [funcExprInContainingScopeStaticField.ts]
import _get from "@swc/helpers/src/_get.mjs";
@ -616,12 +514,9 @@ import _get_prototype_of from "@swc/helpers/src/_get_prototype_of.mjs";
(function Reflect() {}); // no collision
class C extends B {
}
var __ = {
writable: true,
value: (()=>{
_get(_get_prototype_of(C), "w", C).call(C);
})()
};
(()=>{
_get(_get_prototype_of(C), "w", C).call(C);
})();
export { };
//// [inContainingFuncExprStaticField.ts]
import _get from "@swc/helpers/src/_get.mjs";
@ -638,11 +533,8 @@ import _get_prototype_of from "@swc/helpers/src/_get_prototype_of.mjs";
(function Reflect() {
class C extends B {
}
var __ = {
writable: true,
value: (()=>{
_get(_get_prototype_of(C), "w", C).call(C);
})()
};
(()=>{
_get(_get_prototype_of(C), "w", C).call(C);
})();
});
export { };

View File

@ -86,97 +86,64 @@ C._ = [
_get(_get_prototype_of(C), "w", C).call(C);
}()
];
var __ = {
writable: true,
value: function() {
var Reflect = {
Reflect: null
}.Reflect; // collision (es2015-es2021 only)
_get(_get_prototype_of(C), "w", C).call(C);
}()
};
var __1 = {
writable: true,
value: function() {
var Reflect = null; // collision (es2015-es2021 only)
_get(_get_prototype_of(C), "w", C).call(C);
}()
};
var __2 = {
writable: true,
value: function() {
var Reflect; // collision (es2015-es2021 only)
_get(_get_prototype_of(C), "w", C).call(C);
}()
};
var __3 = {
writable: true,
value: function() {
var Reflect = function Reflect() {
"use strict";
_class_call_check(this, Reflect);
} // collision (es2015-es2021 only)
;
_get(_get_prototype_of(C), "w", C).call(C);
}()
};
var __4 = {
writable: true,
value: function() {
var Reflect = function Reflect() {} // collision (es2015-es2021 only)
;
_get(_get_prototype_of(C), "w", C).call(C);
}()
};
var __5 = {
writable: true,
value: function() {
var Reflect// collision (es2015-es2021 only)
;
(function(Reflect) {})(Reflect || (Reflect = {}));
_get(_get_prototype_of(C), "w", C).call(C);
}()
};
var __6 = {
writable: true,
value: function() {
var Reflect// collision (es2015-es2021 only)
;
(function(Reflect) {})(Reflect || (Reflect = {}));
_get(_get_prototype_of(C), "w", C).call(C);
}()
};
var __7 = {
writable: true,
value: function() {
_get(_get_prototype_of(C), "w", C).call(C);
}()
};
var __8 = {
writable: true,
value: function() {
_get(_get_prototype_of(C), "w", C).call(C);
}()
};
var __9 = {
writable: true,
value: function() {
(function Reflect() {
"use strict";
_class_call_check(this, Reflect);
} // no collision
);
_get(_get_prototype_of(C), "w", C).call(C);
}()
};
var __10 = {
writable: true,
value: function() {
(function Reflect() {} // no collision
);
_get(_get_prototype_of(C), "w", C).call(C);
}()
};
(function() {
var Reflect = {
Reflect: null
}.Reflect; // collision (es2015-es2021 only)
_get(_get_prototype_of(C), "w", C).call(C);
})();
(function() {
var Reflect = null; // collision (es2015-es2021 only)
_get(_get_prototype_of(C), "w", C).call(C);
})();
(function() {
var Reflect; // collision (es2015-es2021 only)
_get(_get_prototype_of(C), "w", C).call(C);
})();
(function() {
var Reflect = function Reflect() {
"use strict";
_class_call_check(this, Reflect);
} // collision (es2015-es2021 only)
;
_get(_get_prototype_of(C), "w", C).call(C);
})();
(function() {
var Reflect = function Reflect() {} // collision (es2015-es2021 only)
;
_get(_get_prototype_of(C), "w", C).call(C);
})();
(function() {
var Reflect// collision (es2015-es2021 only)
;
(function(Reflect) {})(Reflect || (Reflect = {}));
_get(_get_prototype_of(C), "w", C).call(C);
})();
(function() {
var Reflect// collision (es2015-es2021 only)
;
(function(Reflect) {})(Reflect || (Reflect = {}));
_get(_get_prototype_of(C), "w", C).call(C);
})();
(function() {
_get(_get_prototype_of(C), "w", C).call(C);
})();
(function() {
_get(_get_prototype_of(C), "w", C).call(C);
})();
(function() {
(function Reflect() {
"use strict";
_class_call_check(this, Reflect);
} // no collision
);
_get(_get_prototype_of(C), "w", C).call(C);
})();
(function() {
(function Reflect() {} // no collision
);
_get(_get_prototype_of(C), "w", C).call(C);
})();
export { };
//// [varInContainingScopeStaticField1.ts]
import _class_call_check from "@swc/helpers/src/_class_call_check.mjs";
@ -254,12 +221,9 @@ var C = /*#__PURE__*/ function(B1) {
}
return C;
}(B);
var __ = {
writable: true,
value: function() {
_get(_get_prototype_of(C), "w", C).call(C);
}()
};
(function() {
_get(_get_prototype_of(C), "w", C).call(C);
})();
export { };
//// [varInContainingScopeStaticBlock2.ts]
import _class_call_check from "@swc/helpers/src/_class_call_check.mjs";
@ -280,12 +244,9 @@ var C = /*#__PURE__*/ function(B1) {
}
return C;
}(B);
var __ = {
writable: true,
value: function() {
_get(_get_prototype_of(C), "w", C).call(C);
}()
};
(function() {
_get(_get_prototype_of(C), "w", C).call(C);
})();
export { };
//// [varInContainingScopeStaticBlock3.ts]
import _class_call_check from "@swc/helpers/src/_class_call_check.mjs";
@ -304,12 +265,9 @@ var C = /*#__PURE__*/ function(B1) {
}
return C;
}(B);
var __ = {
writable: true,
value: function() {
_get(_get_prototype_of(C), "w", C).call(C);
}()
};
(function() {
_get(_get_prototype_of(C), "w", C).call(C);
})();
export { };
//// [classDeclInContainingScopeStaticField.ts]
import _class_call_check from "@swc/helpers/src/_class_call_check.mjs";
@ -355,12 +313,9 @@ var C = /*#__PURE__*/ function(B1) {
}
return C;
}(B);
var __ = {
writable: true,
value: function() {
_get(_get_prototype_of(C), "w", C).call(C);
}()
};
(function() {
_get(_get_prototype_of(C), "w", C).call(C);
})();
export { };
//// [funcDeclInContainingScopeStaticField.ts]
import _class_call_check from "@swc/helpers/src/_class_call_check.mjs";
@ -398,12 +353,9 @@ var C = /*#__PURE__*/ function(B1) {
}
return C;
}(B);
var __ = {
writable: true,
value: function() {
_get(_get_prototype_of(C), "w", C).call(C);
}()
};
(function() {
_get(_get_prototype_of(C), "w", C).call(C);
})();
export { };
//// [valueNamespaceInContainingScopeStaticField.ts]
import _class_call_check from "@swc/helpers/src/_class_call_check.mjs";
@ -439,12 +391,9 @@ var C = /*#__PURE__*/ function(B1) {
}
return C;
}(B);
var __ = {
writable: true,
value: function() {
_get(_get_prototype_of(C), "w", C).call(C);
}()
};
(function() {
_get(_get_prototype_of(C), "w", C).call(C);
})();
export { };
//// [enumInContainingScopeStaticField.ts]
import _class_call_check from "@swc/helpers/src/_class_call_check.mjs";
@ -486,12 +435,9 @@ var C = /*#__PURE__*/ function(B1) {
}
return C;
}(B);
var __ = {
writable: true,
value: function() {
_get(_get_prototype_of(C), "w", C).call(C);
}()
};
(function() {
_get(_get_prototype_of(C), "w", C).call(C);
})();
export { };
//// [constEnumInContainingScopeStaticField.ts]
import _class_call_check from "@swc/helpers/src/_class_call_check.mjs";
@ -533,12 +479,9 @@ var C = /*#__PURE__*/ function(B1) {
}
return C;
}(B);
var __ = {
writable: true,
value: function() {
_get(_get_prototype_of(C), "w", C).call(C);
}()
};
(function() {
_get(_get_prototype_of(C), "w", C).call(C);
})();
export { };
//// [namespaceImportInContainingScopeStaticField.ts]
import _class_call_check from "@swc/helpers/src/_class_call_check.mjs";
@ -574,12 +517,9 @@ var C = /*#__PURE__*/ function(B1) {
}
return C;
}(B);
var __ = {
writable: true,
value: function() {
_get(_get_prototype_of(C), "w", C).call(C);
}()
};
(function() {
_get(_get_prototype_of(C), "w", C).call(C);
})();
export { };
//// [namedImportInContainingScopeStaticField.ts]
import _class_call_check from "@swc/helpers/src/_class_call_check.mjs";
@ -615,12 +555,9 @@ var C = /*#__PURE__*/ function(B1) {
}
return C;
}(B);
var __ = {
writable: true,
value: function() {
_get(_get_prototype_of(C), "w", C).call(C);
}()
};
(function() {
_get(_get_prototype_of(C), "w", C).call(C);
})();
export { };
//// [namedImportOfInterfaceInContainingScopeStaticField.ts]
import _class_call_check from "@swc/helpers/src/_class_call_check.mjs";
@ -656,12 +593,9 @@ var C = /*#__PURE__*/ function(B1) {
}
return C;
}(B);
var __ = {
writable: true,
value: function() {
_get(_get_prototype_of(C), "w", C).call(C);
}()
};
(function() {
_get(_get_prototype_of(C), "w", C).call(C);
})();
export { };
//// [namedImportOfUninstantiatedNamespaceInContainingScopeStaticField.ts]
import _class_call_check from "@swc/helpers/src/_class_call_check.mjs";
@ -697,12 +631,9 @@ var C = /*#__PURE__*/ function(B1) {
}
return C;
}(B);
var __ = {
writable: true,
value: function() {
_get(_get_prototype_of(C), "w", C).call(C);
}()
};
(function() {
_get(_get_prototype_of(C), "w", C).call(C);
})();
export { };
//// [namedImportOfConstEnumInContainingScopeStaticField.ts]
import _class_call_check from "@swc/helpers/src/_class_call_check.mjs";
@ -738,12 +669,9 @@ var C = /*#__PURE__*/ function(B1) {
}
return C;
}(B);
var __ = {
writable: true,
value: function() {
_get(_get_prototype_of(C), "w", C).call(C);
}()
};
(function() {
_get(_get_prototype_of(C), "w", C).call(C);
})();
export { };
//// [typeOnlyNamedImportInContainingScopeStaticField.ts]
import _class_call_check from "@swc/helpers/src/_class_call_check.mjs";
@ -779,12 +707,9 @@ var C = /*#__PURE__*/ function(B1) {
}
return C;
}(B);
var __ = {
writable: true,
value: function() {
_get(_get_prototype_of(C), "w", C).call(C);
}()
};
(function() {
_get(_get_prototype_of(C), "w", C).call(C);
})();
export { };
//// [defaultImportInContainingScopeStaticField.ts]
import _class_call_check from "@swc/helpers/src/_class_call_check.mjs";
@ -820,12 +745,9 @@ var C = /*#__PURE__*/ function(B1) {
}
return C;
}(B);
var __ = {
writable: true,
value: function() {
_get(_get_prototype_of(C), "w", C).call(C);
}()
};
(function() {
_get(_get_prototype_of(C), "w", C).call(C);
})();
export { };
//// [typeOnlyDefaultImportInContainingScopeStaticField.ts]
import _class_call_check from "@swc/helpers/src/_class_call_check.mjs";
@ -861,12 +783,9 @@ var C = /*#__PURE__*/ function(B1) {
}
return C;
}(B);
var __ = {
writable: true,
value: function() {
_get(_get_prototype_of(C), "w", C).call(C);
}()
};
(function() {
_get(_get_prototype_of(C), "w", C).call(C);
})();
export { };
//// [typeInContainingScopeStaticField.ts]
import _class_call_check from "@swc/helpers/src/_class_call_check.mjs";
@ -902,12 +821,9 @@ var C = /*#__PURE__*/ function(B1) {
}
return C;
}(B);
var __ = {
writable: true,
value: function() {
_get(_get_prototype_of(C), "w", C).call(C);
}()
};
(function() {
_get(_get_prototype_of(C), "w", C).call(C);
})();
export { };
//// [interfaceInContainingScopeStaticField.ts]
import _class_call_check from "@swc/helpers/src/_class_call_check.mjs";
@ -943,12 +859,9 @@ var C = /*#__PURE__*/ function(B1) {
}
return C;
}(B);
var __ = {
writable: true,
value: function() {
_get(_get_prototype_of(C), "w", C).call(C);
}()
};
(function() {
_get(_get_prototype_of(C), "w", C).call(C);
})();
export { };
//// [uninstantiatedNamespaceInContainingScopeStaticField.ts]
import _class_call_check from "@swc/helpers/src/_class_call_check.mjs";
@ -984,12 +897,9 @@ var C = /*#__PURE__*/ function(B1) {
}
return C;
}(B);
var __ = {
writable: true,
value: function() {
_get(_get_prototype_of(C), "w", C).call(C);
}()
};
(function() {
_get(_get_prototype_of(C), "w", C).call(C);
})();
export { };
//// [classExprInContainingScopeStaticField.ts]
import _class_call_check from "@swc/helpers/src/_class_call_check.mjs";
@ -1033,12 +943,9 @@ var C = /*#__PURE__*/ function(B1) {
}
return C;
}(B);
var __ = {
writable: true,
value: function() {
_get(_get_prototype_of(C), "w", C).call(C);
}()
};
(function() {
_get(_get_prototype_of(C), "w", C).call(C);
})();
export { };
//// [inContainingClassExprStaticField.ts]
import _class_call_check from "@swc/helpers/src/_class_call_check.mjs";
@ -1046,26 +953,23 @@ import _get from "@swc/helpers/src/_get.mjs";
import _get_prototype_of from "@swc/helpers/src/_get_prototype_of.mjs";
import _inherits from "@swc/helpers/src/_inherits.mjs";
import _create_super from "@swc/helpers/src/_create_super.mjs";
var _Reflect, __;
var _Reflect;
_Reflect = function Reflect() {
"use strict";
_class_call_check(this, Reflect);
}, __ = {
writable: true,
value: function() {
var C = /*#__PURE__*/ function(B1) {
"use strict";
_inherits(C, B1);
var _super = _create_super(C);
function C() {
_class_call_check(this, C);
return _super.apply(this, arguments);
}
return C;
}(B);
C._ = _get(_get_prototype_of(C), "w", C).call(C);
}()
}, _Reflect;
}, function() {
var C = /*#__PURE__*/ function(B1) {
"use strict";
_inherits(C, B1);
var _super = _create_super(C);
function C() {
_class_call_check(this, C);
return _super.apply(this, arguments);
}
return C;
}(B);
C._ = _get(_get_prototype_of(C), "w", C).call(C);
}(), _Reflect;
export { };
//// [inContainingClassExprStaticBlock.ts]
import _class_call_check from "@swc/helpers/src/_class_call_check.mjs";
@ -1073,31 +977,25 @@ import _get from "@swc/helpers/src/_get.mjs";
import _get_prototype_of from "@swc/helpers/src/_get_prototype_of.mjs";
import _inherits from "@swc/helpers/src/_inherits.mjs";
import _create_super from "@swc/helpers/src/_create_super.mjs";
var _Reflect, __;
var _Reflect;
_Reflect = function Reflect() {
"use strict";
_class_call_check(this, Reflect);
}, __ = {
writable: true,
value: function() {
var C = /*#__PURE__*/ function(B1) {
"use strict";
_inherits(C, B1);
var _super = _create_super(C);
function C() {
_class_call_check(this, C);
return _super.apply(this, arguments);
}
return C;
}(B);
var __ = {
writable: true,
value: function() {
_get(_get_prototype_of(C), "w", C).call(C);
}()
};
}()
}, _Reflect;
}, function() {
var C = /*#__PURE__*/ function(B1) {
"use strict";
_inherits(C, B1);
var _super = _create_super(C);
function C() {
_class_call_check(this, C);
return _super.apply(this, arguments);
}
return C;
}(B);
(function() {
_get(_get_prototype_of(C), "w", C).call(C);
})();
}(), _Reflect;
export { };
//// [funcExprInContainingScopeStaticField.ts]
import _class_call_check from "@swc/helpers/src/_class_call_check.mjs";
@ -1135,12 +1033,9 @@ var C = /*#__PURE__*/ function(B1) {
}
return C;
}(B);
var __ = {
writable: true,
value: function() {
_get(_get_prototype_of(C), "w", C).call(C);
}()
};
(function() {
_get(_get_prototype_of(C), "w", C).call(C);
})();
export { };
//// [inContainingFuncExprStaticField.ts]
import _class_call_check from "@swc/helpers/src/_class_call_check.mjs";
@ -1179,11 +1074,8 @@ import _create_super from "@swc/helpers/src/_create_super.mjs";
}
return C;
}(B);
var __ = {
writable: true,
value: function() {
_get(_get_prototype_of(C), "w", C).call(C);
}()
};
(function() {
_get(_get_prototype_of(C), "w", C).call(C);
})();
});
export { };

View File

@ -121,7 +121,12 @@ where
// ES2022
// static block needs to be placed before class property
// because it transforms into private static property
let pass = add!(pass, ClassStaticBlock, es2022::static_blocks());
let static_blocks_mark = Mark::new();
let pass = add!(
pass,
ClassStaticBlock,
es2022::static_blocks(static_blocks_mark)
);
let pass = add!(
pass,
ClassProperties,
@ -131,7 +136,8 @@ where
private_as_properties: loose || assumptions.private_fields_as_properties,
set_public_fields: loose || assumptions.set_public_class_fields,
constant_super: loose || assumptions.constant_super,
no_document_all: loose || assumptions.no_document_all
no_document_all: loose || assumptions.no_document_all,
static_blocks_mark,
}
)
);

View File

@ -1,9 +1,5 @@
var __ = _classPrivateFieldLooseKey("__");
class A {
}
Object.defineProperty(A, __, {
writable: true,
value: (()=>{
A.abc = 123;
})()
});
(()=>{
A.abc = 123;
})();

View File

@ -1,9 +1,5 @@
var __ = _classPrivateFieldLooseKey("__");
class A {
}
Object.defineProperty(A, __, {
writable: true,
value: (()=>{
A.abc = 123;
})()
});
(()=>{
A.abc = 123;
})();

View File

@ -13,6 +13,7 @@ pub(super) enum MemberInit {
PrivProp(PrivProp),
PrivMethod(PrivMethod),
PrivAccessor(PrivAccessor),
StaticBlock(Box<Expr>),
}
pub(super) struct PubProp {
@ -181,6 +182,7 @@ impl MemberInitRecord {
}
.into(),
),
MemberInit::StaticBlock(..) => unreachable!(),
}
}
@ -311,6 +313,7 @@ impl MemberInitRecord {
unreachable!()
}
}
MemberInit::StaticBlock(expr) => value_init.push(expr.into_stmt()),
}
}

View File

@ -53,12 +53,25 @@ pub fn class_properties<C: Comments>(cm: Option<C>, config: Config) -> impl Fold
})
}
#[derive(Debug, Clone, Copy, Default)]
#[derive(Debug, Clone, Copy)]
pub struct Config {
pub private_as_properties: bool,
pub set_public_fields: bool,
pub constant_super: bool,
pub no_document_all: bool,
pub static_blocks_mark: Mark,
}
impl Default for Config {
fn default() -> Self {
Self {
private_as_properties: false,
set_public_fields: false,
constant_super: false,
no_document_all: false,
static_blocks_mark: Mark::new(),
}
}
}
struct ClassProperties<C: Comments> {
@ -708,6 +721,12 @@ impl<C: Comments> ClassProperties<C> {
let value = prop.value.unwrap_or_else(|| undefined(prop_span));
if prop.is_static && prop.span.has_mark(self.c.static_blocks_mark) {
let init = MemberInit::StaticBlock(value);
extra_inits.push(init);
continue;
}
let init = MemberInit::PrivProp(PrivProp {
span: prop_span,
name: ident.clone(),

View File

@ -23,7 +23,7 @@ pub fn es2022<C: Comments>(cm: Option<C>, config: Config) -> impl Fold {
unicode_property_regex: true,
unicode_regex: false,
}),
static_blocks(),
static_blocks(config.class_properties.static_blocks_mark),
class_properties(cm, config.class_properties),
private_in_object(),
)

View File

@ -1,15 +1,17 @@
use swc_atoms::JsWord;
use swc_common::{collections::AHashSet, util::take::Take, DUMMY_SP};
use swc_common::{collections::AHashSet, util::take::Take, Mark, DUMMY_SP};
use swc_ecma_ast::*;
use swc_ecma_utils::ExprFactory;
use swc_ecma_visit::{as_folder, noop_visit_mut_type, Fold, VisitMut, VisitMutWith};
use swc_trace_macro::swc_trace;
struct ClassStaticBlock;
struct ClassStaticBlock {
mark: Mark,
}
#[tracing::instrument(level = "info", skip_all)]
pub fn static_blocks() -> impl Fold + VisitMut {
as_folder(ClassStaticBlock)
pub fn static_blocks(mark: Mark) -> impl Fold + VisitMut {
as_folder(ClassStaticBlock { mark })
}
#[swc_trace]
@ -20,7 +22,7 @@ impl ClassStaticBlock {
private_id: JsWord,
) -> PrivateProp {
PrivateProp {
span: DUMMY_SP,
span: DUMMY_SP.apply_mark(self.mark),
is_static: true,
is_optional: false,
is_override: false,

View File

@ -43,7 +43,8 @@ fn get_passes(t: &Tester, plugins: &[PluginConfig]) -> Box<dyn Fold> {
constant_super: loose,
set_public_fields: loose,
private_as_properties: loose,
no_document_all: loose
no_document_all: loose,
static_blocks_mark: Mark::new(),
}
)
));

View File

@ -1,7 +1,7 @@
use std::path::PathBuf;
use serde::Deserialize;
use swc_common::chain;
use swc_common::{chain, Mark};
use swc_ecma_transforms_base::pass::noop;
use swc_ecma_transforms_compat::{
es2015::classes,
@ -59,7 +59,8 @@ fn fixture(input: PathBuf) {
set_public_fields: loose,
constant_super: loose,
no_document_all: loose,
private_as_properties: loose
private_as_properties: loose,
static_blocks_mark: Mark::new(),
}
)
));
@ -77,7 +78,8 @@ fn fixture(input: PathBuf) {
set_public_fields: loose,
constant_super: loose,
no_document_all: loose,
private_as_properties: loose
private_as_properties: loose,
static_blocks_mark: Mark::new(),
}
)
));

View File

@ -16,16 +16,14 @@ fn fixture(input: PathBuf) {
..Default::default()
}),
&|t| {
let config = class_properties::Config::default();
let pass: Box<dyn Fold> = if input.to_string_lossy().contains("class-properties") {
Box::new(chain!(
static_blocks(),
class_properties(
Some(t.comments.clone()),
class_properties::Config::default()
)
static_blocks(config.static_blocks_mark),
class_properties(Some(t.comments.clone()), config)
))
} else {
Box::new(static_blocks())
Box::new(static_blocks(config.static_blocks_mark))
};
pass
},

View File

@ -1,8 +1,6 @@
class Foo {}
class Foo {
}
_defineProperty(Foo, "bar", 42);
var __ = {
writable: true,
value: (() => {
Foo.foo = Foo.bar;
})(),
};
(()=>{
Foo.foo = Foo.bar;
})();

View File

@ -1,21 +1,12 @@
var _Base, __, _class, __1;
var _Base, _class;
class Foo extends (_class = class extends (_Base = class Base {
}, __ = {
writable: true,
value: (()=>{
_Base.qux = 21;
})()
}, _Base) {
}, __1 = {
writable: true,
value: (()=>{
_class.bar = 21;
})()
}, _class) {
}, (()=>{
_Base.qux = 21;
})(), _Base) {
}, (()=>{
_class.bar = 21;
})(), _class) {
}
var __2 = {
writable: true,
value: (()=>{
Foo.foo = Foo.bar + Foo.qux;
})()
};
(()=>{
Foo.foo = Foo.bar + Foo.qux;
})();

View File

@ -4,17 +4,11 @@ var _bar = {
writable: true,
value: 21
};
var __ = {
writable: true,
value: (()=>{
Foo.foo = _classStaticPrivateFieldSpecGet(Foo, Foo, _bar);
Foo.qux1 = Foo.qux;
})()
};
(()=>{
Foo.foo = _classStaticPrivateFieldSpecGet(Foo, Foo, _bar);
Foo.qux1 = Foo.qux;
})();
_defineProperty(Foo, "qux", 21);
var __1 = {
writable: true,
value: (()=>{
Foo.qux2 = Foo.qux;
})()
};
(()=>{
Foo.qux2 = Foo.qux;
})();

View File

@ -4,9 +4,6 @@ var __ = {
writable: true,
value: 42
};
var __1 = {
writable: true,
value: (()=>{
Foo.foo = _classStaticPrivateFieldSpecGet(Foo, Foo, __);
})()
};
(()=>{
Foo.foo = _classStaticPrivateFieldSpecGet(Foo, Foo, __);
})();

View File

@ -1,12 +1,9 @@
class Base {
constructor(){
var _class, __;
var _class;
this.Foo = (_class = class {
}, __ = {
writable: true,
value: (()=>{
_class.foo = void 0;
})()
}, _class);
}, (()=>{
_class.foo = void 0;
})(), _class);
}
}