From d1484ad5f6514e40a4020db7874717e8ddb9f2a6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Nicol=C3=B2=20Ribaudo?= Date: Sat, 4 Feb 2023 10:51:17 +0100 Subject: [PATCH] Review --- .../babel-helpers/src/helpers-generated.ts | 2 +- .../src/helpers/applyDecs2301.js | 58 +++++++++------ .../src/transformer-2023-01.ts | 73 +++++++++++-------- .../private/output.js | 4 +- .../static-private/output.js | 4 +- .../2023-01-accessors/private/output.js | 4 +- .../static-private/output.js | 4 +- .../super-in-private-accessor/output.js | 2 +- .../super-in-private-method/output.js | 2 +- .../private/output.js | 4 +- .../static-private/output.js | 4 +- .../fixtures/2023-01-fields/private/output.js | 4 +- .../2023-01-fields/static-private/output.js | 4 +- .../private/output.js | 2 +- .../static-private/output.js | 2 +- .../private/output.js | 4 +- .../static-private/output.js | 4 +- .../private/output.js | 4 +- .../static-private/output.js | 4 +- .../2023-01-getters/private/output.js | 2 +- .../2023-01-getters/static-private/output.js | 2 +- .../private/output.js | 2 +- .../static-private/output.js | 2 +- .../2023-01-methods/private/output.js | 2 +- .../2023-01-methods/static-private/output.js | 2 +- .../2023-01-misc/all-decorators/output.js | 10 +-- .../super-in-private-accessor/output.js | 2 +- .../super-in-private-method/output.js | 2 +- .../private/output.js | 2 +- .../static-private/output.js | 2 +- .../2023-01-setters/private/output.js | 2 +- .../2023-01-setters/static-private/output.js | 2 +- 32 files changed, 123 insertions(+), 100 deletions(-) diff --git a/packages/babel-helpers/src/helpers-generated.ts b/packages/babel-helpers/src/helpers-generated.ts index 3d2c9d342d1c..21f8b896584f 100644 --- a/packages/babel-helpers/src/helpers-generated.ts +++ b/packages/babel-helpers/src/helpers-generated.ts @@ -35,7 +35,7 @@ export default Object.freeze({ ), applyDecs2301: helper( "7.20.0", - 'function createAddInitializerMethod(initializers,decoratorFinishedRef){return function(initializer){assertNotFinished(decoratorFinishedRef,"addInitializer"),assertCallable(initializer,"An initializer"),initializers.push(initializer)}}function assertInstanceIfPrivate(has,target){if(has&&!has(target))throw new TypeError("Attempted to access private element on non-instance")}function memberDec(dec,name,desc,initializers,kind,isStatic,isPrivate,value,privateHas){var kindStr;switch(kind){case 1:kindStr="accessor";break;case 2:kindStr="method";break;case 3:kindStr="getter";break;case 4:kindStr="setter";break;default:kindStr="field"}var get,set,has,ctx={kind:kindStr,name:isPrivate?"#"+name:name,static:isStatic,private:isPrivate},decoratorFinishedRef={v:!1};if(0!==kind&&(ctx.addInitializer=createAddInitializerMethod(initializers,decoratorFinishedRef)),has=isPrivate?privateHas:function(target){return name in target},isPrivate||0!==kind&&2!==kind)if(2===kind)get=function(target){return assertInstanceIfPrivate(privateHas,target),desc.value};else{var t=0===kind||1===kind;(t||3===kind)&&(get=function(target){return assertInstanceIfPrivate(privateHas,target),desc.get.call(target)}),(t||4===kind)&&(set=function(target,value){assertInstanceIfPrivate(privateHas,target),desc.set.call(target,value)})}else get=function(target){return target[name]},0===kind&&(set=function(target,v){target[name]=v});ctx.access=get&&set?{get:get,set:set,has:has}:get?{get:get,has:has}:{set:set,has:has};try{return dec(value,ctx)}finally{decoratorFinishedRef.v=!0}}function assertNotFinished(decoratorFinishedRef,fnName){if(decoratorFinishedRef.v)throw new Error("attempted to call "+fnName+" after decoration was finished")}function assertCallable(fn,hint){if("function"!=typeof fn)throw new TypeError(hint+" must be a function")}function assertValidReturnValue(kind,value){var type=typeof value;if(1===kind){if("object"!==type||null===value)throw new TypeError("accessor decorators must return an object with get, set, or init properties or void 0");void 0!==value.get&&assertCallable(value.get,"accessor.get"),void 0!==value.set&&assertCallable(value.set,"accessor.set"),void 0!==value.init&&assertCallable(value.init,"accessor.init")}else if("function"!==type){var hint;throw hint=0===kind?"field":10===kind?"class":"method",new TypeError(hint+" decorators must return a function or void 0")}}function applyMemberDec(ret,base,decInfo,name,kind,isStatic,isPrivate,initializers){var desc,init,value,has,newValue,get,set,decs=decInfo[0];if(isPrivate?0===kind||1===kind?(desc={get:decInfo[3],set:decInfo[4]},has=decInfo[5]):(desc=3===kind?{get:decInfo[3]}:4===kind?{set:decInfo[3]}:{value:decInfo[3]},has=decInfo[4]):0!==kind&&(desc=Object.getOwnPropertyDescriptor(base,name)),1===kind?value={get:desc.get,set:desc.set}:2===kind?value=desc.value:3===kind?value=desc.get:4===kind&&(value=desc.set),"function"==typeof decs)void 0!==(newValue=memberDec(decs,name,desc,initializers,kind,isStatic,isPrivate,value,has))&&(assertValidReturnValue(kind,newValue),0===kind?init=newValue:1===kind?(init=newValue.init,get=newValue.get||value.get,set=newValue.set||value.set,value={get:get,set:set}):value=newValue);else for(var i=decs.length-1;i>=0;i--){var newInit;if(void 0!==(newValue=memberDec(decs[i],name,desc,initializers,kind,isStatic,isPrivate,value,has)))assertValidReturnValue(kind,newValue),0===kind?newInit=newValue:1===kind?(newInit=newValue.init,get=newValue.get||value.get,set=newValue.set||value.set,value={get:get,set:set}):value=newValue,void 0!==newInit&&(void 0===init?init=newInit:"function"==typeof init?init=[init,newInit]:init.push(newInit))}if(0===kind||1===kind){if(void 0===init)init=function(instance,init){return init};else if("function"!=typeof init){var ownInitializers=init;init=function(instance,init){for(var value=init,i=0;i3,isStatic=kind>=5;if(isStatic?(base=Class,0!==(kind-=5)&&(initializers=staticInitializers=staticInitializers||[])):(base=Class.prototype,0!==kind&&(initializers=protoInitializers=protoInitializers||[])),0!==kind&&!isPrivate){var existingNonFields=isStatic?existingStaticNonFields:existingProtoNonFields,existingKind=existingNonFields.get(name)||0;if(!0===existingKind||3===existingKind&&4!==kind||4===existingKind&&3!==kind)throw new Error("Attempted to decorate a public method/accessor that has the same name as a previously decorated public method/accessor. This is not currently supported by the decorators plugin. Property name was: "+name);!existingKind&&kind>2?existingNonFields.set(name,kind):existingNonFields.set(name,!0)}applyMemberDec(ret,base,decInfo,name,kind,isStatic,isPrivate,initializers)}}return pushInitializers(ret,protoInitializers),pushInitializers(ret,staticInitializers),ret}function pushInitializers(ret,initializers){initializers&&ret.push((function(instance){for(var i=0;i0){for(var initializers=[],newClass=targetClass,name=targetClass.name,i=classDecs.length-1;i>=0;i--){var decoratorFinishedRef={v:!1};try{var nextNewClass=classDecs[i](newClass,{kind:"class",name:name,addInitializer:createAddInitializerMethod(initializers,decoratorFinishedRef)})}finally{decoratorFinishedRef.v=!0}void 0!==nextNewClass&&(assertValidReturnValue(10,nextNewClass),newClass=nextNewClass)}return[newClass,function(){for(var i=0;i=0;i--){var newInit;if(void 0!==(newValue=memberDec(decs[i],name,desc,initializers,kind,isStatic,isPrivate,value,hasPrivateBrand)))assertValidReturnValue(kind,newValue),0===kind?newInit=newValue:1===kind?(newInit=newValue.init,get=newValue.get||value.get,set=newValue.set||value.set,value={get:get,set:set}):value=newValue,void 0!==newInit&&(void 0===init?init=newInit:"function"==typeof init?init=[init,newInit]:init.push(newInit))}if(0===kind||1===kind){if(void 0===init)init=function(instance,init){return init};else if("function"!=typeof init){var ownInitializers=init;init=function(instance,init){for(var value=init,i=0;i3,isStatic=kind>=5,hasPrivateBrand=instanceBrand;if(isStatic?(base=Class,0!==(kind-=5)&&(initializers=staticInitializers=staticInitializers||[]),staticBrand||(staticBrand=function(_){return checkInRHS(_)===Class}),hasPrivateBrand=staticBrand):(base=Class.prototype,0!==kind&&(initializers=protoInitializers=protoInitializers||[])),0!==kind&&!isPrivate){var existingNonFields=isStatic?existingStaticNonFields:existingProtoNonFields,existingKind=existingNonFields.get(name)||0;if(!0===existingKind||3===existingKind&&4!==kind||4===existingKind&&3!==kind)throw new Error("Attempted to decorate a public method/accessor that has the same name as a previously decorated public method/accessor. This is not currently supported by the decorators plugin. Property name was: "+name);!existingKind&&kind>2?existingNonFields.set(name,kind):existingNonFields.set(name,!0)}applyMemberDec(ret,base,decInfo,name,kind,isStatic,isPrivate,initializers,hasPrivateBrand)}}return pushInitializers(ret,protoInitializers),pushInitializers(ret,staticInitializers),ret}function pushInitializers(ret,initializers){initializers&&ret.push((function(instance){for(var i=0;i0){for(var initializers=[],newClass=targetClass,name=targetClass.name,i=classDecs.length-1;i>=0;i--){var decoratorFinishedRef={v:!1};try{var nextNewClass=classDecs[i](newClass,{kind:"class",name:name,addInitializer:createAddInitializerMethod(initializers,decoratorFinishedRef)})}finally{decoratorFinishedRef.v=!0}void 0!==nextNewClass&&(assertValidReturnValue(10,nextNewClass),newClass=nextNewClass)}return[newClass,function(){for(var i=0;i= 5; /* STATIC */ var base; var initializers; + var hasPrivateBrand = instanceBrand; if (isStatic) { base = Class; @@ -396,6 +398,12 @@ function applyMemberDecs(Class, decInfos) { staticInitializers = staticInitializers || []; initializers = staticInitializers; } + if (!staticBrand) { + staticBrand = function (_) { + return checkInRHS(_) === Class; + }; + } + hasPrivateBrand = staticBrand; } else { base = Class.prototype; // initialize protoInitializers when we see a non-field member @@ -436,7 +444,8 @@ function applyMemberDecs(Class, decInfos) { kind, isStatic, isPrivate, - initializers + initializers, + hasPrivateBrand ); } @@ -643,9 +652,14 @@ function applyClassDecs(targetClass, classDecs) { initializeClass(Class); */ -export default function applyDecs2301(targetClass, memberDecs, classDecs) { +export default function applyDecs2301( + targetClass, + memberDecs, + classDecs, + instanceBrand +) { return { - e: applyMemberDecs(targetClass, memberDecs), + e: applyMemberDecs(targetClass, memberDecs, instanceBrand), // Lazily apply class decorations so that member init locals can be properly bound. get c() { return applyClassDecs(targetClass, classDecs); diff --git a/packages/babel-plugin-proposal-decorators/src/transformer-2023-01.ts b/packages/babel-plugin-proposal-decorators/src/transformer-2023-01.ts index 278be4f5b693..dce442e0128b 100644 --- a/packages/babel-plugin-proposal-decorators/src/transformer-2023-01.ts +++ b/packages/babel-plugin-proposal-decorators/src/transformer-2023-01.ts @@ -231,7 +231,6 @@ function addProxyAccessorsFor( function extractProxyAccessorsFor( targetKey: t.PrivateName, - injectHas: boolean, ): (t.FunctionExpression | t.ArrowFunctionExpression)[] { return [ template.expression.ast` @@ -244,10 +243,6 @@ function extractProxyAccessorsFor( this.${t.cloneNode(targetKey)} = value; } ` as t.FunctionExpression, - injectHas && - (template.expression.ast` - _ => ${t.cloneNode(targetKey)} in _ - ` as t.ArrowFunctionExpression), ].filter(Boolean); } @@ -343,17 +338,12 @@ function generateDecorationExprs( const kind = el.isStatic ? el.kind + STATIC : el.kind; - const decInfo = [decs, t.numericLiteral(kind), el.name]; - - const { privateMethods } = el; - - if (Array.isArray(privateMethods)) { - decInfo.push(...privateMethods); - } else if (privateMethods) { - decInfo.push(privateMethods); - } - - return t.arrayExpression(decInfo); + return t.arrayExpression([ + decs, + t.numericLiteral(kind), + el.name, + ...el.privateMethods, + ]); }), ); } @@ -491,8 +481,6 @@ function transformClass( const classDecorators = path.node.decorators; let hasElementDecorators = false; - const injectHasChecks = version === "2023-01"; - const generateClassPrivateUid = createLazyPrivateUidGeneratorForClass(path); // Iterate over the class to see if we need to decorate it, and also to @@ -569,6 +557,9 @@ function transformClass( classIdLocal = t.cloneNode(path.node.id); } + let lastInstancePrivateName: t.PrivateName; + let needsInstancePrivateBrandCheck = false; + if (hasElementDecorators) { for (const element of body) { if (!isClassDecoratableElementPath(element)) { @@ -614,6 +605,15 @@ function transformClass( name = key.name; } + if (isPrivate && !isStatic) { + if (hasDecorators) { + needsInstancePrivateBrandCheck = true; + } + if (t.isClassPrivateProperty(node) || !lastInstancePrivateName) { + lastInstancePrivateName = key; + } + } + if (element.isClassMethod({ kind: "constructor" })) { constructorPath = element; } @@ -645,7 +645,7 @@ function transformClass( const [newPath] = element.replaceWith(newField); if (isPrivate) { - privateMethods = extractProxyAccessorsFor(newId, injectHasChecks); + privateMethods = extractProxyAccessorsFor(newId); const getId = newPath.scope.parent.generateDeclaredUidIdentifier( `get_${name}`, @@ -679,7 +679,7 @@ function transformClass( locals = initId; if (isPrivate) { - privateMethods = extractProxyAccessorsFor(key, injectHasChecks); + privateMethods = extractProxyAccessorsFor(key); } } else if (isPrivate) { locals = element.scope.parent.generateDeclaredUidIdentifier( @@ -710,11 +710,7 @@ function transformClass( body, isAsync, ), - injectHasChecks && - (template.expression.ast` - _ => ${t.cloneNode(key)} in _ - ` as t.ArrowFunctionExpression), - ].filter(Boolean); + ]; if (kind === GETTER || kind === SETTER) { movePrivateAccessor( @@ -997,6 +993,7 @@ function transformClass( classLocals, elementDecorations, classDecorations, + needsInstancePrivateBrandCheck ? lastInstancePrivateName : null, state, version, ), @@ -1026,11 +1023,17 @@ function createLocalsAssignment( classLocals: t.Identifier[], elementDecorations: t.ArrayExpression, classDecorations: t.ArrayExpression, + maybePrivateBranName: t.PrivateName | null, state: PluginPass, version: DecoratorVersionKind, ) { let lhs, rhs; // TODO(Babel 8): Only keep the else branch + const args: t.Expression[] = [ + t.thisExpression(), + elementDecorations, + classDecorations, + ]; if ( version === "2021-12" || (version === "2022-03" && !state.availableHelper("applyDecs2203R")) @@ -1038,15 +1041,21 @@ function createLocalsAssignment( lhs = t.arrayPattern([...elementLocals, ...classLocals]); rhs = t.callExpression( state.addHelper(version === "2021-12" ? "applyDecs" : "applyDecs2203"), - [t.thisExpression(), elementDecorations, classDecorations], + args, ); } else { - rhs = t.callExpression( - state.addHelper( - version === "2023-01" ? "applyDecs2301" : "applyDecs2203R", - ), - [t.thisExpression(), elementDecorations, classDecorations], - ); + if (version === "2023-01") { + if (maybePrivateBranName) { + args.push( + template.expression.ast` + _ => ${t.cloneNode(maybePrivateBranName)} in _ + ` as t.ArrowFunctionExpression, + ); + } + rhs = t.callExpression(state.addHelper("applyDecs2301"), args); + } else { + rhs = t.callExpression(state.addHelper("applyDecs2203R"), args); + } // optimize `{ c: [classLocals] } = applyapplyDecs2203R(...)` to // `[classLocals] = applyapplyDecs2203R(...).c` if (elementLocals.length > 0) { diff --git a/packages/babel-plugin-proposal-decorators/test/fixtures/2023-01-accessors--to-es2015/private/output.js b/packages/babel-plugin-proposal-decorators/test/fixtures/2023-01-accessors--to-es2015/private/output.js index 2954fc4908ce..bc2f3404afdb 100644 --- a/packages/babel-plugin-proposal-decorators/test/fixtures/2023-01-accessors--to-es2015/private/output.js +++ b/packages/babel-plugin-proposal-decorators/test/fixtures/2023-01-accessors--to-es2015/private/output.js @@ -40,8 +40,8 @@ function _get_b2() { return babelHelpers.classPrivateFieldGet(this, _A); }, function (value) { babelHelpers.classPrivateFieldSet(this, _A, value); -}, _ => _A.has(babelHelpers.checkInRHS(_))], [dec, 1, "b", function () { +}], [dec, 1, "b", function () { return babelHelpers.classPrivateFieldGet(this, _B); }, function (value) { babelHelpers.classPrivateFieldSet(this, _B, value); -}, _ => _B.has(babelHelpers.checkInRHS(_))]], []).e; +}]], [], _ => _a.has(babelHelpers.checkInRHS(_))).e; diff --git a/packages/babel-plugin-proposal-decorators/test/fixtures/2023-01-accessors--to-es2015/static-private/output.js b/packages/babel-plugin-proposal-decorators/test/fixtures/2023-01-accessors--to-es2015/static-private/output.js index dd58145e92de..50f1f16799bf 100644 --- a/packages/babel-plugin-proposal-decorators/test/fixtures/2023-01-accessors--to-es2015/static-private/output.js +++ b/packages/babel-plugin-proposal-decorators/test/fixtures/2023-01-accessors--to-es2015/static-private/output.js @@ -31,11 +31,11 @@ function _get_b2() { return babelHelpers.classStaticPrivateFieldSpecGet(this, Foo, _A); }, function (value) { babelHelpers.classStaticPrivateFieldSpecSet(this, Foo, _A, value); - }, _ => babelHelpers.checkInRHS(_) === Foo], [dec, 6, "b", function () { + }], [dec, 6, "b", function () { return babelHelpers.classStaticPrivateFieldSpecGet(this, Foo, _B); }, function (value) { babelHelpers.classStaticPrivateFieldSpecSet(this, Foo, _B, value); - }, _ => babelHelpers.checkInRHS(_) === Foo]], []).e; + }]], []).e; _initStatic(Foo); })(); var _A = { diff --git a/packages/babel-plugin-proposal-decorators/test/fixtures/2023-01-accessors/private/output.js b/packages/babel-plugin-proposal-decorators/test/fixtures/2023-01-accessors/private/output.js index b3e40dd0c4c5..18a97f687779 100644 --- a/packages/babel-plugin-proposal-decorators/test/fixtures/2023-01-accessors/private/output.js +++ b/packages/babel-plugin-proposal-decorators/test/fixtures/2023-01-accessors/private/output.js @@ -6,11 +6,11 @@ class Foo { return this.#A; }, function (value) { this.#A = value; - }, _ => #A in _], [dec, 1, "b", function () { + }], [dec, 1, "b", function () { return this.#B; }, function (value) { this.#B = value; - }, _ => #B in _]], []).e; + }]], [], _ => #a in _).e; } #A = (_initProto(this), _init_a(this)); set #a(v) { diff --git a/packages/babel-plugin-proposal-decorators/test/fixtures/2023-01-accessors/static-private/output.js b/packages/babel-plugin-proposal-decorators/test/fixtures/2023-01-accessors/static-private/output.js index 5176e83bdef5..120e64a5676d 100644 --- a/packages/babel-plugin-proposal-decorators/test/fixtures/2023-01-accessors/static-private/output.js +++ b/packages/babel-plugin-proposal-decorators/test/fixtures/2023-01-accessors/static-private/output.js @@ -6,11 +6,11 @@ class Foo { return this.#A; }, function (value) { this.#A = value; - }, _ => #A in _], [dec, 6, "b", function () { + }], [dec, 6, "b", function () { return this.#B; }, function (value) { this.#B = value; - }, _ => #B in _]], []).e; + }]], []).e; _initStatic(this); } static #A = _init_a(this); diff --git a/packages/babel-plugin-proposal-decorators/test/fixtures/2023-01-assumption-constantSuper/super-in-private-accessor/output.js b/packages/babel-plugin-proposal-decorators/test/fixtures/2023-01-assumption-constantSuper/super-in-private-accessor/output.js index 389e1c65cd11..d05b26d27f5a 100644 --- a/packages/babel-plugin-proposal-decorators/test/fixtures/2023-01-assumption-constantSuper/super-in-private-accessor/output.js +++ b/packages/babel-plugin-proposal-decorators/test/fixtures/2023-01-assumption-constantSuper/super-in-private-accessor/output.js @@ -4,7 +4,7 @@ class Foo extends Bar { static { [_call_x, _initProto] = babelHelpers.applyDecs2301(this, [[dec, 3, "x", function () { return Bar.prototype.foo.call(this); - }, _ => #x in _]], []).e; + }]], [], _ => #x in _).e; } constructor(...args) { super(...args); diff --git a/packages/babel-plugin-proposal-decorators/test/fixtures/2023-01-assumption-constantSuper/super-in-private-method/output.js b/packages/babel-plugin-proposal-decorators/test/fixtures/2023-01-assumption-constantSuper/super-in-private-method/output.js index 3148ecfd31fc..29b0c3f17885 100644 --- a/packages/babel-plugin-proposal-decorators/test/fixtures/2023-01-assumption-constantSuper/super-in-private-method/output.js +++ b/packages/babel-plugin-proposal-decorators/test/fixtures/2023-01-assumption-constantSuper/super-in-private-method/output.js @@ -4,7 +4,7 @@ class Foo extends Bar { static { [_call_x, _initProto] = babelHelpers.applyDecs2301(this, [[dec, 2, "x", function () { return Bar.prototype.foo.call(this); - }, _ => #x in _]], []).e; + }]], [], _ => #x in _).e; } constructor(...args) { super(...args); diff --git a/packages/babel-plugin-proposal-decorators/test/fixtures/2023-01-fields--to-es2015/private/output.js b/packages/babel-plugin-proposal-decorators/test/fixtures/2023-01-fields--to-es2015/private/output.js index 839036d3d834..033305eefbbb 100644 --- a/packages/babel-plugin-proposal-decorators/test/fixtures/2023-01-fields--to-es2015/private/output.js +++ b/packages/babel-plugin-proposal-decorators/test/fixtures/2023-01-fields--to-es2015/private/output.js @@ -18,8 +18,8 @@ class Foo { return babelHelpers.classPrivateFieldGet(this, _a); }, function (value) { babelHelpers.classPrivateFieldSet(this, _a, value); -}, _ => _a.has(babelHelpers.checkInRHS(_))], [dec, 0, "b", function () { +}], [dec, 0, "b", function () { return babelHelpers.classPrivateFieldGet(this, _b); }, function (value) { babelHelpers.classPrivateFieldSet(this, _b, value); -}, _ => _b.has(babelHelpers.checkInRHS(_))]], []).e; +}]], [], _ => _b.has(babelHelpers.checkInRHS(_))).e; diff --git a/packages/babel-plugin-proposal-decorators/test/fixtures/2023-01-fields--to-es2015/static-private/output.js b/packages/babel-plugin-proposal-decorators/test/fixtures/2023-01-fields--to-es2015/static-private/output.js index fb59212f7c40..62441abec88b 100644 --- a/packages/babel-plugin-proposal-decorators/test/fixtures/2023-01-fields--to-es2015/static-private/output.js +++ b/packages/babel-plugin-proposal-decorators/test/fixtures/2023-01-fields--to-es2015/static-private/output.js @@ -5,11 +5,11 @@ class Foo {} return babelHelpers.classStaticPrivateFieldSpecGet(this, Foo, _a); }, function (value) { babelHelpers.classStaticPrivateFieldSpecSet(this, Foo, _a, value); -}, _ => babelHelpers.checkInRHS(_) === Foo], [dec, 5, "b", function () { +}], [dec, 5, "b", function () { return babelHelpers.classStaticPrivateFieldSpecGet(this, Foo, _b); }, function (value) { babelHelpers.classStaticPrivateFieldSpecSet(this, Foo, _b, value); -}, _ => babelHelpers.checkInRHS(_) === Foo]], []).e; +}]], []).e; var _a = { writable: true, value: _init_a(Foo) diff --git a/packages/babel-plugin-proposal-decorators/test/fixtures/2023-01-fields/private/output.js b/packages/babel-plugin-proposal-decorators/test/fixtures/2023-01-fields/private/output.js index 227b9ad0c160..c875ddf8b786 100644 --- a/packages/babel-plugin-proposal-decorators/test/fixtures/2023-01-fields/private/output.js +++ b/packages/babel-plugin-proposal-decorators/test/fixtures/2023-01-fields/private/output.js @@ -6,11 +6,11 @@ class Foo { return this.#a; }, function (value) { this.#a = value; - }, _ => #a in _], [dec, 0, "b", function () { + }], [dec, 0, "b", function () { return this.#b; }, function (value) { this.#b = value; - }, _ => #b in _]], []).e; + }]], [], _ => #b in _).e; } #a = _init_a(this); #b = _init_b(this, 123); diff --git a/packages/babel-plugin-proposal-decorators/test/fixtures/2023-01-fields/static-private/output.js b/packages/babel-plugin-proposal-decorators/test/fixtures/2023-01-fields/static-private/output.js index cdbfdf39a575..f4277774d8ce 100644 --- a/packages/babel-plugin-proposal-decorators/test/fixtures/2023-01-fields/static-private/output.js +++ b/packages/babel-plugin-proposal-decorators/test/fixtures/2023-01-fields/static-private/output.js @@ -6,11 +6,11 @@ class Foo { return this.#a; }, function (value) { this.#a = value; - }, _ => #a in _], [dec, 5, "b", function () { + }], [dec, 5, "b", function () { return this.#b; }, function (value) { this.#b = value; - }, _ => #b in _]], []).e; + }]], []).e; } static #a = _init_a(this); static #b = _init_b(this, 123); diff --git a/packages/babel-plugin-proposal-decorators/test/fixtures/2023-01-getters--to-es2015/private/output.js b/packages/babel-plugin-proposal-decorators/test/fixtures/2023-01-getters--to-es2015/private/output.js index 77d74e975ecb..c3a4d559cec1 100644 --- a/packages/babel-plugin-proposal-decorators/test/fixtures/2023-01-getters--to-es2015/private/output.js +++ b/packages/babel-plugin-proposal-decorators/test/fixtures/2023-01-getters--to-es2015/private/output.js @@ -19,4 +19,4 @@ function _get_a() { } [_call_a, _initProto] = babelHelpers.applyDecs2301(Foo, [[dec, 3, "a", function () { return this.value; -}, _ => _a.has(babelHelpers.checkInRHS(_))]], []).e; +}]], [], _ => _a.has(babelHelpers.checkInRHS(_))).e; diff --git a/packages/babel-plugin-proposal-decorators/test/fixtures/2023-01-getters--to-es2015/static-private/output.js b/packages/babel-plugin-proposal-decorators/test/fixtures/2023-01-getters--to-es2015/static-private/output.js index 01b21f3c7303..98ae05095661 100644 --- a/packages/babel-plugin-proposal-decorators/test/fixtures/2023-01-getters--to-es2015/static-private/output.js +++ b/packages/babel-plugin-proposal-decorators/test/fixtures/2023-01-getters--to-es2015/static-private/output.js @@ -15,7 +15,7 @@ var _a = { (() => { [_call_a, _initStatic] = babelHelpers.applyDecs2301(Foo, [[dec, 8, "a", function () { return this.value; - }, _ => babelHelpers.checkInRHS(_) === Foo]], []).e; + }]], []).e; _initStatic(Foo); })(); babelHelpers.defineProperty(Foo, "value", 1); diff --git a/packages/babel-plugin-proposal-decorators/test/fixtures/2023-01-getters-and-setters--to-es2015/private/output.js b/packages/babel-plugin-proposal-decorators/test/fixtures/2023-01-getters-and-setters--to-es2015/private/output.js index e7f1972d195e..bb503fb9f577 100644 --- a/packages/babel-plugin-proposal-decorators/test/fixtures/2023-01-getters-and-setters--to-es2015/private/output.js +++ b/packages/babel-plugin-proposal-decorators/test/fixtures/2023-01-getters-and-setters--to-es2015/private/output.js @@ -25,6 +25,6 @@ function _set_a(v) { } [_call_a, _call_a2, _initProto] = babelHelpers.applyDecs2301(Foo, [[dec, 3, "a", function () { return this.value; -}, _ => _a.has(babelHelpers.checkInRHS(_))], [dec, 4, "a", function (v) { +}], [dec, 4, "a", function (v) { this.value = v; -}, _ => _a.has(babelHelpers.checkInRHS(_))]], []).e; +}]], [], _ => _a.has(babelHelpers.checkInRHS(_))).e; diff --git a/packages/babel-plugin-proposal-decorators/test/fixtures/2023-01-getters-and-setters--to-es2015/static-private/output.js b/packages/babel-plugin-proposal-decorators/test/fixtures/2023-01-getters-and-setters--to-es2015/static-private/output.js index f98b7cf38449..c36e28d689f6 100644 --- a/packages/babel-plugin-proposal-decorators/test/fixtures/2023-01-getters-and-setters--to-es2015/static-private/output.js +++ b/packages/babel-plugin-proposal-decorators/test/fixtures/2023-01-getters-and-setters--to-es2015/static-private/output.js @@ -21,9 +21,9 @@ var _a = { (() => { [_call_a, _call_a2, _initStatic] = babelHelpers.applyDecs2301(Foo, [[dec, 8, "a", function () { return this.value; - }, _ => babelHelpers.checkInRHS(_) === Foo], [dec, 9, "a", function (v) { + }], [dec, 9, "a", function (v) { this.value = v; - }, _ => babelHelpers.checkInRHS(_) === Foo]], []).e; + }]], []).e; _initStatic(Foo); })(); babelHelpers.defineProperty(Foo, "value", 1); diff --git a/packages/babel-plugin-proposal-decorators/test/fixtures/2023-01-getters-and-setters/private/output.js b/packages/babel-plugin-proposal-decorators/test/fixtures/2023-01-getters-and-setters/private/output.js index a3143704a39a..d3e63656c91c 100644 --- a/packages/babel-plugin-proposal-decorators/test/fixtures/2023-01-getters-and-setters/private/output.js +++ b/packages/babel-plugin-proposal-decorators/test/fixtures/2023-01-getters-and-setters/private/output.js @@ -4,9 +4,9 @@ class Foo { static { [_call_a, _call_a2, _initProto] = babelHelpers.applyDecs2301(this, [[dec, 3, "a", function () { return this.value; - }, _ => #a in _], [dec, 4, "a", function (v) { + }], [dec, 4, "a", function (v) { this.value = v; - }, _ => #a in _]], []).e; + }]], [], _ => #a in _).e; } constructor(...args) { _initProto(this); diff --git a/packages/babel-plugin-proposal-decorators/test/fixtures/2023-01-getters-and-setters/static-private/output.js b/packages/babel-plugin-proposal-decorators/test/fixtures/2023-01-getters-and-setters/static-private/output.js index bf9c4d33801c..6ab3c888227b 100644 --- a/packages/babel-plugin-proposal-decorators/test/fixtures/2023-01-getters-and-setters/static-private/output.js +++ b/packages/babel-plugin-proposal-decorators/test/fixtures/2023-01-getters-and-setters/static-private/output.js @@ -4,9 +4,9 @@ class Foo { static { [_call_a, _call_a2, _initStatic] = babelHelpers.applyDecs2301(this, [[dec, 8, "a", function () { return this.value; - }, _ => #a in _], [dec, 9, "a", function (v) { + }], [dec, 9, "a", function (v) { this.value = v; - }, _ => #a in _]], []).e; + }]], []).e; _initStatic(this); } static value = 1; diff --git a/packages/babel-plugin-proposal-decorators/test/fixtures/2023-01-getters/private/output.js b/packages/babel-plugin-proposal-decorators/test/fixtures/2023-01-getters/private/output.js index 25830a14452c..aa2ee78b680a 100644 --- a/packages/babel-plugin-proposal-decorators/test/fixtures/2023-01-getters/private/output.js +++ b/packages/babel-plugin-proposal-decorators/test/fixtures/2023-01-getters/private/output.js @@ -4,7 +4,7 @@ class Foo { static { [_call_a, _initProto] = babelHelpers.applyDecs2301(this, [[dec, 3, "a", function () { return this.value; - }, _ => #a in _]], []).e; + }]], [], _ => #a in _).e; } constructor(...args) { _initProto(this); diff --git a/packages/babel-plugin-proposal-decorators/test/fixtures/2023-01-getters/static-private/output.js b/packages/babel-plugin-proposal-decorators/test/fixtures/2023-01-getters/static-private/output.js index f44de79d021a..16853b029714 100644 --- a/packages/babel-plugin-proposal-decorators/test/fixtures/2023-01-getters/static-private/output.js +++ b/packages/babel-plugin-proposal-decorators/test/fixtures/2023-01-getters/static-private/output.js @@ -4,7 +4,7 @@ class Foo { static { [_call_a, _initStatic] = babelHelpers.applyDecs2301(this, [[dec, 8, "a", function () { return this.value; - }, _ => #a in _]], []).e; + }]], []).e; _initStatic(this); } static value = 1; diff --git a/packages/babel-plugin-proposal-decorators/test/fixtures/2023-01-methods--to-es2015/private/output.js b/packages/babel-plugin-proposal-decorators/test/fixtures/2023-01-methods--to-es2015/private/output.js index 3074a64136c2..88bd08521712 100644 --- a/packages/babel-plugin-proposal-decorators/test/fixtures/2023-01-methods--to-es2015/private/output.js +++ b/packages/babel-plugin-proposal-decorators/test/fixtures/2023-01-methods--to-es2015/private/output.js @@ -16,4 +16,4 @@ class Foo { } [_call_a, _initProto] = babelHelpers.applyDecs2301(Foo, [[dec, 2, "a", function () { return this.value; -}, _ => _a.has(babelHelpers.checkInRHS(_))]], []).e; +}]], [], _ => _a.has(babelHelpers.checkInRHS(_))).e; diff --git a/packages/babel-plugin-proposal-decorators/test/fixtures/2023-01-methods--to-es2015/static-private/output.js b/packages/babel-plugin-proposal-decorators/test/fixtures/2023-01-methods--to-es2015/static-private/output.js index 86176c435fd2..37add57acdd1 100644 --- a/packages/babel-plugin-proposal-decorators/test/fixtures/2023-01-methods--to-es2015/static-private/output.js +++ b/packages/babel-plugin-proposal-decorators/test/fixtures/2023-01-methods--to-es2015/static-private/output.js @@ -8,7 +8,7 @@ class Foo { (() => { [_call_a, _initStatic] = babelHelpers.applyDecs2301(Foo, [[dec, 7, "a", function () { return this.value; - }, _ => babelHelpers.checkInRHS(_) === Foo]], []).e; + }]], []).e; _initStatic(Foo); })(); var _a = { diff --git a/packages/babel-plugin-proposal-decorators/test/fixtures/2023-01-methods/private/output.js b/packages/babel-plugin-proposal-decorators/test/fixtures/2023-01-methods/private/output.js index 5792be67795d..1a093ee88e38 100644 --- a/packages/babel-plugin-proposal-decorators/test/fixtures/2023-01-methods/private/output.js +++ b/packages/babel-plugin-proposal-decorators/test/fixtures/2023-01-methods/private/output.js @@ -4,7 +4,7 @@ class Foo { static { [_call_a, _initProto] = babelHelpers.applyDecs2301(this, [[dec, 2, "a", function () { return this.value; - }, _ => #a in _]], []).e; + }]], [], _ => #a in _).e; } constructor(...args) { _initProto(this); diff --git a/packages/babel-plugin-proposal-decorators/test/fixtures/2023-01-methods/static-private/output.js b/packages/babel-plugin-proposal-decorators/test/fixtures/2023-01-methods/static-private/output.js index b59f975820bf..ee2073fb7892 100644 --- a/packages/babel-plugin-proposal-decorators/test/fixtures/2023-01-methods/static-private/output.js +++ b/packages/babel-plugin-proposal-decorators/test/fixtures/2023-01-methods/static-private/output.js @@ -4,7 +4,7 @@ class Foo { static { [_call_a, _initStatic] = babelHelpers.applyDecs2301(this, [[dec, 7, "a", function () { return this.value; - }, _ => #a in _]], []).e; + }]], []).e; _initStatic(this); } static #a = _call_a; diff --git a/packages/babel-plugin-proposal-decorators/test/fixtures/2023-01-misc/all-decorators/output.js b/packages/babel-plugin-proposal-decorators/test/fixtures/2023-01-misc/all-decorators/output.js index d31796ad665c..2588e1d7445b 100644 --- a/packages/babel-plugin-proposal-decorators/test/fixtures/2023-01-misc/all-decorators/output.js +++ b/packages/babel-plugin-proposal-decorators/test/fixtures/2023-01-misc/all-decorators/output.js @@ -8,23 +8,23 @@ new class extends babelHelpers.identity { ({ e: [_init_m, _call_o, _call_p, _call_q, _init_r, _get_r, _set_r, _init_d, _call_f, _call_g, _call_g2, _init_h, _get_h, _set_h, _init_i, _init_n, _init_a, _init_e, _initProto, _initStatic], c: [_Class, _initClass] - } = babelHelpers.applyDecs2301(this, [[dec, 7, "j"], [dec, 8, "k"], [dec, 9, "l"], [dec, 6, "m"], [dec, 7, "o", function () {}, _ => #o in _], [dec, 8, "p", function () {}, _ => #p in _], [dec, 9, "q", function (v) {}, _ => #q in _], [dec, 6, "r", function () { + } = babelHelpers.applyDecs2301(this, [[dec, 7, "j"], [dec, 8, "k"], [dec, 9, "l"], [dec, 6, "m"], [dec, 7, "o", function () {}], [dec, 8, "p", function () {}], [dec, 9, "q", function (v) {}], [dec, 6, "r", function () { return this.#D; }, function (value) { this.#D = value; - }, _ => #D in _], [dec, 2, "b"], [dec, 3, "c"], [dec, 4, "c"], [dec, 1, "d"], [dec, 2, "f", function () {}, _ => #f in _], [dec, 3, "g", function () {}, _ => #g in _], [dec, 4, "g", function (v) {}, _ => #g in _], [dec, 1, "h", function () { + }], [dec, 2, "b"], [dec, 3, "c"], [dec, 4, "c"], [dec, 1, "d"], [dec, 2, "f", function () {}], [dec, 3, "g", function () {}], [dec, 4, "g", function (v) {}], [dec, 1, "h", function () { return this.#B; }, function (value) { this.#B = value; - }, _ => #B in _], [dec, 5, "i"], [dec, 5, "n", function () { + }], [dec, 5, "i"], [dec, 5, "n", function () { return this.#n; }, function (value) { this.#n = value; - }, _ => #n in _], [dec, 0, "a"], [dec, 0, "e", function () { + }], [dec, 0, "a"], [dec, 0, "e", function () { return this.#e; }, function (value) { this.#e = value; - }, _ => #e in _]], [dec])); + }]], [dec], _ => #e in _)); _initStatic(this); } #f = _call_f; diff --git a/packages/babel-plugin-proposal-decorators/test/fixtures/2023-01-misc/super-in-private-accessor/output.js b/packages/babel-plugin-proposal-decorators/test/fixtures/2023-01-misc/super-in-private-accessor/output.js index 36144a8b744f..4319528e4129 100644 --- a/packages/babel-plugin-proposal-decorators/test/fixtures/2023-01-misc/super-in-private-accessor/output.js +++ b/packages/babel-plugin-proposal-decorators/test/fixtures/2023-01-misc/super-in-private-accessor/output.js @@ -4,7 +4,7 @@ class Foo extends Bar { static { [_call_x, _initProto] = babelHelpers.applyDecs2301(this, [[dec, 3, "x", function () { return babelHelpers.get(babelHelpers.getPrototypeOf(Foo), "foo", this).call(this); - }, _ => #x in _]], []).e; + }]], [], _ => #x in _).e; } constructor(...args) { super(...args); diff --git a/packages/babel-plugin-proposal-decorators/test/fixtures/2023-01-misc/super-in-private-method/output.js b/packages/babel-plugin-proposal-decorators/test/fixtures/2023-01-misc/super-in-private-method/output.js index a2265789b3c8..10c86c690683 100644 --- a/packages/babel-plugin-proposal-decorators/test/fixtures/2023-01-misc/super-in-private-method/output.js +++ b/packages/babel-plugin-proposal-decorators/test/fixtures/2023-01-misc/super-in-private-method/output.js @@ -4,7 +4,7 @@ class Foo extends Bar { static { [_call_x, _initProto] = babelHelpers.applyDecs2301(this, [[dec, 2, "x", function () { return babelHelpers.get(babelHelpers.getPrototypeOf(Foo), "foo", this).call(this); - }, _ => #x in _]], []).e; + }]], [], _ => #x in _).e; } constructor(...args) { super(...args); diff --git a/packages/babel-plugin-proposal-decorators/test/fixtures/2023-01-setters--to-es2015/private/output.js b/packages/babel-plugin-proposal-decorators/test/fixtures/2023-01-setters--to-es2015/private/output.js index 949f0980592f..28a954ff3228 100644 --- a/packages/babel-plugin-proposal-decorators/test/fixtures/2023-01-setters--to-es2015/private/output.js +++ b/packages/babel-plugin-proposal-decorators/test/fixtures/2023-01-setters--to-es2015/private/output.js @@ -19,4 +19,4 @@ function _set_a(v) { } [_call_a, _initProto] = babelHelpers.applyDecs2301(Foo, [[dec, 4, "a", function (v) { return this.value = v; -}, _ => _a.has(babelHelpers.checkInRHS(_))]], []).e; +}]], [], _ => _a.has(babelHelpers.checkInRHS(_))).e; diff --git a/packages/babel-plugin-proposal-decorators/test/fixtures/2023-01-setters--to-es2015/static-private/output.js b/packages/babel-plugin-proposal-decorators/test/fixtures/2023-01-setters--to-es2015/static-private/output.js index 50049f8e9728..81b70713008f 100644 --- a/packages/babel-plugin-proposal-decorators/test/fixtures/2023-01-setters--to-es2015/static-private/output.js +++ b/packages/babel-plugin-proposal-decorators/test/fixtures/2023-01-setters--to-es2015/static-private/output.js @@ -15,7 +15,7 @@ var _a = { (() => { [_call_a, _initStatic] = babelHelpers.applyDecs2301(Foo, [[dec, 9, "a", function (v) { return this.value = v; - }, _ => babelHelpers.checkInRHS(_) === Foo]], []).e; + }]], []).e; _initStatic(Foo); })(); babelHelpers.defineProperty(Foo, "value", 1); diff --git a/packages/babel-plugin-proposal-decorators/test/fixtures/2023-01-setters/private/output.js b/packages/babel-plugin-proposal-decorators/test/fixtures/2023-01-setters/private/output.js index 8daaac2ce161..d95063e256e6 100644 --- a/packages/babel-plugin-proposal-decorators/test/fixtures/2023-01-setters/private/output.js +++ b/packages/babel-plugin-proposal-decorators/test/fixtures/2023-01-setters/private/output.js @@ -4,7 +4,7 @@ class Foo { static { [_call_a, _initProto] = babelHelpers.applyDecs2301(this, [[dec, 4, "a", function (v) { return this.value = v; - }, _ => #a in _]], []).e; + }]], [], _ => #a in _).e; } constructor(...args) { _initProto(this); diff --git a/packages/babel-plugin-proposal-decorators/test/fixtures/2023-01-setters/static-private/output.js b/packages/babel-plugin-proposal-decorators/test/fixtures/2023-01-setters/static-private/output.js index 1e626133aa4c..2ec483f1d1f4 100644 --- a/packages/babel-plugin-proposal-decorators/test/fixtures/2023-01-setters/static-private/output.js +++ b/packages/babel-plugin-proposal-decorators/test/fixtures/2023-01-setters/static-private/output.js @@ -4,7 +4,7 @@ class Foo { static { [_call_a, _initStatic] = babelHelpers.applyDecs2301(this, [[dec, 9, "a", function (v) { return this.value = v; - }, _ => #a in _]], []).e; + }]], []).e; _initStatic(this); } static value = 1;