diff --git a/src/decorator/accessor-deco-invalid-return-get.case b/src/decorator/accessor-deco-invalid-return-get.case index f92aaf4da18..9aeb0987d9e 100644 --- a/src/decorator/accessor-deco-invalid-return-get.case +++ b/src/decorator/accessor-deco-invalid-return-get.case @@ -2,7 +2,7 @@ // This code is governed by the BSD license found in the LICENSE file. /*--- -esid: sec-initializefieldoraccessor +esid: sec-applydecoratorstoelementdefinition desc: Accessor decorator cannot return invalid getter template: accessors/error/**/* features: [decorators] diff --git a/src/decorator/accessor-deco-invalid-return-init.case b/src/decorator/accessor-deco-invalid-return-init.case index 62eb4a686a7..3986808be56 100644 --- a/src/decorator/accessor-deco-invalid-return-init.case +++ b/src/decorator/accessor-deco-invalid-return-init.case @@ -2,7 +2,7 @@ // This code is governed by the BSD license found in the LICENSE file. /*--- -esid: sec-initializefieldoraccessor +esid: sec-applydecoratorstoelementdefinition desc: Accessor decorator cannot return invalid init template: accessors/error/**/* features: [decorators] diff --git a/src/decorator/accessor-deco-invalid-return-set.case b/src/decorator/accessor-deco-invalid-return-set.case index 86fae1760b6..8c3b0a300c3 100644 --- a/src/decorator/accessor-deco-invalid-return-set.case +++ b/src/decorator/accessor-deco-invalid-return-set.case @@ -2,7 +2,7 @@ // This code is governed by the BSD license found in the LICENSE file. /*--- -esid: sec-initializefieldoraccessor +esid: sec-applydecoratorstoelementdefinition desc: Accessor decorator cannot return invalid setter template: accessors/error/**/* features: [decorators] diff --git a/src/decorator/accessor-deco-invalid-return.case b/src/decorator/accessor-deco-invalid-return.case index 70c59cbcc05..86dc47e2023 100644 --- a/src/decorator/accessor-deco-invalid-return.case +++ b/src/decorator/accessor-deco-invalid-return.case @@ -2,7 +2,7 @@ // This code is governed by the BSD license found in the LICENSE file. /*--- -esid: sec-initializefieldoraccessor +esid: sec-applydecoratorstoelementdefinition desc: Accessor decorator cannot return invalid init template: accessors/error/**/* features: [decorators] diff --git a/src/decorator/accessor-deco-returns-get.case b/src/decorator/accessor-deco-returns-get.case index e9d114f1e51..7bb02efeb0e 100644 --- a/src/decorator/accessor-deco-returns-get.case +++ b/src/decorator/accessor-deco-returns-get.case @@ -2,7 +2,7 @@ // This code is governed by the BSD license found in the LICENSE file. /*--- -esid: sec-initializefieldoraccessor +esid: sec-applydecoratorstoelementdefinition desc: Accessor decorator can return a new getter template: accessors/standard/**/* features: [decorators] diff --git a/src/decorator/accessor-deco-returns-init.case b/src/decorator/accessor-deco-returns-init.case index 526ce829e59..27a1966daa0 100644 --- a/src/decorator/accessor-deco-returns-init.case +++ b/src/decorator/accessor-deco-returns-init.case @@ -2,7 +2,7 @@ // This code is governed by the BSD license found in the LICENSE file. /*--- -esid: sec-initializefieldoraccessor +esid: sec-applydecoratorstoelementdefinition desc: Accessor decorator can return a new init template: accessors/standard/**/* features: [decorators] diff --git a/src/decorator/accessor-deco-returns-set.case b/src/decorator/accessor-deco-returns-set.case index d44093744ae..7447e9def8c 100644 --- a/src/decorator/accessor-deco-returns-set.case +++ b/src/decorator/accessor-deco-returns-set.case @@ -2,7 +2,7 @@ // This code is governed by the BSD license found in the LICENSE file. /*--- -esid: sec-initializefieldoraccessor +esid: sec-applydecoratorstoelementdefinition desc: Accessor decorator can return a new getter template: accessors/standard/**/* features: [decorators] diff --git a/src/decorator/accessor-with-init-deco-returns-get.case b/src/decorator/accessor-with-init-deco-returns-get.case index 7c776acc0eb..13ab031c827 100644 --- a/src/decorator/accessor-with-init-deco-returns-get.case +++ b/src/decorator/accessor-with-init-deco-returns-get.case @@ -2,7 +2,7 @@ // This code is governed by the BSD license found in the LICENSE file. /*--- -esid: sec-initializefieldoraccessor +esid: sec-applydecoratorstoelementdefinition desc: Accessor decorator can return a new getter template: accessors/with-init/**/* features: [decorators] diff --git a/src/decorator/accessor-with-init-deco-returns-init.case b/src/decorator/accessor-with-init-deco-returns-init.case index 3bcda3f8545..1c7b07338f5 100644 --- a/src/decorator/accessor-with-init-deco-returns-init.case +++ b/src/decorator/accessor-with-init-deco-returns-init.case @@ -2,7 +2,7 @@ // This code is governed by the BSD license found in the LICENSE file. /*--- -esid: sec-initializefieldoraccessor +esid: sec-applydecoratorstoelementdefinition desc: Accessor decorator can return a new init that chains with default initializer template: accessors/with-init/**/* features: [decorators] diff --git a/src/decorator/accessor-with-init-deco-returns-set.case b/src/decorator/accessor-with-init-deco-returns-set.case index abbebba8356..dc484f0fc6c 100644 --- a/src/decorator/accessor-with-init-deco-returns-set.case +++ b/src/decorator/accessor-with-init-deco-returns-set.case @@ -2,7 +2,7 @@ // This code is governed by the BSD license found in the LICENSE file. /*--- -esid: sec-initializefieldoraccessor +esid: sec-applydecoratorstoelementdefinition desc: Accessor decorator can return a new setter when initializer is present template: accessors/with-init/**/* features: [decorators] diff --git a/src/decorator/class-deco-invalid-return-arrow.case b/src/decorator/class-deco-invalid-return-arrow.case index 23580a75e8c..863e2a5157f 100644 --- a/src/decorator/class-deco-invalid-return-arrow.case +++ b/src/decorator/class-deco-invalid-return-arrow.case @@ -2,7 +2,7 @@ // This code is governed by the BSD license found in the LICENSE file. /*--- -esid: sec-initializefieldoraccessor +esid: sec-applydecoratorstoclassdefinition desc: Class decorator cannot return non-newable function (arrow) template: class/error features: [decorators] diff --git a/src/decorator/class-deco-invalid-return-primitive.case b/src/decorator/class-deco-invalid-return-primitive.case index 666ec7b4f91..b90d74ea2e3 100644 --- a/src/decorator/class-deco-invalid-return-primitive.case +++ b/src/decorator/class-deco-invalid-return-primitive.case @@ -2,7 +2,7 @@ // This code is governed by the BSD license found in the LICENSE file. /*--- -esid: sec-initializefieldoraccessor +esid: sec-applydecoratorstoclassdefinition desc: Class decorator cannot return a random non-newable value template: class/error features: [decorators] diff --git a/src/decorator/class-deco-rebinds-identifier.case b/src/decorator/class-deco-rebinds-identifier.case index b0c4a383d47..7ad3400a9f0 100644 --- a/src/decorator/class-deco-rebinds-identifier.case +++ b/src/decorator/class-deco-rebinds-identifier.case @@ -2,7 +2,7 @@ // This code is governed by the BSD license found in the LICENSE file. /*--- -esid: sec-createdecoratorcontextobject +esid: sec-applydecoratorstoclassdefinition desc: Class decorator return value is rebound before static fields are run template: class/standard/cls-decl.template features: [decorators] diff --git a/src/decorator/class-deco-returns-class.case b/src/decorator/class-deco-returns-class.case index b3dcce769b3..870dc82c8b7 100644 --- a/src/decorator/class-deco-returns-class.case +++ b/src/decorator/class-deco-returns-class.case @@ -2,7 +2,7 @@ // This code is governed by the BSD license found in the LICENSE file. /*--- -esid: sec-createdecoratorcontextobject +esid: sec-applydecoratorstoclassdefinition desc: Class decorator can return a new class template: class/standard features: [decorators] diff --git a/src/decorator/class-deco-returns-function.case b/src/decorator/class-deco-returns-function.case index 0329b52f053..c0e1f9925b0 100644 --- a/src/decorator/class-deco-returns-function.case +++ b/src/decorator/class-deco-returns-function.case @@ -2,7 +2,7 @@ // This code is governed by the BSD license found in the LICENSE file. /*--- -esid: sec-createdecoratorcontextobject +esid: sec-applydecoratorstoclassdefinition desc: Class decorator can return a standard function template: class/standard features: [decorators] diff --git a/src/decorator/class-deco-returns-proxy.case b/src/decorator/class-deco-returns-proxy.case index 85d6451e258..e3ec78abd95 100644 --- a/src/decorator/class-deco-returns-proxy.case +++ b/src/decorator/class-deco-returns-proxy.case @@ -2,7 +2,7 @@ // This code is governed by the BSD license found in the LICENSE file. /*--- -esid: sec-createdecoratorcontextobject +esid: sec-applydecoratorstoclassdefinition desc: Class decorator can return a Proxy template: class/standard features: [decorators, Proxy] diff --git a/src/decorator/class-deco-returns-subclass.case b/src/decorator/class-deco-returns-subclass.case index 0812217ee2e..af6ac2d5dd0 100644 --- a/src/decorator/class-deco-returns-subclass.case +++ b/src/decorator/class-deco-returns-subclass.case @@ -2,7 +2,7 @@ // This code is governed by the BSD license found in the LICENSE file. /*--- -esid: sec-createdecoratorcontextobject +esid: sec-applydecoratorstoclassdefinition desc: Class decorator can return a new class template: class/standard features: [decorators] diff --git a/src/decorator/class/error/cls-decl.template b/src/decorator/class/error/cls-decl.template index 3274ad16ada..e1db2431c04 100644 --- a/src/decorator/class/error/cls-decl.template +++ b/src/decorator/class/error/cls-decl.template @@ -5,7 +5,7 @@ path: language/statements/class/decorator/class/error/ name: class decorator evaluation error in class declaration features: [class, decorators] -esid: prod-MethodDefinition +esid: prod-ClassDeclaration ---*/ /*{ decorators }*/ diff --git a/src/decorator/class/error/cls-expr.template b/src/decorator/class/error/cls-expr.template index 553eed15f9b..1faaa7daecf 100644 --- a/src/decorator/class/error/cls-expr.template +++ b/src/decorator/class/error/cls-expr.template @@ -5,7 +5,7 @@ path: language/expressions/class/decorator/class/error/ name: private method decorator evaluation error in class expression features: [class, decorators, class-methods-private] -esid: prod-MethodDefinition +esid: prod-ClassExpression ---*/ /*{ decorators }*/ diff --git a/src/decorator/class/standard/cls-decl.template b/src/decorator/class/standard/cls-decl.template index acb4c9e6e28..9ab5774f734 100644 --- a/src/decorator/class/standard/cls-decl.template +++ b/src/decorator/class/standard/cls-decl.template @@ -5,7 +5,7 @@ path: language/statements/class/decorator/class/ name: decorator usage in a class declaration features: [class] -esid: prod-FieldDefinition +esid: prod-ClassDeclaration ---*/ /*{ decorators }*/ diff --git a/src/decorator/class/standard/cls-expr.template b/src/decorator/class/standard/cls-expr.template index 99954cd70d7..ff78d62e6cb 100644 --- a/src/decorator/class/standard/cls-expr.template +++ b/src/decorator/class/standard/cls-expr.template @@ -5,7 +5,7 @@ path: language/expressions/class/decorator/class/ name: decorator usage in a class expression features: [class] -esid: prod-FieldDefinition +esid: prod-FieldExpression ---*/ /*{ decorators }*/ diff --git a/src/decorator/class/with-super-class/cls-decl.template b/src/decorator/class/with-super-class/cls-decl.template index 98ef3bfe517..e3158b4e439 100644 --- a/src/decorator/class/with-super-class/cls-decl.template +++ b/src/decorator/class/with-super-class/cls-decl.template @@ -5,7 +5,7 @@ path: language/statements/class/decorator/class/with-super-class/ name: decorator usage in a class declaration features: [class] -esid: prod-FieldDefinition +esid: prod-ClassDeclaration ---*/ /*{ decorators }*/ diff --git a/src/decorator/class/with-super-class/cls-expr.template b/src/decorator/class/with-super-class/cls-expr.template index 436309564e5..b437f9fbd2c 100644 --- a/src/decorator/class/with-super-class/cls-expr.template +++ b/src/decorator/class/with-super-class/cls-expr.template @@ -5,7 +5,7 @@ path: language/expressions/class/decorator/class/with-super-class/ name: decorator usage in a class expression features: [class] -esid: prod-FieldDefinition +esid: prod-ClassExpression ---*/ /*{ decorators }*/ diff --git a/src/decorator/decorator-order-application-field-and-accessor.case b/src/decorator/decorator-order-application-field-and-accessor.case index 711fc2fa494..89973932846 100644 --- a/src/decorator/decorator-order-application-field-and-accessor.case +++ b/src/decorator/decorator-order-application-field-and-accessor.case @@ -2,7 +2,7 @@ // This code is governed by the BSD license found in the LICENSE file. /*--- -esid: sec-runtime-semantics-classdefinitionevaluation +esid: sec-ecmascript-function-objects-construct-argumentslist-newtarget desc: Order of decorator application for elements with initializers templates: - accessors/with-init/**/* diff --git a/src/decorator/decorator-order-phases-4-init-instance.case b/src/decorator/decorator-order-phases-4-init-instance.case index 8b26a38a9ca..f3fef58ba29 100644 --- a/src/decorator/decorator-order-phases-4-init-instance.case +++ b/src/decorator/decorator-order-phases-4-init-instance.case @@ -2,7 +2,7 @@ // This code is governed by the BSD license found in the LICENSE file. /*--- -esid: sec-runtime-semantics-classdefinitionevaluation +esid: sec-ecmascript-function-objects-construct-argumentslist-newtarget desc: Class instance creation order info: | Class instances are created in the following order: diff --git a/src/decorator/field-init-this.case b/src/decorator/field-and-accessor-init-this.case similarity index 69% rename from src/decorator/field-init-this.case rename to src/decorator/field-and-accessor-init-this.case index 572d4b912b8..e4ee2d7d967 100644 --- a/src/decorator/field-init-this.case +++ b/src/decorator/field-and-accessor-init-this.case @@ -4,17 +4,23 @@ /*--- esid: sec-initializefieldoraccessor desc: Field initializer `this` value is the instance or the class -template: fields/with-init/**/* +templates: + - fields/standard/**/* + - fields/with-init/**/* + - accessors/standard/**/* + - accessors/with-init/**/* features: [decorators] ---*/ //- decorators var savedThisValues = []; -function dec(value) { - return function(value) { +function dec(value, context) { + function init (value) { savedThisValues.push(this); } + + return context.kind === 'field' ? init : { init }; } //- application diff --git a/src/decorator/getter-deco-returns-invalid.case b/src/decorator/getter-deco-returns-invalid.case index 9f976364f14..76be0bf5bd2 100644 --- a/src/decorator/getter-deco-returns-invalid.case +++ b/src/decorator/getter-deco-returns-invalid.case @@ -2,7 +2,7 @@ // This code is governed by the BSD license found in the LICENSE file. /*--- -esid: sec-createdecoratorcontextobject +esid: sec-applydecoratorstoelementdefinition desc: Decorator can't return an invalid value template: getters/error/**/* features: [decorators] diff --git a/src/decorator/getter-deco-returns-replacement.case b/src/decorator/getter-deco-returns-replacement.case index c159c848f2e..17633d78967 100644 --- a/src/decorator/getter-deco-returns-replacement.case +++ b/src/decorator/getter-deco-returns-replacement.case @@ -2,7 +2,7 @@ // This code is governed by the BSD license found in the LICENSE file. /*--- -esid: sec-createdecoratorcontextobject +esid: sec-applydecoratorstoelementdefinition desc: Can replace a decorated getter with a new getter template: getters/standard/**/* features: [decorators] diff --git a/src/decorator/getter-deco-returns-undefined.case b/src/decorator/getter-deco-returns-undefined.case index 261363f60e1..b0b5ea91b77 100644 --- a/src/decorator/getter-deco-returns-undefined.case +++ b/src/decorator/getter-deco-returns-undefined.case @@ -2,7 +2,7 @@ // This code is governed by the BSD license found in the LICENSE file. /*--- -esid: sec-createdecoratorcontextobject +esid: sec-applydecoratorstoelementdefinition desc: Decorator undefined return defaults to previous value template: getters/standard/**/* features: [decorators] diff --git a/src/decorator/method-async-deco-returns-replacement.case b/src/decorator/method-async-deco-returns-replacement.case index 51710d1f398..5df2cca1d62 100644 --- a/src/decorator/method-async-deco-returns-replacement.case +++ b/src/decorator/method-async-deco-returns-replacement.case @@ -2,7 +2,7 @@ // This code is governed by the BSD license found in the LICENSE file. /*--- -esid: sec-createdecoratorcontextobject +esid: sec-applydecoratorstoelementdefinition desc: Can replace a decorated method with a new method template: methods/async/**/* features: [decorators] diff --git a/src/decorator/method-async-deco-returns-undefined.case b/src/decorator/method-async-deco-returns-undefined.case index 65c62505cb5..2077acc3bfe 100644 --- a/src/decorator/method-async-deco-returns-undefined.case +++ b/src/decorator/method-async-deco-returns-undefined.case @@ -2,7 +2,7 @@ // This code is governed by the BSD license found in the LICENSE file. /*--- -esid: sec-createdecoratorcontextobject +esid: sec-applydecoratorstoelementdefinition desc: Decorator undefined return defaults to previous value template: methods/async/**/* features: [decorators] diff --git a/src/decorator/method-deco-returns-invalid.case b/src/decorator/method-deco-returns-invalid.case index d9aa7f8bc0a..45fa6a79831 100644 --- a/src/decorator/method-deco-returns-invalid.case +++ b/src/decorator/method-deco-returns-invalid.case @@ -2,7 +2,7 @@ // This code is governed by the BSD license found in the LICENSE file. /*--- -esid: sec-createdecoratorcontextobject +esid: sec-applydecoratorstoelementdefinition desc: Decorator can't return an invalid value template: methods/error/**/* features: [decorators] diff --git a/src/decorator/method-deco-returns-replacement.case b/src/decorator/method-deco-returns-replacement.case index accfd6fc203..4518c8e26cc 100644 --- a/src/decorator/method-deco-returns-replacement.case +++ b/src/decorator/method-deco-returns-replacement.case @@ -2,7 +2,7 @@ // This code is governed by the BSD license found in the LICENSE file. /*--- -esid: sec-createdecoratorcontextobject +esid: sec-applydecoratorstoelementdefinition desc: Can replace a decorated method with a new method template: methods/standard/**/* features: [decorators] diff --git a/src/decorator/method-deco-returns-undefined.case b/src/decorator/method-deco-returns-undefined.case index b78e7fee0c4..7c33a57b430 100644 --- a/src/decorator/method-deco-returns-undefined.case +++ b/src/decorator/method-deco-returns-undefined.case @@ -2,7 +2,7 @@ // This code is governed by the BSD license found in the LICENSE file. /*--- -esid: sec-createdecoratorcontextobject +esid: sec-applydecoratorstoelementdefinition desc: Decorator undefined return defaults to previous value template: methods/standard/**/* features: [decorators] diff --git a/src/decorator/method-generator-deco-returns-replacement.case b/src/decorator/method-generator-deco-returns-replacement.case index d7c4421ecc7..8e18d39695e 100644 --- a/src/decorator/method-generator-deco-returns-replacement.case +++ b/src/decorator/method-generator-deco-returns-replacement.case @@ -2,7 +2,7 @@ // This code is governed by the BSD license found in the LICENSE file. /*--- -esid: sec-createdecoratorcontextobject +esid: sec-applydecoratorstoelementdefinition desc: Can replace a decorated method with a new method template: methods/generator/**/* features: [decorators] diff --git a/src/decorator/method-generator-deco-returns-undefined.case b/src/decorator/method-generator-deco-returns-undefined.case index 206c43729e5..bc8c13244f8 100644 --- a/src/decorator/method-generator-deco-returns-undefined.case +++ b/src/decorator/method-generator-deco-returns-undefined.case @@ -2,7 +2,7 @@ // This code is governed by the BSD license found in the LICENSE file. /*--- -esid: sec-createdecoratorcontextobject +esid: sec-applydecoratorstoelementdefinition desc: Decorator undefined return defaults to previous value template: methods/generator/**/* features: [decorators] diff --git a/src/decorator/setter-deco-returns-invalid.case b/src/decorator/setter-deco-returns-invalid.case index 41bfbe52964..bf4867ec8e0 100644 --- a/src/decorator/setter-deco-returns-invalid.case +++ b/src/decorator/setter-deco-returns-invalid.case @@ -2,7 +2,7 @@ // This code is governed by the BSD license found in the LICENSE file. /*--- -esid: sec-createdecoratorcontextobject +esid: sec-applydecoratorstoelementdefinition desc: Decorator can't return an invalid value template: setters/error/**/* features: [decorators] diff --git a/src/decorator/setter-deco-returns-replacement.case b/src/decorator/setter-deco-returns-replacement.case index 2dad8d83ce7..9413c5590c5 100644 --- a/src/decorator/setter-deco-returns-replacement.case +++ b/src/decorator/setter-deco-returns-replacement.case @@ -2,7 +2,7 @@ // This code is governed by the BSD license found in the LICENSE file. /*--- -esid: sec-createdecoratorcontextobject +esid: sec-applydecoratorstoelementdefinition desc: Can replace a decorated setter with a new setter template: setters/standard/**/* features: [decorators] diff --git a/src/decorator/setter-deco-returns-undefined.case b/src/decorator/setter-deco-returns-undefined.case index 2a5c0af77b3..afe4755d54c 100644 --- a/src/decorator/setter-deco-returns-undefined.case +++ b/src/decorator/setter-deco-returns-undefined.case @@ -2,7 +2,7 @@ // This code is governed by the BSD license found in the LICENSE file. /*--- -esid: sec-createdecoratorcontextobject +esid: sec-applydecoratorstoelementdefinition desc: Decorator undefined return defaults to previous value template: setters/standard/**/* features: [decorators] diff --git a/test/language/expressions/class/decorator/accessor/private/instance/field-and-accessor-init-this.js b/test/language/expressions/class/decorator/accessor/private/instance/field-and-accessor-init-this.js new file mode 100644 index 00000000000..69b3a5e4da9 --- /dev/null +++ b/test/language/expressions/class/decorator/accessor/private/instance/field-and-accessor-init-this.js @@ -0,0 +1,39 @@ +// This file was procedurally generated from the following sources: +// - src/decorator/field-and-accessor-init-this.case +// - src/decorator/accessors/standard/private/instance/cls-expr.template +/*--- +description: Field initializer `this` value is the instance or the class (private acessor decorator behavior in class expression) +esid: prod-FieldDefinition +features: [decorators, class, class-fields-private] +flags: [generated] +---*/ + + +var savedThisValues = []; + +function dec(value, context) { + function init (value) { + savedThisValues.push(this); + } + + return context.kind === 'field' ? init : { init }; +} + + +var C = class { + @dec + + accessor #element; + + getElement() { + return this.#element; + } + + setElement(value) { + this.#element = value; + } +} + +var classOrInstance = new C(); + +savedThisValues.forEach((v) => assert.sameValue(v, classOrInstance)); diff --git a/test/language/expressions/class/decorator/accessor/private/static/field-and-accessor-init-this.js b/test/language/expressions/class/decorator/accessor/private/static/field-and-accessor-init-this.js new file mode 100644 index 00000000000..6ee32121421 --- /dev/null +++ b/test/language/expressions/class/decorator/accessor/private/static/field-and-accessor-init-this.js @@ -0,0 +1,39 @@ +// This file was procedurally generated from the following sources: +// - src/decorator/field-and-accessor-init-this.case +// - src/decorator/accessors/standard/private/static/cls-expr.template +/*--- +description: Field initializer `this` value is the instance or the class (private static acessor decorator behavior in class expression) +esid: prod-FieldDefinition +features: [decorators, class, class-static-fields-private] +flags: [generated] +---*/ + + +var savedThisValues = []; + +function dec(value, context) { + function init (value) { + savedThisValues.push(this); + } + + return context.kind === 'field' ? init : { init }; +} + + +var C = class { + @dec + + static accessor #element; + + static getElement() { + return this.#element; + } + + static setElement(value) { + this.#element = value; + } +} + +var classOrInstance = C; + +savedThisValues.forEach((v) => assert.sameValue(v, classOrInstance)); diff --git a/test/language/expressions/class/decorator/accessor/public/instance/field-and-accessor-init-this.js b/test/language/expressions/class/decorator/accessor/public/instance/field-and-accessor-init-this.js new file mode 100644 index 00000000000..4e4ee7a691a --- /dev/null +++ b/test/language/expressions/class/decorator/accessor/public/instance/field-and-accessor-init-this.js @@ -0,0 +1,39 @@ +// This file was procedurally generated from the following sources: +// - src/decorator/field-and-accessor-init-this.case +// - src/decorator/accessors/standard/public/instance/cls-expr.template +/*--- +description: Field initializer `this` value is the instance or the class (public acessor decorator behavior in class expression) +esid: prod-FieldDefinition +features: [decorators, class, class-fields-public] +flags: [generated] +---*/ + + +var savedThisValues = []; + +function dec(value, context) { + function init (value) { + savedThisValues.push(this); + } + + return context.kind === 'field' ? init : { init }; +} + + +var C = class { + @dec + + accessor element; + + getElement() { + return this.element; + } + + setElement(value) { + this.element = value; + } +} + +var classOrInstance = new C(); + +savedThisValues.forEach((v) => assert.sameValue(v, classOrInstance)); diff --git a/test/language/expressions/class/decorator/accessor/public/static/field-and-accessor-init-this.js b/test/language/expressions/class/decorator/accessor/public/static/field-and-accessor-init-this.js new file mode 100644 index 00000000000..7cff1fb3db9 --- /dev/null +++ b/test/language/expressions/class/decorator/accessor/public/static/field-and-accessor-init-this.js @@ -0,0 +1,39 @@ +// This file was procedurally generated from the following sources: +// - src/decorator/field-and-accessor-init-this.case +// - src/decorator/accessors/standard/public/static/cls-expr.template +/*--- +description: Field initializer `this` value is the instance or the class (public static acessor decorator behavior in class expression) +esid: prod-FieldDefinition +features: [decorators, class, class-static-fields-public] +flags: [generated] +---*/ + + +var savedThisValues = []; + +function dec(value, context) { + function init (value) { + savedThisValues.push(this); + } + + return context.kind === 'field' ? init : { init }; +} + + +var C = class { + @dec + + static accessor element; + + static getElement() { + return this.element; + } + + static setElement(value) { + this.element = value; + } +} + +var classOrInstance = C; + +savedThisValues.forEach((v) => assert.sameValue(v, classOrInstance)); diff --git a/test/language/expressions/class/decorator/accessor/with-init/private/instance/field-and-accessor-init-this.js b/test/language/expressions/class/decorator/accessor/with-init/private/instance/field-and-accessor-init-this.js new file mode 100644 index 00000000000..8694dc4f9d7 --- /dev/null +++ b/test/language/expressions/class/decorator/accessor/with-init/private/instance/field-and-accessor-init-this.js @@ -0,0 +1,40 @@ +// This file was procedurally generated from the following sources: +// - src/decorator/field-and-accessor-init-this.case +// - src/decorator/accessors/with-init/private/instance/cls-expr.template +/*--- +description: Field initializer `this` value is the instance or the class (private accessor with initializer decorator behavior in class expression) +esid: prod-FieldDefinition +features: [decorators, class, class-fields-private] +flags: [generated] +---*/ + + +var savedThisValues = []; + +function dec(value, context) { + function init (value) { + savedThisValues.push(this); + } + + return context.kind === 'field' ? init : { init }; +} + + +var C = class { + @dec + + accessor #element = savedThisValues.push(this); +; + + getElement() { + return this.#element; + } + + setElement(value) { + this.#element = value; + } +} + +var classOrInstance = new C(); + +savedThisValues.forEach((v) => assert.sameValue(v, classOrInstance)); diff --git a/test/language/expressions/class/decorator/accessor/with-init/private/static/field-and-accessor-init-this.js b/test/language/expressions/class/decorator/accessor/with-init/private/static/field-and-accessor-init-this.js new file mode 100644 index 00000000000..719561e1248 --- /dev/null +++ b/test/language/expressions/class/decorator/accessor/with-init/private/static/field-and-accessor-init-this.js @@ -0,0 +1,40 @@ +// This file was procedurally generated from the following sources: +// - src/decorator/field-and-accessor-init-this.case +// - src/decorator/accessors/with-init/private/static/cls-expr.template +/*--- +description: Field initializer `this` value is the instance or the class (private static with initializer acessor decorator behavior in class expression) +esid: prod-FieldDefinition +features: [decorators, class, class-static-fields-private] +flags: [generated] +---*/ + + +var savedThisValues = []; + +function dec(value, context) { + function init (value) { + savedThisValues.push(this); + } + + return context.kind === 'field' ? init : { init }; +} + + +var C = class { + @dec + + static accessor #element = savedThisValues.push(this); +; + + static getElement() { + return this.#element; + } + + static setElement(value) { + this.#element = value; + } +} + +var classOrInstance = C; + +savedThisValues.forEach((v) => assert.sameValue(v, classOrInstance)); diff --git a/test/language/expressions/class/decorator/accessor/with-init/public/instance/field-and-accessor-init-this.js b/test/language/expressions/class/decorator/accessor/with-init/public/instance/field-and-accessor-init-this.js new file mode 100644 index 00000000000..64408b46c14 --- /dev/null +++ b/test/language/expressions/class/decorator/accessor/with-init/public/instance/field-and-accessor-init-this.js @@ -0,0 +1,40 @@ +// This file was procedurally generated from the following sources: +// - src/decorator/field-and-accessor-init-this.case +// - src/decorator/accessors/with-init/public/instance/cls-expr.template +/*--- +description: Field initializer `this` value is the instance or the class (public accessor with initializer decorator behavior in class expression) +esid: prod-FieldDefinition +features: [decorators, class, class-fields-public] +flags: [generated] +---*/ + + +var savedThisValues = []; + +function dec(value, context) { + function init (value) { + savedThisValues.push(this); + } + + return context.kind === 'field' ? init : { init }; +} + + +var C = class { + @dec + + accessor element = savedThisValues.push(this); +; + + getElement() { + return this.element; + } + + setElement(value) { + this.element = value; + } +} + +var classOrInstance = new C(); + +savedThisValues.forEach((v) => assert.sameValue(v, classOrInstance)); diff --git a/test/language/expressions/class/decorator/accessor/with-init/public/static/field-and-accessor-init-this.js b/test/language/expressions/class/decorator/accessor/with-init/public/static/field-and-accessor-init-this.js new file mode 100644 index 00000000000..6bd09e450f8 --- /dev/null +++ b/test/language/expressions/class/decorator/accessor/with-init/public/static/field-and-accessor-init-this.js @@ -0,0 +1,40 @@ +// This file was procedurally generated from the following sources: +// - src/decorator/field-and-accessor-init-this.case +// - src/decorator/accessors/with-init/public/static/cls-expr.template +/*--- +description: Field initializer `this` value is the instance or the class (public static with initializer acessor decorator behavior in class expression) +esid: prod-FieldDefinition +features: [decorators, class, class-static-fields-public] +flags: [generated] +---*/ + + +var savedThisValues = []; + +function dec(value, context) { + function init (value) { + savedThisValues.push(this); + } + + return context.kind === 'field' ? init : { init }; +} + + +var C = class { + @dec + + static accessor element = savedThisValues.push(this); +; + + static getElement() { + return this.element; + } + + static setElement(value) { + this.element = value; + } +} + +var classOrInstance = C; + +savedThisValues.forEach((v) => assert.sameValue(v, classOrInstance)); diff --git a/test/language/expressions/class/decorator/class/class-deco-returns-class.js b/test/language/expressions/class/decorator/class/class-deco-returns-class.js index 10d5686b924..8f929feee6e 100644 --- a/test/language/expressions/class/decorator/class/class-deco-returns-class.js +++ b/test/language/expressions/class/decorator/class/class-deco-returns-class.js @@ -3,7 +3,7 @@ // - src/decorator/class/standard/cls-expr.template /*--- description: Class decorator can return a new class (decorator usage in a class expression) -esid: prod-FieldDefinition +esid: prod-FieldExpression features: [decorators, class] flags: [generated] ---*/ diff --git a/test/language/expressions/class/decorator/class/class-deco-returns-function.js b/test/language/expressions/class/decorator/class/class-deco-returns-function.js index 48152eadd00..05a09f4fca4 100644 --- a/test/language/expressions/class/decorator/class/class-deco-returns-function.js +++ b/test/language/expressions/class/decorator/class/class-deco-returns-function.js @@ -3,7 +3,7 @@ // - src/decorator/class/standard/cls-expr.template /*--- description: Class decorator can return a standard function (decorator usage in a class expression) -esid: prod-FieldDefinition +esid: prod-FieldExpression features: [decorators, class] flags: [generated] ---*/ diff --git a/test/language/expressions/class/decorator/class/class-deco-returns-proxy.js b/test/language/expressions/class/decorator/class/class-deco-returns-proxy.js index b1368c5bc3f..83e772953d3 100644 --- a/test/language/expressions/class/decorator/class/class-deco-returns-proxy.js +++ b/test/language/expressions/class/decorator/class/class-deco-returns-proxy.js @@ -3,7 +3,7 @@ // - src/decorator/class/standard/cls-expr.template /*--- description: Class decorator can return a Proxy (decorator usage in a class expression) -esid: prod-FieldDefinition +esid: prod-FieldExpression features: [decorators, Proxy, class] flags: [generated] ---*/ diff --git a/test/language/expressions/class/decorator/class/class-deco-returns-subclass.js b/test/language/expressions/class/decorator/class/class-deco-returns-subclass.js index 7eca3c3ff80..8f5cccad2eb 100644 --- a/test/language/expressions/class/decorator/class/class-deco-returns-subclass.js +++ b/test/language/expressions/class/decorator/class/class-deco-returns-subclass.js @@ -3,7 +3,7 @@ // - src/decorator/class/standard/cls-expr.template /*--- description: Class decorator can return a new class (decorator usage in a class expression) -esid: prod-FieldDefinition +esid: prod-FieldExpression features: [decorators, class] flags: [generated] ---*/ diff --git a/test/language/expressions/class/decorator/class/context-kind-class.js b/test/language/expressions/class/decorator/class/context-kind-class.js index 18a749185dd..6b122652bf5 100644 --- a/test/language/expressions/class/decorator/class/context-kind-class.js +++ b/test/language/expressions/class/decorator/class/context-kind-class.js @@ -3,7 +3,7 @@ // - src/decorator/class/standard/cls-expr.template /*--- description: Context kind is the string "class" when decorating a method (decorator usage in a class expression) -esid: prod-FieldDefinition +esid: prod-FieldExpression features: [decorators, class] flags: [generated] ---*/ diff --git a/test/language/expressions/class/decorator/class/context-name-class.js b/test/language/expressions/class/decorator/class/context-name-class.js index cb5134057ae..29eb9ad27c2 100644 --- a/test/language/expressions/class/decorator/class/context-name-class.js +++ b/test/language/expressions/class/decorator/class/context-name-class.js @@ -3,7 +3,7 @@ // - src/decorator/class/standard/cls-expr.template /*--- description: Name of the class is correct on the context object (decorator usage in a class expression) -esid: prod-FieldDefinition +esid: prod-FieldExpression features: [decorators, class] flags: [generated] ---*/ diff --git a/test/language/expressions/class/decorator/class/decorator-order-application-method-and-class.js b/test/language/expressions/class/decorator/class/decorator-order-application-method-and-class.js index a5216d51b2f..ea1746747a9 100644 --- a/test/language/expressions/class/decorator/class/decorator-order-application-method-and-class.js +++ b/test/language/expressions/class/decorator/class/decorator-order-application-method-and-class.js @@ -3,7 +3,7 @@ // - src/decorator/class/standard/cls-expr.template /*--- description: Order of decorator application for elements without initializers (decorator usage in a class expression) -esid: prod-FieldDefinition +esid: prod-FieldExpression features: [decorators, class] flags: [generated] ---*/ diff --git a/test/language/expressions/class/decorator/class/decorator-order-phases-1-pre-definition.js b/test/language/expressions/class/decorator/class/decorator-order-phases-1-pre-definition.js index 1cac757fb6b..914f3615788 100644 --- a/test/language/expressions/class/decorator/class/decorator-order-phases-1-pre-definition.js +++ b/test/language/expressions/class/decorator/class/decorator-order-phases-1-pre-definition.js @@ -3,7 +3,7 @@ // - src/decorator/class/standard/cls-expr.template /*--- description: Class pre-definition evaluation phase order (decorator usage in a class expression) -esid: prod-FieldDefinition +esid: prod-FieldExpression features: [decorators, class] flags: [generated] info: | diff --git a/test/language/expressions/class/decorator/class/decorator-order-phases-2-application.js b/test/language/expressions/class/decorator/class/decorator-order-phases-2-application.js index cb67af3c9ad..e9f5310bf4c 100644 --- a/test/language/expressions/class/decorator/class/decorator-order-phases-2-application.js +++ b/test/language/expressions/class/decorator/class/decorator-order-phases-2-application.js @@ -3,7 +3,7 @@ // - src/decorator/class/standard/cls-expr.template /*--- description: Class definition decorator application order (decorator usage in a class expression) -esid: prod-FieldDefinition +esid: prod-FieldExpression features: [decorators, class] flags: [generated] info: | diff --git a/test/language/expressions/class/decorator/class/decorator-order-phases-3-init-static.js b/test/language/expressions/class/decorator/class/decorator-order-phases-3-init-static.js index 486d8dcfc00..7bb5b755847 100644 --- a/test/language/expressions/class/decorator/class/decorator-order-phases-3-init-static.js +++ b/test/language/expressions/class/decorator/class/decorator-order-phases-3-init-static.js @@ -3,7 +3,7 @@ // - src/decorator/class/standard/cls-expr.template /*--- description: Class definition static initialization order (decorator usage in a class expression) -esid: prod-FieldDefinition +esid: prod-FieldExpression features: [decorators, class] flags: [generated] info: | diff --git a/test/language/expressions/class/decorator/class/decorator-order-phases.js b/test/language/expressions/class/decorator/class/decorator-order-phases.js index db440f01687..ad3fff1a91e 100644 --- a/test/language/expressions/class/decorator/class/decorator-order-phases.js +++ b/test/language/expressions/class/decorator/class/decorator-order-phases.js @@ -3,7 +3,7 @@ // - src/decorator/class/standard/cls-expr.template /*--- description: Order of decorators (decorator usage in a class expression) -esid: prod-FieldDefinition +esid: prod-FieldExpression features: [decorators, class] flags: [generated] info: | diff --git a/test/language/expressions/class/decorator/class/error/class-deco-invalid-return-arrow.js b/test/language/expressions/class/decorator/class/error/class-deco-invalid-return-arrow.js index f76a40b74fc..b62b4460116 100644 --- a/test/language/expressions/class/decorator/class/error/class-deco-invalid-return-arrow.js +++ b/test/language/expressions/class/decorator/class/error/class-deco-invalid-return-arrow.js @@ -3,7 +3,7 @@ // - src/decorator/class/error/cls-expr.template /*--- description: Class decorator cannot return non-newable function (arrow) (private method decorator evaluation error in class expression) -esid: prod-MethodDefinition +esid: prod-ClassExpression features: [decorators, class, class-methods-private] flags: [generated] ---*/ diff --git a/test/language/expressions/class/decorator/class/error/class-deco-invalid-return-primitive.js b/test/language/expressions/class/decorator/class/error/class-deco-invalid-return-primitive.js index 7af6b880b58..e329b506f9e 100644 --- a/test/language/expressions/class/decorator/class/error/class-deco-invalid-return-primitive.js +++ b/test/language/expressions/class/decorator/class/error/class-deco-invalid-return-primitive.js @@ -3,7 +3,7 @@ // - src/decorator/class/error/cls-expr.template /*--- description: Class decorator cannot return a random non-newable value (private method decorator evaluation error in class expression) -esid: prod-MethodDefinition +esid: prod-ClassExpression features: [decorators, class, class-methods-private] flags: [generated] ---*/ diff --git a/test/language/expressions/class/decorator/class/with-super-class/decorator-order-phases-4-init-instance.js b/test/language/expressions/class/decorator/class/with-super-class/decorator-order-phases-4-init-instance.js index 69771400f66..a221c0c70b7 100644 --- a/test/language/expressions/class/decorator/class/with-super-class/decorator-order-phases-4-init-instance.js +++ b/test/language/expressions/class/decorator/class/with-super-class/decorator-order-phases-4-init-instance.js @@ -3,7 +3,7 @@ // - src/decorator/class/with-super-class/cls-expr.template /*--- description: Class instance creation order (decorator usage in a class expression) -esid: prod-FieldDefinition +esid: prod-ClassExpression features: [decorators, class] flags: [generated] info: | diff --git a/test/language/expressions/class/decorator/field/private/instance/field-and-accessor-init-this.js b/test/language/expressions/class/decorator/field/private/instance/field-and-accessor-init-this.js new file mode 100644 index 00000000000..75204cbaef2 --- /dev/null +++ b/test/language/expressions/class/decorator/field/private/instance/field-and-accessor-init-this.js @@ -0,0 +1,39 @@ +// This file was procedurally generated from the following sources: +// - src/decorator/field-and-accessor-init-this.case +// - src/decorator/fields/standard/private/instance/cls-expr.template +/*--- +description: Field initializer `this` value is the instance or the class (private field decorator behavior in class expression) +esid: prod-FieldDefinition +features: [decorators, class, class-fields-private] +flags: [generated] +---*/ + + +var savedThisValues = []; + +function dec(value, context) { + function init (value) { + savedThisValues.push(this); + } + + return context.kind === 'field' ? init : { init }; +} + + +var C = class { + @dec + + #element; + + getElement() { + return this.#element; + } + + setElement(value) { + this.#element = value; + } +} + +var classOrInstance = new C(); + +savedThisValues.forEach((v) => assert.sameValue(v, classOrInstance)); diff --git a/test/language/expressions/class/decorator/field/private/static/field-and-accessor-init-this.js b/test/language/expressions/class/decorator/field/private/static/field-and-accessor-init-this.js new file mode 100644 index 00000000000..3fc70c9c346 --- /dev/null +++ b/test/language/expressions/class/decorator/field/private/static/field-and-accessor-init-this.js @@ -0,0 +1,39 @@ +// This file was procedurally generated from the following sources: +// - src/decorator/field-and-accessor-init-this.case +// - src/decorator/fields/standard/private/static/cls-expr.template +/*--- +description: Field initializer `this` value is the instance or the class (private static field decorator behavior in class expression) +esid: prod-FieldDefinition +features: [decorators, class, class-static-fields-private] +flags: [generated] +---*/ + + +var savedThisValues = []; + +function dec(value, context) { + function init (value) { + savedThisValues.push(this); + } + + return context.kind === 'field' ? init : { init }; +} + + +var C = class { + @dec + + static #element; + + static getElement() { + return this.#element; + } + + static setElement(value) { + this.#element = value; + } +} + +var classOrInstance = C; + +savedThisValues.forEach((v) => assert.sameValue(v, classOrInstance)); diff --git a/test/language/expressions/class/decorator/field/public/instance/field-and-accessor-init-this.js b/test/language/expressions/class/decorator/field/public/instance/field-and-accessor-init-this.js new file mode 100644 index 00000000000..60cbf47e9bc --- /dev/null +++ b/test/language/expressions/class/decorator/field/public/instance/field-and-accessor-init-this.js @@ -0,0 +1,39 @@ +// This file was procedurally generated from the following sources: +// - src/decorator/field-and-accessor-init-this.case +// - src/decorator/fields/standard/public/instance/cls-expr.template +/*--- +description: Field initializer `this` value is the instance or the class (public field decorator behavior in class expression) +esid: prod-FieldDefinition +features: [decorators, class, class-fields-public] +flags: [generated] +---*/ + + +var savedThisValues = []; + +function dec(value, context) { + function init (value) { + savedThisValues.push(this); + } + + return context.kind === 'field' ? init : { init }; +} + + +var C = class { + @dec + + element; + + getElement() { + return this.element; + } + + setElement(value) { + this.element = value; + } +} + +var classOrInstance = new C(); + +savedThisValues.forEach((v) => assert.sameValue(v, classOrInstance)); diff --git a/test/language/expressions/class/decorator/field/public/static/field-and-accessor-init-this.js b/test/language/expressions/class/decorator/field/public/static/field-and-accessor-init-this.js new file mode 100644 index 00000000000..b2ff9179f32 --- /dev/null +++ b/test/language/expressions/class/decorator/field/public/static/field-and-accessor-init-this.js @@ -0,0 +1,39 @@ +// This file was procedurally generated from the following sources: +// - src/decorator/field-and-accessor-init-this.case +// - src/decorator/fields/standard/public/static/cls-expr.template +/*--- +description: Field initializer `this` value is the instance or the class (public static field decorator behavior in class expression) +esid: prod-FieldDefinition +features: [decorators, class, class-static-fields-public] +flags: [generated] +---*/ + + +var savedThisValues = []; + +function dec(value, context) { + function init (value) { + savedThisValues.push(this); + } + + return context.kind === 'field' ? init : { init }; +} + + +var C = class { + @dec + + static element; + + static getElement() { + return this.element; + } + + static setElement(value) { + this.element = value; + } +} + +var classOrInstance = C; + +savedThisValues.forEach((v) => assert.sameValue(v, classOrInstance)); diff --git a/test/language/expressions/class/decorator/field/with-init/private/instance/field-init-this.js b/test/language/expressions/class/decorator/field/with-init/private/instance/field-and-accessor-init-this.js similarity index 81% rename from test/language/expressions/class/decorator/field/with-init/private/instance/field-init-this.js rename to test/language/expressions/class/decorator/field/with-init/private/instance/field-and-accessor-init-this.js index 8d596d3e09d..1abb84e0cc8 100644 --- a/test/language/expressions/class/decorator/field/with-init/private/instance/field-init-this.js +++ b/test/language/expressions/class/decorator/field/with-init/private/instance/field-and-accessor-init-this.js @@ -1,5 +1,5 @@ // This file was procedurally generated from the following sources: -// - src/decorator/field-init-this.case +// - src/decorator/field-and-accessor-init-this.case // - src/decorator/fields/with-init/private/instance/cls-expr.template /*--- description: Field initializer `this` value is the instance or the class (private field with initializer decorator behavior in class expression) @@ -11,10 +11,12 @@ flags: [generated] var savedThisValues = []; -function dec(value) { - return function(value) { +function dec(value, context) { + function init (value) { savedThisValues.push(this); } + + return context.kind === 'field' ? init : { init }; } diff --git a/test/language/expressions/class/decorator/field/with-init/private/static/field-init-this.js b/test/language/expressions/class/decorator/field/with-init/private/static/field-and-accessor-init-this.js similarity index 82% rename from test/language/expressions/class/decorator/field/with-init/private/static/field-init-this.js rename to test/language/expressions/class/decorator/field/with-init/private/static/field-and-accessor-init-this.js index 61823fea79f..9803e85aef7 100644 --- a/test/language/expressions/class/decorator/field/with-init/private/static/field-init-this.js +++ b/test/language/expressions/class/decorator/field/with-init/private/static/field-and-accessor-init-this.js @@ -1,5 +1,5 @@ // This file was procedurally generated from the following sources: -// - src/decorator/field-init-this.case +// - src/decorator/field-and-accessor-init-this.case // - src/decorator/fields/with-init/private/static/cls-expr.template /*--- description: Field initializer `this` value is the instance or the class (private static with initializer field decorator behavior in class expression) @@ -11,10 +11,12 @@ flags: [generated] var savedThisValues = []; -function dec(value) { - return function(value) { +function dec(value, context) { + function init (value) { savedThisValues.push(this); } + + return context.kind === 'field' ? init : { init }; } diff --git a/test/language/expressions/class/decorator/field/with-init/public/instance/field-init-this.js b/test/language/expressions/class/decorator/field/with-init/public/instance/field-and-accessor-init-this.js similarity index 81% rename from test/language/expressions/class/decorator/field/with-init/public/instance/field-init-this.js rename to test/language/expressions/class/decorator/field/with-init/public/instance/field-and-accessor-init-this.js index c039a0dcf86..bc60d1dcd52 100644 --- a/test/language/expressions/class/decorator/field/with-init/public/instance/field-init-this.js +++ b/test/language/expressions/class/decorator/field/with-init/public/instance/field-and-accessor-init-this.js @@ -1,5 +1,5 @@ // This file was procedurally generated from the following sources: -// - src/decorator/field-init-this.case +// - src/decorator/field-and-accessor-init-this.case // - src/decorator/fields/with-init/public/instance/cls-expr.template /*--- description: Field initializer `this` value is the instance or the class (public field with initializer decorator behavior in class expression) @@ -11,10 +11,12 @@ flags: [generated] var savedThisValues = []; -function dec(value) { - return function(value) { +function dec(value, context) { + function init (value) { savedThisValues.push(this); } + + return context.kind === 'field' ? init : { init }; } diff --git a/test/language/expressions/class/decorator/field/with-init/public/static/field-init-this.js b/test/language/expressions/class/decorator/field/with-init/public/static/field-and-accessor-init-this.js similarity index 82% rename from test/language/expressions/class/decorator/field/with-init/public/static/field-init-this.js rename to test/language/expressions/class/decorator/field/with-init/public/static/field-and-accessor-init-this.js index a80718e3cd1..93ae6f1e7a3 100644 --- a/test/language/expressions/class/decorator/field/with-init/public/static/field-init-this.js +++ b/test/language/expressions/class/decorator/field/with-init/public/static/field-and-accessor-init-this.js @@ -1,5 +1,5 @@ // This file was procedurally generated from the following sources: -// - src/decorator/field-init-this.case +// - src/decorator/field-and-accessor-init-this.case // - src/decorator/fields/with-init/public/static/cls-expr.template /*--- description: Field initializer `this` value is the instance or the class (public static with initializer field decorator behavior in class expression) @@ -11,10 +11,12 @@ flags: [generated] var savedThisValues = []; -function dec(value) { - return function(value) { +function dec(value, context) { + function init (value) { savedThisValues.push(this); } + + return context.kind === 'field' ? init : { init }; } diff --git a/test/language/statements/class/decorator/accessor/private/instance/field-and-accessor-init-this.js b/test/language/statements/class/decorator/accessor/private/instance/field-and-accessor-init-this.js new file mode 100644 index 00000000000..1e209559cf1 --- /dev/null +++ b/test/language/statements/class/decorator/accessor/private/instance/field-and-accessor-init-this.js @@ -0,0 +1,39 @@ +// This file was procedurally generated from the following sources: +// - src/decorator/field-and-accessor-init-this.case +// - src/decorator/accessors/standard/private/instance/cls-decl.template +/*--- +description: Field initializer `this` value is the instance or the class (private acessor decorator behavior in class declaration) +esid: prod-FieldDefinition +features: [decorators, class, class-fields-private] +flags: [generated] +---*/ + + +var savedThisValues = []; + +function dec(value, context) { + function init (value) { + savedThisValues.push(this); + } + + return context.kind === 'field' ? init : { init }; +} + + +class C { + @dec + + accessor #element; + + getElement() { + return this.#element; + } + + setElement(value) { + this.#element = value; + } +} + +var classOrInstance = new C(); + +savedThisValues.forEach((v) => assert.sameValue(v, classOrInstance)); diff --git a/test/language/statements/class/decorator/accessor/private/static/field-and-accessor-init-this.js b/test/language/statements/class/decorator/accessor/private/static/field-and-accessor-init-this.js new file mode 100644 index 00000000000..5a87deac51c --- /dev/null +++ b/test/language/statements/class/decorator/accessor/private/static/field-and-accessor-init-this.js @@ -0,0 +1,39 @@ +// This file was procedurally generated from the following sources: +// - src/decorator/field-and-accessor-init-this.case +// - src/decorator/accessors/standard/private/static/cls-decl.template +/*--- +description: Field initializer `this` value is the instance or the class (private static acessor decorator behavior in class declaration) +esid: prod-FieldDefinition +features: [decorators, class, class-static-fields-private] +flags: [generated] +---*/ + + +var savedThisValues = []; + +function dec(value, context) { + function init (value) { + savedThisValues.push(this); + } + + return context.kind === 'field' ? init : { init }; +} + + +class C { + @dec + + static accessor #element; + + static getElement() { + return this.#element; + } + + static setElement(value) { + this.#element = value; + } +} + +var classOrInstance = C; + +savedThisValues.forEach((v) => assert.sameValue(v, classOrInstance)); diff --git a/test/language/statements/class/decorator/accessor/public/instance/field-and-accessor-init-this.js b/test/language/statements/class/decorator/accessor/public/instance/field-and-accessor-init-this.js new file mode 100644 index 00000000000..cb63e6fbce3 --- /dev/null +++ b/test/language/statements/class/decorator/accessor/public/instance/field-and-accessor-init-this.js @@ -0,0 +1,39 @@ +// This file was procedurally generated from the following sources: +// - src/decorator/field-and-accessor-init-this.case +// - src/decorator/accessors/standard/public/instance/cls-decl.template +/*--- +description: Field initializer `this` value is the instance or the class (public acessor decorator behavior in class declaration) +esid: prod-FieldDefinition +features: [decorators, class, class-fields-public] +flags: [generated] +---*/ + + +var savedThisValues = []; + +function dec(value, context) { + function init (value) { + savedThisValues.push(this); + } + + return context.kind === 'field' ? init : { init }; +} + + +class C { + @dec + + accessor element; + + getElement() { + return this.element; + } + + setElement(value) { + this.element = value; + } +} + +var classOrInstance = new C(); + +savedThisValues.forEach((v) => assert.sameValue(v, classOrInstance)); diff --git a/test/language/statements/class/decorator/accessor/public/static/field-and-accessor-init-this.js b/test/language/statements/class/decorator/accessor/public/static/field-and-accessor-init-this.js new file mode 100644 index 00000000000..4fb7497c8d5 --- /dev/null +++ b/test/language/statements/class/decorator/accessor/public/static/field-and-accessor-init-this.js @@ -0,0 +1,39 @@ +// This file was procedurally generated from the following sources: +// - src/decorator/field-and-accessor-init-this.case +// - src/decorator/accessors/standard/public/static/cls-decl.template +/*--- +description: Field initializer `this` value is the instance or the class (public static acessor decorator behavior in class declaration) +esid: prod-FieldDefinition +features: [decorators, class, class-static-fields-public] +flags: [generated] +---*/ + + +var savedThisValues = []; + +function dec(value, context) { + function init (value) { + savedThisValues.push(this); + } + + return context.kind === 'field' ? init : { init }; +} + + +class C { + @dec + + static accessor element; + + static getElement() { + return this.element; + } + + static setElement(value) { + this.element = value; + } +} + +var classOrInstance = C; + +savedThisValues.forEach((v) => assert.sameValue(v, classOrInstance)); diff --git a/test/language/statements/class/decorator/accessor/with-init/private/instance/field-and-accessor-init-this.js b/test/language/statements/class/decorator/accessor/with-init/private/instance/field-and-accessor-init-this.js new file mode 100644 index 00000000000..6493d1cab09 --- /dev/null +++ b/test/language/statements/class/decorator/accessor/with-init/private/instance/field-and-accessor-init-this.js @@ -0,0 +1,40 @@ +// This file was procedurally generated from the following sources: +// - src/decorator/field-and-accessor-init-this.case +// - src/decorator/accessors/with-init/private/instance/cls-decl.template +/*--- +description: Field initializer `this` value is the instance or the class (private accessor with initializer decorator behavior in class declaration) +esid: prod-FieldDefinition +features: [decorators, class, class-fields-private] +flags: [generated] +---*/ + + +var savedThisValues = []; + +function dec(value, context) { + function init (value) { + savedThisValues.push(this); + } + + return context.kind === 'field' ? init : { init }; +} + + +class C { + @dec + + accessor #element = savedThisValues.push(this); +; + + getElement() { + return this.#element; + } + + setElement(value) { + this.#element = value; + } +} + +var classOrInstance = new C(); + +savedThisValues.forEach((v) => assert.sameValue(v, classOrInstance)); diff --git a/test/language/statements/class/decorator/accessor/with-init/private/static/field-and-accessor-init-this.js b/test/language/statements/class/decorator/accessor/with-init/private/static/field-and-accessor-init-this.js new file mode 100644 index 00000000000..746d715a923 --- /dev/null +++ b/test/language/statements/class/decorator/accessor/with-init/private/static/field-and-accessor-init-this.js @@ -0,0 +1,40 @@ +// This file was procedurally generated from the following sources: +// - src/decorator/field-and-accessor-init-this.case +// - src/decorator/accessors/with-init/private/static/cls-decl.template +/*--- +description: Field initializer `this` value is the instance or the class (private static with initializer acessor decorator behavior in class declaration) +esid: prod-FieldDefinition +features: [decorators, class, class-static-fields-private] +flags: [generated] +---*/ + + +var savedThisValues = []; + +function dec(value, context) { + function init (value) { + savedThisValues.push(this); + } + + return context.kind === 'field' ? init : { init }; +} + + +class C { + @dec + + static accessor #element = savedThisValues.push(this); +; + + static getElement() { + return this.#element; + } + + static setElement(value) { + this.#element = value; + } +} + +var classOrInstance = C; + +savedThisValues.forEach((v) => assert.sameValue(v, classOrInstance)); diff --git a/test/language/statements/class/decorator/accessor/with-init/public/instance/field-and-accessor-init-this.js b/test/language/statements/class/decorator/accessor/with-init/public/instance/field-and-accessor-init-this.js new file mode 100644 index 00000000000..6270b76b5a8 --- /dev/null +++ b/test/language/statements/class/decorator/accessor/with-init/public/instance/field-and-accessor-init-this.js @@ -0,0 +1,40 @@ +// This file was procedurally generated from the following sources: +// - src/decorator/field-and-accessor-init-this.case +// - src/decorator/accessors/with-init/public/instance/cls-decl.template +/*--- +description: Field initializer `this` value is the instance or the class (public accessor with initializer decorator behavior in class declaration) +esid: prod-FieldDefinition +features: [decorators, class, class-fields-public] +flags: [generated] +---*/ + + +var savedThisValues = []; + +function dec(value, context) { + function init (value) { + savedThisValues.push(this); + } + + return context.kind === 'field' ? init : { init }; +} + + +class C { + @dec + + accessor element = savedThisValues.push(this); +; + + getElement() { + return this.element; + } + + setElement(value) { + this.element = value; + } +} + +var classOrInstance = new C(); + +savedThisValues.forEach((v) => assert.sameValue(v, classOrInstance)); diff --git a/test/language/statements/class/decorator/accessor/with-init/public/static/field-and-accessor-init-this.js b/test/language/statements/class/decorator/accessor/with-init/public/static/field-and-accessor-init-this.js new file mode 100644 index 00000000000..c38b881726a --- /dev/null +++ b/test/language/statements/class/decorator/accessor/with-init/public/static/field-and-accessor-init-this.js @@ -0,0 +1,40 @@ +// This file was procedurally generated from the following sources: +// - src/decorator/field-and-accessor-init-this.case +// - src/decorator/accessors/with-init/public/static/cls-decl.template +/*--- +description: Field initializer `this` value is the instance or the class (public static with initializer acessor decorator behavior in class declaration) +esid: prod-FieldDefinition +features: [decorators, class, class-static-fields-public] +flags: [generated] +---*/ + + +var savedThisValues = []; + +function dec(value, context) { + function init (value) { + savedThisValues.push(this); + } + + return context.kind === 'field' ? init : { init }; +} + + +class C { + @dec + + static accessor element = savedThisValues.push(this); +; + + static getElement() { + return this.element; + } + + static setElement(value) { + this.element = value; + } +} + +var classOrInstance = C; + +savedThisValues.forEach((v) => assert.sameValue(v, classOrInstance)); diff --git a/test/language/statements/class/decorator/class/class-deco-rebinds-identifier.js b/test/language/statements/class/decorator/class/class-deco-rebinds-identifier.js index f666960b538..1b84736ebbd 100644 --- a/test/language/statements/class/decorator/class/class-deco-rebinds-identifier.js +++ b/test/language/statements/class/decorator/class/class-deco-rebinds-identifier.js @@ -3,7 +3,7 @@ // - src/decorator/class/standard/cls-decl.template /*--- description: Class decorator return value is rebound before static fields are run (decorator usage in a class declaration) -esid: prod-FieldDefinition +esid: prod-ClassDeclaration features: [decorators, class] flags: [generated] ---*/ diff --git a/test/language/statements/class/decorator/class/class-deco-returns-class.js b/test/language/statements/class/decorator/class/class-deco-returns-class.js index 5d3cf2cca86..a7bbeed79d1 100644 --- a/test/language/statements/class/decorator/class/class-deco-returns-class.js +++ b/test/language/statements/class/decorator/class/class-deco-returns-class.js @@ -3,7 +3,7 @@ // - src/decorator/class/standard/cls-decl.template /*--- description: Class decorator can return a new class (decorator usage in a class declaration) -esid: prod-FieldDefinition +esid: prod-ClassDeclaration features: [decorators, class] flags: [generated] ---*/ diff --git a/test/language/statements/class/decorator/class/class-deco-returns-function.js b/test/language/statements/class/decorator/class/class-deco-returns-function.js index 7bf151614a3..36981021584 100644 --- a/test/language/statements/class/decorator/class/class-deco-returns-function.js +++ b/test/language/statements/class/decorator/class/class-deco-returns-function.js @@ -3,7 +3,7 @@ // - src/decorator/class/standard/cls-decl.template /*--- description: Class decorator can return a standard function (decorator usage in a class declaration) -esid: prod-FieldDefinition +esid: prod-ClassDeclaration features: [decorators, class] flags: [generated] ---*/ diff --git a/test/language/statements/class/decorator/class/class-deco-returns-proxy.js b/test/language/statements/class/decorator/class/class-deco-returns-proxy.js index da397548c7e..a81b700c9aa 100644 --- a/test/language/statements/class/decorator/class/class-deco-returns-proxy.js +++ b/test/language/statements/class/decorator/class/class-deco-returns-proxy.js @@ -3,7 +3,7 @@ // - src/decorator/class/standard/cls-decl.template /*--- description: Class decorator can return a Proxy (decorator usage in a class declaration) -esid: prod-FieldDefinition +esid: prod-ClassDeclaration features: [decorators, Proxy, class] flags: [generated] ---*/ diff --git a/test/language/statements/class/decorator/class/class-deco-returns-subclass.js b/test/language/statements/class/decorator/class/class-deco-returns-subclass.js index 823d6822538..4169f7c314e 100644 --- a/test/language/statements/class/decorator/class/class-deco-returns-subclass.js +++ b/test/language/statements/class/decorator/class/class-deco-returns-subclass.js @@ -3,7 +3,7 @@ // - src/decorator/class/standard/cls-decl.template /*--- description: Class decorator can return a new class (decorator usage in a class declaration) -esid: prod-FieldDefinition +esid: prod-ClassDeclaration features: [decorators, class] flags: [generated] ---*/ diff --git a/test/language/statements/class/decorator/class/context-kind-class.js b/test/language/statements/class/decorator/class/context-kind-class.js index 0308ca00d31..c3053516362 100644 --- a/test/language/statements/class/decorator/class/context-kind-class.js +++ b/test/language/statements/class/decorator/class/context-kind-class.js @@ -3,7 +3,7 @@ // - src/decorator/class/standard/cls-decl.template /*--- description: Context kind is the string "class" when decorating a method (decorator usage in a class declaration) -esid: prod-FieldDefinition +esid: prod-ClassDeclaration features: [decorators, class] flags: [generated] ---*/ diff --git a/test/language/statements/class/decorator/class/context-name-class.js b/test/language/statements/class/decorator/class/context-name-class.js index bf614d38305..131aa5928fe 100644 --- a/test/language/statements/class/decorator/class/context-name-class.js +++ b/test/language/statements/class/decorator/class/context-name-class.js @@ -3,7 +3,7 @@ // - src/decorator/class/standard/cls-decl.template /*--- description: Name of the class is correct on the context object (decorator usage in a class declaration) -esid: prod-FieldDefinition +esid: prod-ClassDeclaration features: [decorators, class] flags: [generated] ---*/ diff --git a/test/language/statements/class/decorator/class/decorator-order-application-method-and-class.js b/test/language/statements/class/decorator/class/decorator-order-application-method-and-class.js index 21bba99bb1c..a51642500fe 100644 --- a/test/language/statements/class/decorator/class/decorator-order-application-method-and-class.js +++ b/test/language/statements/class/decorator/class/decorator-order-application-method-and-class.js @@ -3,7 +3,7 @@ // - src/decorator/class/standard/cls-decl.template /*--- description: Order of decorator application for elements without initializers (decorator usage in a class declaration) -esid: prod-FieldDefinition +esid: prod-ClassDeclaration features: [decorators, class] flags: [generated] ---*/ diff --git a/test/language/statements/class/decorator/class/decorator-order-phases-1-pre-definition.js b/test/language/statements/class/decorator/class/decorator-order-phases-1-pre-definition.js index e1d25854022..df57415587c 100644 --- a/test/language/statements/class/decorator/class/decorator-order-phases-1-pre-definition.js +++ b/test/language/statements/class/decorator/class/decorator-order-phases-1-pre-definition.js @@ -3,7 +3,7 @@ // - src/decorator/class/standard/cls-decl.template /*--- description: Class pre-definition evaluation phase order (decorator usage in a class declaration) -esid: prod-FieldDefinition +esid: prod-ClassDeclaration features: [decorators, class] flags: [generated] info: | diff --git a/test/language/statements/class/decorator/class/decorator-order-phases-2-application.js b/test/language/statements/class/decorator/class/decorator-order-phases-2-application.js index 4aed7776731..52a2db3551a 100644 --- a/test/language/statements/class/decorator/class/decorator-order-phases-2-application.js +++ b/test/language/statements/class/decorator/class/decorator-order-phases-2-application.js @@ -3,7 +3,7 @@ // - src/decorator/class/standard/cls-decl.template /*--- description: Class definition decorator application order (decorator usage in a class declaration) -esid: prod-FieldDefinition +esid: prod-ClassDeclaration features: [decorators, class] flags: [generated] info: | diff --git a/test/language/statements/class/decorator/class/decorator-order-phases-3-init-static.js b/test/language/statements/class/decorator/class/decorator-order-phases-3-init-static.js index 76e908e03b2..7572cabec87 100644 --- a/test/language/statements/class/decorator/class/decorator-order-phases-3-init-static.js +++ b/test/language/statements/class/decorator/class/decorator-order-phases-3-init-static.js @@ -3,7 +3,7 @@ // - src/decorator/class/standard/cls-decl.template /*--- description: Class definition static initialization order (decorator usage in a class declaration) -esid: prod-FieldDefinition +esid: prod-ClassDeclaration features: [decorators, class] flags: [generated] info: | diff --git a/test/language/statements/class/decorator/class/decorator-order-phases.js b/test/language/statements/class/decorator/class/decorator-order-phases.js index 261d116ebf6..854f0729004 100644 --- a/test/language/statements/class/decorator/class/decorator-order-phases.js +++ b/test/language/statements/class/decorator/class/decorator-order-phases.js @@ -3,7 +3,7 @@ // - src/decorator/class/standard/cls-decl.template /*--- description: Order of decorators (decorator usage in a class declaration) -esid: prod-FieldDefinition +esid: prod-ClassDeclaration features: [decorators, class] flags: [generated] info: | diff --git a/test/language/statements/class/decorator/class/error/class-deco-invalid-return-arrow.js b/test/language/statements/class/decorator/class/error/class-deco-invalid-return-arrow.js index a511931a1a5..1ae623cc2f3 100644 --- a/test/language/statements/class/decorator/class/error/class-deco-invalid-return-arrow.js +++ b/test/language/statements/class/decorator/class/error/class-deco-invalid-return-arrow.js @@ -3,7 +3,7 @@ // - src/decorator/class/error/cls-decl.template /*--- description: Class decorator cannot return non-newable function (arrow) (class decorator evaluation error in class declaration) -esid: prod-MethodDefinition +esid: prod-ClassDeclaration features: [decorators, class] flags: [generated] ---*/ diff --git a/test/language/statements/class/decorator/class/error/class-deco-invalid-return-primitive.js b/test/language/statements/class/decorator/class/error/class-deco-invalid-return-primitive.js index 07f37e907b3..413e4397f86 100644 --- a/test/language/statements/class/decorator/class/error/class-deco-invalid-return-primitive.js +++ b/test/language/statements/class/decorator/class/error/class-deco-invalid-return-primitive.js @@ -3,7 +3,7 @@ // - src/decorator/class/error/cls-decl.template /*--- description: Class decorator cannot return a random non-newable value (class decorator evaluation error in class declaration) -esid: prod-MethodDefinition +esid: prod-ClassDeclaration features: [decorators, class] flags: [generated] ---*/ diff --git a/test/language/statements/class/decorator/class/with-super-class/decorator-order-phases-4-init-instance.js b/test/language/statements/class/decorator/class/with-super-class/decorator-order-phases-4-init-instance.js index bbceabb1f0a..d155ed605cc 100644 --- a/test/language/statements/class/decorator/class/with-super-class/decorator-order-phases-4-init-instance.js +++ b/test/language/statements/class/decorator/class/with-super-class/decorator-order-phases-4-init-instance.js @@ -3,7 +3,7 @@ // - src/decorator/class/with-super-class/cls-decl.template /*--- description: Class instance creation order (decorator usage in a class declaration) -esid: prod-FieldDefinition +esid: prod-ClassDeclaration features: [decorators, class] flags: [generated] info: | diff --git a/test/language/statements/class/decorator/field/private/instance/field-and-accessor-init-this.js b/test/language/statements/class/decorator/field/private/instance/field-and-accessor-init-this.js new file mode 100644 index 00000000000..470aabdff5c --- /dev/null +++ b/test/language/statements/class/decorator/field/private/instance/field-and-accessor-init-this.js @@ -0,0 +1,39 @@ +// This file was procedurally generated from the following sources: +// - src/decorator/field-and-accessor-init-this.case +// - src/decorator/fields/standard/private/instance/cls-decl.template +/*--- +description: Field initializer `this` value is the instance or the class (private field decorator behavior in class declaration) +esid: prod-FieldDefinition +features: [decorators, class, class-fields-private] +flags: [generated] +---*/ + + +var savedThisValues = []; + +function dec(value, context) { + function init (value) { + savedThisValues.push(this); + } + + return context.kind === 'field' ? init : { init }; +} + + +class C { + @dec + + #element; + + getElement() { + return this.#element; + } + + setElement(value) { + this.#element = value; + } +} + +var classOrInstance = new C(); + +savedThisValues.forEach((v) => assert.sameValue(v, classOrInstance)); diff --git a/test/language/statements/class/decorator/field/private/static/field-and-accessor-init-this.js b/test/language/statements/class/decorator/field/private/static/field-and-accessor-init-this.js new file mode 100644 index 00000000000..10dd5496872 --- /dev/null +++ b/test/language/statements/class/decorator/field/private/static/field-and-accessor-init-this.js @@ -0,0 +1,39 @@ +// This file was procedurally generated from the following sources: +// - src/decorator/field-and-accessor-init-this.case +// - src/decorator/fields/standard/private/static/cls-decl.template +/*--- +description: Field initializer `this` value is the instance or the class (private static field decorator behavior in class declaration) +esid: prod-FieldDefinition +features: [decorators, class, class-static-fields-private] +flags: [generated] +---*/ + + +var savedThisValues = []; + +function dec(value, context) { + function init (value) { + savedThisValues.push(this); + } + + return context.kind === 'field' ? init : { init }; +} + + +class C { + @dec + + static #element; + + static getElement() { + return this.#element; + } + + static setElement(value) { + this.#element = value; + } +} + +var classOrInstance = C; + +savedThisValues.forEach((v) => assert.sameValue(v, classOrInstance)); diff --git a/test/language/statements/class/decorator/field/public/instance/field-and-accessor-init-this.js b/test/language/statements/class/decorator/field/public/instance/field-and-accessor-init-this.js new file mode 100644 index 00000000000..c0ada983ce4 --- /dev/null +++ b/test/language/statements/class/decorator/field/public/instance/field-and-accessor-init-this.js @@ -0,0 +1,39 @@ +// This file was procedurally generated from the following sources: +// - src/decorator/field-and-accessor-init-this.case +// - src/decorator/fields/standard/public/instance/cls-decl.template +/*--- +description: Field initializer `this` value is the instance or the class (public field decorator behavior in class declaration) +esid: prod-FieldDefinition +features: [decorators, class, class-fields-public] +flags: [generated] +---*/ + + +var savedThisValues = []; + +function dec(value, context) { + function init (value) { + savedThisValues.push(this); + } + + return context.kind === 'field' ? init : { init }; +} + + +class C { + @dec + + element; + + getElement() { + return this.element; + } + + setElement(value) { + this.element = value; + } +} + +var classOrInstance = new C(); + +savedThisValues.forEach((v) => assert.sameValue(v, classOrInstance)); diff --git a/test/language/statements/class/decorator/field/public/static/field-and-accessor-init-this.js b/test/language/statements/class/decorator/field/public/static/field-and-accessor-init-this.js new file mode 100644 index 00000000000..5bd1dacc69b --- /dev/null +++ b/test/language/statements/class/decorator/field/public/static/field-and-accessor-init-this.js @@ -0,0 +1,39 @@ +// This file was procedurally generated from the following sources: +// - src/decorator/field-and-accessor-init-this.case +// - src/decorator/fields/standard/public/static/cls-decl.template +/*--- +description: Field initializer `this` value is the instance or the class (public static field decorator behavior in class declaration) +esid: prod-FieldDefinition +features: [decorators, class, class-static-fields-public] +flags: [generated] +---*/ + + +var savedThisValues = []; + +function dec(value, context) { + function init (value) { + savedThisValues.push(this); + } + + return context.kind === 'field' ? init : { init }; +} + + +class C { + @dec + + static element; + + static getElement() { + return this.element; + } + + static setElement(value) { + this.element = value; + } +} + +var classOrInstance = C; + +savedThisValues.forEach((v) => assert.sameValue(v, classOrInstance)); diff --git a/test/language/statements/class/decorator/field/with-init/private/instance/field-init-this.js b/test/language/statements/class/decorator/field/with-init/private/instance/field-and-accessor-init-this.js similarity index 81% rename from test/language/statements/class/decorator/field/with-init/private/instance/field-init-this.js rename to test/language/statements/class/decorator/field/with-init/private/instance/field-and-accessor-init-this.js index ae16c78bbc0..f372dde69e8 100644 --- a/test/language/statements/class/decorator/field/with-init/private/instance/field-init-this.js +++ b/test/language/statements/class/decorator/field/with-init/private/instance/field-and-accessor-init-this.js @@ -1,5 +1,5 @@ // This file was procedurally generated from the following sources: -// - src/decorator/field-init-this.case +// - src/decorator/field-and-accessor-init-this.case // - src/decorator/fields/with-init/private/instance/cls-decl.template /*--- description: Field initializer `this` value is the instance or the class (private field with initializer decorator behavior in class declaration) @@ -11,10 +11,12 @@ flags: [generated] var savedThisValues = []; -function dec(value) { - return function(value) { +function dec(value, context) { + function init (value) { savedThisValues.push(this); } + + return context.kind === 'field' ? init : { init }; } diff --git a/test/language/statements/class/decorator/field/with-init/private/static/field-init-this.js b/test/language/statements/class/decorator/field/with-init/private/static/field-and-accessor-init-this.js similarity index 82% rename from test/language/statements/class/decorator/field/with-init/private/static/field-init-this.js rename to test/language/statements/class/decorator/field/with-init/private/static/field-and-accessor-init-this.js index b10fd8cecd4..a2fb251938b 100644 --- a/test/language/statements/class/decorator/field/with-init/private/static/field-init-this.js +++ b/test/language/statements/class/decorator/field/with-init/private/static/field-and-accessor-init-this.js @@ -1,5 +1,5 @@ // This file was procedurally generated from the following sources: -// - src/decorator/field-init-this.case +// - src/decorator/field-and-accessor-init-this.case // - src/decorator/fields/with-init/private/static/cls-decl.template /*--- description: Field initializer `this` value is the instance or the class (private static with initializer field decorator behavior in class declaration) @@ -11,10 +11,12 @@ flags: [generated] var savedThisValues = []; -function dec(value) { - return function(value) { +function dec(value, context) { + function init (value) { savedThisValues.push(this); } + + return context.kind === 'field' ? init : { init }; } diff --git a/test/language/statements/class/decorator/field/with-init/public/instance/field-init-this.js b/test/language/statements/class/decorator/field/with-init/public/instance/field-and-accessor-init-this.js similarity index 81% rename from test/language/statements/class/decorator/field/with-init/public/instance/field-init-this.js rename to test/language/statements/class/decorator/field/with-init/public/instance/field-and-accessor-init-this.js index b6361049827..ffa50c9cf0c 100644 --- a/test/language/statements/class/decorator/field/with-init/public/instance/field-init-this.js +++ b/test/language/statements/class/decorator/field/with-init/public/instance/field-and-accessor-init-this.js @@ -1,5 +1,5 @@ // This file was procedurally generated from the following sources: -// - src/decorator/field-init-this.case +// - src/decorator/field-and-accessor-init-this.case // - src/decorator/fields/with-init/public/instance/cls-decl.template /*--- description: Field initializer `this` value is the instance or the class (public field with initializer decorator behavior in class declaration) @@ -11,10 +11,12 @@ flags: [generated] var savedThisValues = []; -function dec(value) { - return function(value) { +function dec(value, context) { + function init (value) { savedThisValues.push(this); } + + return context.kind === 'field' ? init : { init }; } diff --git a/test/language/statements/class/decorator/field/with-init/public/static/field-init-this.js b/test/language/statements/class/decorator/field/with-init/public/static/field-and-accessor-init-this.js similarity index 82% rename from test/language/statements/class/decorator/field/with-init/public/static/field-init-this.js rename to test/language/statements/class/decorator/field/with-init/public/static/field-and-accessor-init-this.js index f2fd840e902..913a624ced3 100644 --- a/test/language/statements/class/decorator/field/with-init/public/static/field-init-this.js +++ b/test/language/statements/class/decorator/field/with-init/public/static/field-and-accessor-init-this.js @@ -1,5 +1,5 @@ // This file was procedurally generated from the following sources: -// - src/decorator/field-init-this.case +// - src/decorator/field-and-accessor-init-this.case // - src/decorator/fields/with-init/public/static/cls-decl.template /*--- description: Field initializer `this` value is the instance or the class (public static with initializer field decorator behavior in class declaration) @@ -11,10 +11,12 @@ flags: [generated] var savedThisValues = []; -function dec(value) { - return function(value) { +function dec(value, context) { + function init (value) { savedThisValues.push(this); } + + return context.kind === 'field' ? init : { init }; }