From 5e7cf259752f500d75c5640b1d72fbf498be9dcd Mon Sep 17 00:00:00 2001 From: Evan Wallace Date: Wed, 15 May 2024 16:20:57 -0400 Subject: [PATCH] fix #3760: implement decorator metadata proposal --- CHANGELOG.md | 25 + .../snapshots/snapshots_lower.txt | 40 +- internal/js_parser/js_parser_lower_class.go | 31 +- internal/js_parser/js_parser_test.go | 22 +- internal/js_parser/ts_parser_test.go | 22 +- internal/runtime/runtime.go | 11 +- scripts/decorator-tests.js | 733 +++++++++++------- scripts/decorator-tests.ts | 98 +++ 8 files changed, 659 insertions(+), 323 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index fcb0f0bef59..799180d22b5 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,6 +2,31 @@ ## Unreleased +* Implement the decorator metadata proposal ([#3760](https://github.com/evanw/esbuild/issues/3760)) + + This release implements the [decorator metadata proposal](https://github.com/tc39/proposal-decorator-metadata), which is a sub-proposal of the [decorators proposal](https://github.com/tc39/proposal-decorators). Microsoft shipped the decorators proposal in [TypeScript 5.0](https://devblogs.microsoft.com/typescript/announcing-typescript-5-0/#decorators) and the decorator metadata proposal in [TypeScript 5.2](https://devblogs.microsoft.com/typescript/announcing-typescript-5-2/#decorator-metadata), so it's important that esbuild also supports both of these features. Here's a quick example: + + ```js + // Shim the "Symbol.metadata" symbol + Symbol.metadata ??= Symbol('Symbol.metadata') + + const track = (_, context) => { + (context.metadata.names ||= []).push(context.name) + } + + class Foo { + @track foo = 1 + @track bar = 2 + } + + // Prints ["foo", "bar"] + console.log(Foo[Symbol.metadata].names) + ``` + + **⚠️ WARNING ⚠️** + + This proposal has been marked as "stage 3" which means "recommended for implementation". However, it's still a work in progress and isn't a part of JavaScript yet, so keep in mind that any code that uses JavaScript decorator metadata may need to be updated as the feature continues to evolve. If/when that happens, I will update esbuild's implementation to match the specification. I will not be supporting old versions of the specification. + * Fix bundled decorators in derived classes ([#3768](https://github.com/evanw/esbuild/issues/3768)) In certain cases, bundling code that uses decorators in a derived class with a class body that references its own class name could previously generate code that crashes at run-time due to an incorrect variable name. This problem has been fixed. Here is an example of code that was compiled incorrectly before this fix: diff --git a/internal/bundler_tests/snapshots/snapshots_lower.txt b/internal/bundler_tests/snapshots/snapshots_lower.txt index 6e444233987..e28e61f08c8 100644 --- a/internal/bundler_tests/snapshots/snapshots_lower.txt +++ b/internal/bundler_tests/snapshots/snapshots_lower.txt @@ -627,10 +627,10 @@ var _foo_dec, _init, _foo; _foo_dec = [dec]; var _Foo = class _Foo { constructor() { - __privateAdd(this, _foo, __runInitializers(_init, 6, this, _Foo)), __runInitializers(_init, 9, this); + __privateAdd(this, _foo, __runInitializers(_init, 8, this, _Foo)), __runInitializers(_init, 11, this); } }; -_init = [, , ,]; +_init = __decoratorStart(null); _foo = new WeakMap(); __decorateElement(_init, 4, "foo", _foo_dec, _Foo, _foo); var Foo = _Foo; @@ -641,10 +641,10 @@ var _foo_dec, _init; _foo_dec = [dec]; var _Foo = class _Foo { constructor() { - __publicField(this, "foo", __runInitializers(_init, 6, this, _Foo)), __runInitializers(_init, 9, this); + __publicField(this, "foo", __runInitializers(_init, 8, this, _Foo)), __runInitializers(_init, 11, this); } }; -_init = [, , ,]; +_init = __decoratorStart(null); __decorateElement(_init, 5, "foo", _foo_dec, _Foo); var Foo = _Foo; @@ -660,7 +660,7 @@ var _Foo = class _Foo { return _Foo; } }; -_init = [, , ,]; +_init = __decoratorStart(null); __decorateElement(_init, 1, "foo", _foo_dec, _Foo); var Foo = _Foo; @@ -670,10 +670,10 @@ var _foo_dec, _init, _foo; _foo_dec = [dec]; var _Foo = class _Foo { }; -_init = [, , ,]; +_init = __decoratorStart(null); _foo = new WeakMap(); __decorateElement(_init, 12, "foo", _foo_dec, _Foo, _foo); -__privateAdd(_Foo, _foo, __runInitializers(_init, 6, _Foo, _Foo)), __runInitializers(_init, 9, _Foo); +__privateAdd(_Foo, _foo, __runInitializers(_init, 8, _Foo, _Foo)), __runInitializers(_init, 11, _Foo); var Foo = _Foo; ---------- /out/base-static-field.js ---------- @@ -682,9 +682,9 @@ var _foo_dec, _init; _foo_dec = [dec]; var _Foo = class _Foo { }; -_init = [, , ,]; +_init = __decoratorStart(null); __decorateElement(_init, 13, "foo", _foo_dec, _Foo); -__publicField(_Foo, "foo", __runInitializers(_init, 6, _Foo, _Foo)), __runInitializers(_init, 9, _Foo); +__publicField(_Foo, "foo", __runInitializers(_init, 8, _Foo, _Foo)), __runInitializers(_init, 11, _Foo); var Foo = _Foo; ---------- /out/base-static-method.js ---------- @@ -696,7 +696,7 @@ var _Foo = class _Foo { return _Foo; } }; -_init = [, , ,]; +_init = __decoratorStart(null); __decorateElement(_init, 9, "foo", _foo_dec, _Foo); __runInitializers(_init, 3, _Foo); var Foo = _Foo; @@ -707,10 +707,10 @@ var _foo_dec, _a, _init, _foo; var _Foo = class _Foo extends (_a = Bar, _foo_dec = [dec], _a) { constructor() { super(...arguments); - __privateAdd(this, _foo, __runInitializers(_init, 6, this, _Foo)), __runInitializers(_init, 9, this); + __privateAdd(this, _foo, __runInitializers(_init, 8, this, _Foo)), __runInitializers(_init, 11, this); } }; -_init = [, , ,]; +_init = __decoratorStart(_a); _foo = new WeakMap(); __decorateElement(_init, 4, "foo", _foo_dec, _Foo, _foo); var Foo = _Foo; @@ -721,10 +721,10 @@ var _foo_dec, _a, _init; var _Foo = class _Foo extends (_a = Bar, _foo_dec = [dec], _a) { constructor() { super(...arguments); - __publicField(this, "foo", __runInitializers(_init, 6, this, _Foo)), __runInitializers(_init, 9, this); + __publicField(this, "foo", __runInitializers(_init, 8, this, _Foo)), __runInitializers(_init, 11, this); } }; -_init = [, , ,]; +_init = __decoratorStart(_a); __decorateElement(_init, 5, "foo", _foo_dec, _Foo); var Foo = _Foo; @@ -740,7 +740,7 @@ var _Foo = class _Foo extends (_a = Bar, _foo_dec = [dec], _a) { return _Foo; } }; -_init = [, , ,]; +_init = __decoratorStart(_a); __decorateElement(_init, 1, "foo", _foo_dec, _Foo); var Foo = _Foo; @@ -749,10 +749,10 @@ var Foo = _Foo; var _foo_dec, _a, _init, _foo; var _Foo = class _Foo extends (_a = Bar, _foo_dec = [dec], _a) { }; -_init = [, , ,]; +_init = __decoratorStart(_a); _foo = new WeakMap(); __decorateElement(_init, 12, "foo", _foo_dec, _Foo, _foo); -__privateAdd(_Foo, _foo, __runInitializers(_init, 6, _Foo, _Foo)), __runInitializers(_init, 9, _Foo); +__privateAdd(_Foo, _foo, __runInitializers(_init, 8, _Foo, _Foo)), __runInitializers(_init, 11, _Foo); var Foo = _Foo; ---------- /out/derived-static-field.js ---------- @@ -760,9 +760,9 @@ var Foo = _Foo; var _foo_dec, _a, _init; var _Foo = class _Foo extends (_a = Bar, _foo_dec = [dec], _a) { }; -_init = [, , ,]; +_init = __decoratorStart(_a); __decorateElement(_init, 13, "foo", _foo_dec, _Foo); -__publicField(_Foo, "foo", __runInitializers(_init, 6, _Foo, _Foo)), __runInitializers(_init, 9, _Foo); +__publicField(_Foo, "foo", __runInitializers(_init, 8, _Foo, _Foo)), __runInitializers(_init, 11, _Foo); var Foo = _Foo; ---------- /out/derived-static-method.js ---------- @@ -773,7 +773,7 @@ var _Foo = class _Foo extends (_a = Bar, _foo_dec = [dec], _a) { return _Foo; } }; -_init = [, , ,]; +_init = __decoratorStart(_a); __decorateElement(_init, 9, "foo", _foo_dec, _Foo); __runInitializers(_init, 3, _Foo); var Foo = _Foo; diff --git a/internal/js_parser/js_parser_lower_class.go b/internal/js_parser/js_parser_lower_class.go index 689ecbb0246..3f6f7d7d161 100644 --- a/internal/js_parser/js_parser_lower_class.go +++ b/internal/js_parser/js_parser_lower_class.go @@ -631,6 +631,7 @@ type lowerClassContext struct { defaultName ast.LocRef ctor *js_ast.EFunction + extendsRef ast.Ref parameterFields []js_ast.Stmt instanceMembers []js_ast.Stmt instancePrivateMethods []js_ast.Stmt @@ -682,6 +683,7 @@ type lowerClassContext struct { func (p *parser) lowerClass(stmt js_ast.Stmt, expr js_ast.Expr, result visitClassResult, nameToKeep string) ([]js_ast.Stmt, js_ast.Expr) { ctx := lowerClassContext{ nameToKeep: nameToKeep, + extendsRef: ast.InvalidRef, decoratorContextRef: ast.InvalidRef, privateInstanceMethodRef: ast.InvalidRef, privateStaticMethodRef: ast.InvalidRef, @@ -857,7 +859,7 @@ func (ctx *lowerClassContext) lowerField( } args := []js_ast.Expr{ {Loc: loc, Data: &js_ast.EIdentifier{Ref: ctx.decoratorContextRef}}, - {Loc: loc, Data: &js_ast.ENumber{Value: float64((3 + 2*initializerIndex) << 1)}}, + {Loc: loc, Data: &js_ast.ENumber{Value: float64((4 + 2*initializerIndex) << 1)}}, value, } if _, ok := init.Data.(*js_ast.EUndefined); !ok { @@ -929,7 +931,7 @@ func (ctx *lowerClassContext) lowerField( } memberExpr = js_ast.JoinWithComma(memberExpr, p.callRuntime(loc, "__runInitializers", []js_ast.Expr{ {Loc: loc, Data: &js_ast.EIdentifier{Ref: ctx.decoratorContextRef}}, - {Loc: loc, Data: &js_ast.ENumber{Value: float64(((4 + 2*initializerIndex) << 1) | 1)}}, + {Loc: loc, Data: &js_ast.ENumber{Value: float64(((5 + 2*initializerIndex) << 1) | 1)}}, value, })) p.recordUsage(ctx.decoratorContextRef) @@ -1402,13 +1404,13 @@ func (ctx *lowerClassContext) hoistComputedProperties(p *parser, classLoweringIn // __publicField(Foo, _a); // if ctx.computedPropertyChain.Data != nil && ctx.class.ExtendsOrNil.Data != nil { - ref := p.generateTempRef(tempRefNeedsDeclare, "") + ctx.extendsRef = p.generateTempRef(tempRefNeedsDeclare, "") ctx.class.ExtendsOrNil = js_ast.JoinWithComma(js_ast.JoinWithComma( - js_ast.Assign(js_ast.Expr{Loc: ctx.class.ExtendsOrNil.Loc, Data: &js_ast.EIdentifier{Ref: ref}}, ctx.class.ExtendsOrNil), + js_ast.Assign(js_ast.Expr{Loc: ctx.class.ExtendsOrNil.Loc, Data: &js_ast.EIdentifier{Ref: ctx.extendsRef}}, ctx.class.ExtendsOrNil), ctx.computedPropertyChain), - js_ast.Expr{Loc: ctx.class.ExtendsOrNil.Loc, Data: &js_ast.EIdentifier{Ref: ref}}) - p.recordUsage(ref) - p.recordUsage(ref) + js_ast.Expr{Loc: ctx.class.ExtendsOrNil.Loc, Data: &js_ast.EIdentifier{Ref: ctx.extendsRef}}) + p.recordUsage(ctx.extendsRef) + p.recordUsage(ctx.extendsRef) ctx.computedPropertyChain = js_ast.Expr{} } return @@ -2143,13 +2145,18 @@ func (ctx *lowerClassContext) finishAndGenerateCode(p *parser, result visitClass // If there are JavaScript decorators, start by allocating a context object if ctx.decoratorContextRef != ast.InvalidRef { + base := js_ast.Expr{Loc: ctx.classLoc, Data: js_ast.ENullShared} + if ctx.class.ExtendsOrNil.Data != nil { + if ctx.extendsRef == ast.InvalidRef { + ctx.extendsRef = p.generateTempRef(tempRefNeedsDeclare, "") + ctx.class.ExtendsOrNil = js_ast.Assign(js_ast.Expr{Loc: ctx.class.ExtendsOrNil.Loc, Data: &js_ast.EIdentifier{Ref: ctx.extendsRef}}, ctx.class.ExtendsOrNil) + p.recordUsage(ctx.extendsRef) + } + base.Data = &js_ast.EIdentifier{Ref: ctx.extendsRef} + } suffixExprs = append(suffixExprs, js_ast.Assign( js_ast.Expr{Loc: ctx.classLoc, Data: &js_ast.EIdentifier{Ref: ctx.decoratorContextRef}}, - js_ast.Expr{Loc: ctx.classLoc, Data: &js_ast.EArray{IsSingleLine: true, Items: []js_ast.Expr{ - {Loc: ctx.classLoc, Data: js_ast.EMissingShared}, // classExtraInitializers - {Loc: ctx.classLoc, Data: js_ast.EMissingShared}, // staticMethodExtraInitializers - {Loc: ctx.classLoc, Data: js_ast.EMissingShared}, // instanceMethodExtraInitializers - }}}, + p.callRuntime(ctx.classLoc, "__decoratorStart", []js_ast.Expr{base}), )) p.recordUsage(ctx.decoratorContextRef) } diff --git a/internal/js_parser/js_parser_test.go b/internal/js_parser/js_parser_test.go index e023095866b..10247fb5404 100644 --- a/internal/js_parser/js_parser_test.go +++ b/internal/js_parser/js_parser_test.go @@ -2077,7 +2077,7 @@ func TestDecorators(t *testing.T) { _Foo_decorators = [dec]; class Foo { } -_init = [, , ,]; +_init = __decoratorStart(null); Foo = __decorateElement(_init, 0, "Foo", _Foo_decorators, Foo); __runInitializers(_init, 1, Foo); `) @@ -2086,10 +2086,10 @@ __runInitializers(_init, 1, Foo); _x_dec = [dec]; class Foo { constructor() { - __publicField(this, "x", __runInitializers(_init, 6, this)), __runInitializers(_init, 9, this); + __publicField(this, "x", __runInitializers(_init, 8, this)), __runInitializers(_init, 11, this); } } -_init = [, , ,]; +_init = __decoratorStart(null); __decorateElement(_init, 5, "x", _x_dec, Foo); `) expectPrintedWithUnsupportedFeatures(t, compat.Decorators, "class Foo { @dec x() {} }", @@ -2102,7 +2102,7 @@ class Foo { x() { } } -_init = [, , ,]; +_init = __decoratorStart(null); __decorateElement(_init, 1, "x", _x_dec, Foo); `) expectPrintedWithUnsupportedFeatures(t, compat.Decorators, "class Foo { @dec accessor x }", @@ -2110,10 +2110,10 @@ __decorateElement(_init, 1, "x", _x_dec, Foo); _x_dec = [dec]; class Foo { constructor() { - __privateAdd(this, _x, __runInitializers(_init, 6, this)), __runInitializers(_init, 9, this); + __privateAdd(this, _x, __runInitializers(_init, 8, this)), __runInitializers(_init, 11, this); } } -_init = [, , ,]; +_init = __decoratorStart(null); _x = new WeakMap(); __decorateElement(_init, 4, "x", _x_dec, Foo, _x); `) @@ -2122,9 +2122,9 @@ __decorateElement(_init, 4, "x", _x_dec, Foo, _x); _x_dec = [dec]; class Foo { } -_init = [, , ,]; +_init = __decoratorStart(null); __decorateElement(_init, 13, "x", _x_dec, Foo); -__publicField(Foo, "x", __runInitializers(_init, 6, Foo)), __runInitializers(_init, 9, Foo); +__publicField(Foo, "x", __runInitializers(_init, 8, Foo)), __runInitializers(_init, 11, Foo); `) expectPrintedWithUnsupportedFeatures(t, compat.Decorators, "class Foo { @dec static x() {} }", `var _x_dec, _init; @@ -2133,7 +2133,7 @@ class Foo { static x() { } } -_init = [, , ,]; +_init = __decoratorStart(null); __decorateElement(_init, 9, "x", _x_dec, Foo); __runInitializers(_init, 3, Foo); `) @@ -2142,10 +2142,10 @@ __runInitializers(_init, 3, Foo); _x_dec = [dec]; class Foo { } -_init = [, , ,]; +_init = __decoratorStart(null); _x = new WeakMap(); __decorateElement(_init, 12, "x", _x_dec, Foo, _x); -__privateAdd(Foo, _x, __runInitializers(_init, 6, Foo)), __runInitializers(_init, 9, Foo); +__privateAdd(Foo, _x, __runInitializers(_init, 8, Foo)), __runInitializers(_init, 11, Foo); `) // Check ASI for "abstract" diff --git a/internal/js_parser/ts_parser_test.go b/internal/js_parser/ts_parser_test.go index 39d50befe65..601a1572136 100644 --- a/internal/js_parser/ts_parser_test.go +++ b/internal/js_parser/ts_parser_test.go @@ -2122,7 +2122,7 @@ func TestTSDecorators(t *testing.T) { _Foo_decorators = [dec]; class Foo { } -_init = [, , ,]; +_init = __decoratorStart(null); Foo = __decorateElement(_init, 0, "Foo", _Foo_decorators, Foo); __runInitializers(_init, 1, Foo); `) @@ -2131,10 +2131,10 @@ __runInitializers(_init, 1, Foo); _x_dec = [dec]; class Foo { constructor() { - __publicField(this, "x", __runInitializers(_init, 6, this)), __runInitializers(_init, 9, this); + __publicField(this, "x", __runInitializers(_init, 8, this)), __runInitializers(_init, 11, this); } } -_init = [, , ,]; +_init = __decoratorStart(null); __decorateElement(_init, 5, "x", _x_dec, Foo); `) expectPrintedWithUnsupportedFeaturesTS(t, compat.Decorators, "class Foo { @dec x() {} }", @@ -2147,7 +2147,7 @@ class Foo { x() { } } -_init = [, , ,]; +_init = __decoratorStart(null); __decorateElement(_init, 1, "x", _x_dec, Foo); `) expectPrintedWithUnsupportedFeaturesTS(t, compat.Decorators, "class Foo { @dec accessor x }", @@ -2155,10 +2155,10 @@ __decorateElement(_init, 1, "x", _x_dec, Foo); _x_dec = [dec]; class Foo { constructor() { - __privateAdd(this, _x, __runInitializers(_init, 6, this)), __runInitializers(_init, 9, this); + __privateAdd(this, _x, __runInitializers(_init, 8, this)), __runInitializers(_init, 11, this); } } -_init = [, , ,]; +_init = __decoratorStart(null); _x = new WeakMap(); __decorateElement(_init, 4, "x", _x_dec, Foo, _x); `) @@ -2167,9 +2167,9 @@ __decorateElement(_init, 4, "x", _x_dec, Foo, _x); _x_dec = [dec]; class Foo { } -_init = [, , ,]; +_init = __decoratorStart(null); __decorateElement(_init, 13, "x", _x_dec, Foo); -__publicField(Foo, "x", __runInitializers(_init, 6, Foo)), __runInitializers(_init, 9, Foo); +__publicField(Foo, "x", __runInitializers(_init, 8, Foo)), __runInitializers(_init, 11, Foo); `) expectPrintedWithUnsupportedFeaturesTS(t, compat.Decorators, "class Foo { @dec static x() {} }", `var _x_dec, _init; @@ -2178,7 +2178,7 @@ class Foo { static x() { } } -_init = [, , ,]; +_init = __decoratorStart(null); __decorateElement(_init, 9, "x", _x_dec, Foo); __runInitializers(_init, 3, Foo); `) @@ -2187,10 +2187,10 @@ __runInitializers(_init, 3, Foo); _x_dec = [dec]; class Foo { } -_init = [, , ,]; +_init = __decoratorStart(null); _x = new WeakMap(); __decorateElement(_init, 12, "x", _x_dec, Foo, _x); -__privateAdd(Foo, _x, __runInitializers(_init, 6, Foo)), __runInitializers(_init, 9, Foo); +__privateAdd(Foo, _x, __runInitializers(_init, 8, Foo)), __runInitializers(_init, 11, Foo); `) // Check ASI for "abstract" diff --git a/internal/runtime/runtime.go b/internal/runtime/runtime.go index b99b5751455..b3bf41616f1 100644 --- a/internal/runtime/runtime.go +++ b/internal/runtime/runtime.go @@ -261,10 +261,11 @@ func Source(unsupportedJSFeatures compat.JSFeature) logger.Source { export var __decorateParam = (index, decorator) => (target, key) => decorator(target, key, index) // For JavaScript decorators + export var __decoratorStart = base => [, , , __create(base?.[__knownSymbol('metadata')] ?? null)] var __decoratorStrings = ['class', 'method', 'getter', 'setter', 'accessor', 'field', 'value', 'get', 'set'] var __expectFn = fn => fn !== void 0 && typeof fn !== 'function' ? __typeError('Function expected') : fn - var __decoratorContext = (kind, name, done, fns) => ({ kind: __decoratorStrings[kind], name, addInitializer: fn => - done._ ? __typeError('Already initialized') : fns.push(__expectFn(fn || null)), }) + var __decoratorContext = (kind, name, done, metadata, fns) => ({ kind: __decoratorStrings[kind], name, metadata, addInitializer: fn => + done._ ? __typeError('Already initialized') : fns.push(__expectFn(fn || null)) }) export var __runInitializers = (array, flags, self, value) => { for (var i = 0, fns = array[flags >> 1], n = fns && fns.length; i < n; i++) flags & 1 ? fns[i].call(self) : value = fns[i].call(self, value) return value @@ -290,7 +291,7 @@ func Source(unsupportedJSFeatures compat.JSFeature) logger.Source { k ? p && k < 4 && __name(extra, (k > 2 ? 'set ' : k > 1 ? 'get ' : '') + name) : __name(target, name) for (var i = decorators.length - 1; i >= 0; i--) { - ctx = __decoratorContext(k, name, done = {}, extraInitializers) + ctx = __decoratorContext(k, name, done = {}, array[3], extraInitializers) if (k) { ctx.static = s, ctx.private = p, access = ctx.access = { has: p ? x => __privateIn(target, x) : x => name in x } @@ -305,7 +306,9 @@ func Source(unsupportedJSFeatures compat.JSFeature) logger.Source { else __expectFn(fn = it.get) && (desc.get = fn), __expectFn(fn = it.set) && (desc.set = fn), __expectFn(fn = it.init) && initializers.unshift(fn) } - return desc && __defProp(target, name, desc), p ? k ^ 4 ? extra : desc : target + return k || (target[__knownSymbol('metadata')] = array[3]), + desc && __defProp(target, name, desc), + p ? k ^ 4 ? extra : desc : target } // For class members diff --git a/scripts/decorator-tests.js b/scripts/decorator-tests.js index a48159ee30f..22113d10bbc 100644 --- a/scripts/decorator-tests.js +++ b/scripts/decorator-tests.js @@ -1,13 +1,16 @@ +var __create = Object.create; var __defProp = Object.defineProperty; var __getOwnPropDesc = Object.getOwnPropertyDescriptor; +var __knownSymbol = (name, symbol) => (symbol = Symbol[name]) ? symbol : Symbol.for("Symbol." + name); var __typeError = (msg) => { throw TypeError(msg); }; var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value; var __name = (target, value) => __defProp(target, "name", { value, configurable: true }); +var __decoratorStart = (base) => [, , , __create(base?.[__knownSymbol("metadata")] ?? null)]; var __decoratorStrings = ["class", "method", "getter", "setter", "accessor", "field", "value", "get", "set"]; var __expectFn = (fn) => fn !== void 0 && typeof fn !== "function" ? __typeError("Function expected") : fn; -var __decoratorContext = (kind, name, done, fns) => ({ kind: __decoratorStrings[kind], name, addInitializer: (fn) => done._ ? __typeError("Already initialized") : fns.push(__expectFn(fn || null)) }); +var __decoratorContext = (kind, name, done, metadata, fns) => ({ kind: __decoratorStrings[kind], name, metadata, addInitializer: (fn) => done._ ? __typeError("Already initialized") : fns.push(__expectFn(fn || null)) }); var __runInitializers = (array, flags, self, value) => { for (var i = 0, fns = array[flags >> 1], n = fns && fns.length; i < n; i++) flags & 1 ? fns[i].call(self) : value = fns[i].call(self, value); return value; @@ -23,7 +26,7 @@ var __decorateElement = (array, flags, name, decorators, target, extra) => { } }, name)); k ? p && k < 4 && __name(extra, (k > 2 ? "set " : k > 1 ? "get " : "") + name) : __name(target, name); for (var i = decorators.length - 1; i >= 0; i--) { - ctx = __decoratorContext(k, name, done = {}, extraInitializers); + ctx = __decoratorContext(k, name, done = {}, array[3], extraInitializers); if (k) { ctx.static = s, ctx.private = p, access = ctx.access = { has: p ? (x) => __privateIn(target, x) : (x) => name in x }; if (k ^ 3) access.get = p ? (x) => (k ^ 1 ? __privateGet : __privateMethod)(x, target, k ^ 4 ? extra : desc.get) : (x) => x[name]; @@ -34,7 +37,7 @@ var __decorateElement = (array, flags, name, decorators, target, extra) => { else if (typeof it !== "object" || it === null) __typeError("Object expected"); else __expectFn(fn = it.get) && (desc.get = fn), __expectFn(fn = it.set) && (desc.set = fn), __expectFn(fn = it.init) && initializers.unshift(fn); } - return desc && __defProp(target, name, desc), p ? k ^ 4 ? extra : desc : target; + return k || (target[__knownSymbol("metadata")] = array[3]), desc && __defProp(target, name, desc), p ? k ^ 4 ? extra : desc : target; }; var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "symbol" ? key + "" : key, value); var __accessCheck = (obj, member, msg) => member.has(obj) || __typeError("Cannot " + msg); @@ -43,6 +46,9 @@ var __privateGet = (obj, member, getter) => (__accessCheck(obj, member, "read fr var __privateAdd = (obj, member, value) => member.has(obj) ? __typeError("Cannot add the same private member more than once") : member instanceof WeakSet ? member.add(obj) : member.set(obj, value); var __privateSet = (obj, member, value, setter) => (__accessCheck(obj, member, "write to private field"), setter ? setter.call(obj, value) : member.set(obj, value), value); var __privateMethod = (obj, member, method) => (__accessCheck(obj, member, "access private method"), method); +if (!("metadata" in Symbol)) { + Symbol.metadata = Symbol("Symbol.metadata"); +} const tests = { // Class decorators "Class decorators: Basic statement": () => { @@ -61,7 +67,7 @@ const tests = { _Foo_decorators = [dec("Foo")]; class Foo2 { } - _init = [, , ,]; + _init = __decoratorStart(null); Foo2 = __decorateElement(_init, 0, "Foo", _Foo_decorators, Foo2); __runInitializers(_init, 1, Foo2); assertEq(() => Foo2, old); @@ -80,10 +86,10 @@ const tests = { old = cls; }; const Foo2 = /* @__PURE__ */ ((x) => x)((_class_decorators = [dec("")], _a = class { - }, _init = [, , ,], _a = __decorateElement(_init, 0, "", _class_decorators, _a), __runInitializers(_init, 1, _a), _a)); + }, _init = __decoratorStart(null), _a = __decorateElement(_init, 0, "", _class_decorators, _a), __runInitializers(_init, 1, _a), _a)); assertEq(() => Foo2, old); const Bar = /* @__PURE__ */ ((x) => x)((_Baz_decorators = [dec("Baz")], _b = class { - }, _init2 = [, , ,], _b = __decorateElement(_init2, 0, "Baz", _Baz_decorators, _b), __runInitializers(_init2, 1, _b), _b)); + }, _init2 = __decoratorStart(null), _b = __decorateElement(_init2, 0, "Baz", _Baz_decorators, _b), __runInitializers(_init2, 1, _b), _b)); assertEq(() => Bar, old); }, "Class decorators: Basic expression: Property value": () => { @@ -101,12 +107,12 @@ const tests = { }; const obj = { Foo: (_Foo_decorators = [dec("Foo")], _a = class { - }, _init = [, , ,], _a = __decorateElement(_init, 0, "Foo", _Foo_decorators, _a), __runInitializers(_init, 1, _a), _a) + }, _init = __decoratorStart(null), _a = __decorateElement(_init, 0, "Foo", _Foo_decorators, _a), __runInitializers(_init, 1, _a), _a) }; assertEq(() => obj.Foo, old); const obj2 = { Bar: (_Baz_decorators = [dec("Baz")], _b = class { - }, _init2 = [, , ,], _b = __decorateElement(_init2, 0, "Baz", _Baz_decorators, _b), __runInitializers(_init2, 1, _b), _b) + }, _init2 = __decoratorStart(null), _b = __decorateElement(_init2, 0, "Baz", _Baz_decorators, _b), __runInitializers(_init2, 1, _b), _b) }; assertEq(() => obj2.Bar, old); }, @@ -124,10 +130,10 @@ const tests = { old = cls; }; const Foo2 = (_Foo_decorators = [dec("Foo")], _a = class { - }, _init = [, , ,], _a = __decorateElement(_init, 0, "Foo", _Foo_decorators, _a), __runInitializers(_init, 1, _a), _a); + }, _init = __decoratorStart(null), _a = __decorateElement(_init, 0, "Foo", _Foo_decorators, _a), __runInitializers(_init, 1, _a), _a); assertEq(() => Foo2, old); const Bar = (_Baz_decorators = [dec("Baz")], _b = class { - }, _init2 = [, , ,], _b = __decorateElement(_init2, 0, "Baz", _Baz_decorators, _b), __runInitializers(_init2, 1, _b), _b); + }, _init2 = __decoratorStart(null), _b = __decorateElement(_init2, 0, "Baz", _Baz_decorators, _b), __runInitializers(_init2, 1, _b), _b); assertEq(() => Bar, old); }, "Class decorators: Basic expression: Array binding": () => { @@ -144,10 +150,10 @@ const tests = { old = cls; }; const [Foo2 = (_Foo_decorators = [dec("Foo")], _a = class { - }, _init = [, , ,], _a = __decorateElement(_init, 0, "Foo", _Foo_decorators, _a), __runInitializers(_init, 1, _a), _a)] = []; + }, _init = __decoratorStart(null), _a = __decorateElement(_init, 0, "Foo", _Foo_decorators, _a), __runInitializers(_init, 1, _a), _a)] = []; assertEq(() => Foo2, old); const [Bar = (_Baz_decorators = [dec("Baz")], _b = class { - }, _init2 = [, , ,], _b = __decorateElement(_init2, 0, "Baz", _Baz_decorators, _b), __runInitializers(_init2, 1, _b), _b)] = []; + }, _init2 = __decoratorStart(null), _b = __decorateElement(_init2, 0, "Baz", _Baz_decorators, _b), __runInitializers(_init2, 1, _b), _b)] = []; assertEq(() => Bar, old); }, "Class decorators: Basic expression: Object binding": () => { @@ -164,10 +170,10 @@ const tests = { old = cls; }; const { Foo: Foo2 = (_Foo_decorators = [dec("Foo")], _a = class { - }, _init = [, , ,], _a = __decorateElement(_init, 0, "Foo", _Foo_decorators, _a), __runInitializers(_init, 1, _a), _a) } = {}; + }, _init = __decoratorStart(null), _a = __decorateElement(_init, 0, "Foo", _Foo_decorators, _a), __runInitializers(_init, 1, _a), _a) } = {}; assertEq(() => Foo2, old); const { Bar = (_Baz_decorators = [dec("Baz")], _b = class { - }, _init2 = [, , ,], _b = __decorateElement(_init2, 0, "Baz", _Baz_decorators, _b), __runInitializers(_init2, 1, _b), _b) } = {}; + }, _init2 = __decoratorStart(null), _b = __decorateElement(_init2, 0, "Baz", _Baz_decorators, _b), __runInitializers(_init2, 1, _b), _b) } = {}; assertEq(() => Bar, old); }, "Class decorators: Basic expression: Assignment initializer": () => { @@ -185,11 +191,11 @@ const tests = { }; let Foo2; Foo2 = (_Foo_decorators = [dec("Foo")], _a = class { - }, _init = [, , ,], _a = __decorateElement(_init, 0, "Foo", _Foo_decorators, _a), __runInitializers(_init, 1, _a), _a); + }, _init = __decoratorStart(null), _a = __decorateElement(_init, 0, "Foo", _Foo_decorators, _a), __runInitializers(_init, 1, _a), _a); assertEq(() => Foo2, old); let Bar; Bar = (_Baz_decorators = [dec("Baz")], _b = class { - }, _init2 = [, , ,], _b = __decorateElement(_init2, 0, "Baz", _Baz_decorators, _b), __runInitializers(_init2, 1, _b), _b); + }, _init2 = __decoratorStart(null), _b = __decorateElement(_init2, 0, "Baz", _Baz_decorators, _b), __runInitializers(_init2, 1, _b), _b); assertEq(() => Bar, old); }, "Class decorators: Basic expression: Assignment array binding": () => { @@ -207,11 +213,11 @@ const tests = { }; let Foo2; [Foo2 = (_Foo_decorators = [dec("Foo")], _a = class { - }, _init = [, , ,], _a = __decorateElement(_init, 0, "Foo", _Foo_decorators, _a), __runInitializers(_init, 1, _a), _a)] = []; + }, _init = __decoratorStart(null), _a = __decorateElement(_init, 0, "Foo", _Foo_decorators, _a), __runInitializers(_init, 1, _a), _a)] = []; assertEq(() => Foo2, old); let Bar; [Bar = (_Baz_decorators = [dec("Baz")], _b = class { - }, _init2 = [, , ,], _b = __decorateElement(_init2, 0, "Baz", _Baz_decorators, _b), __runInitializers(_init2, 1, _b), _b)] = []; + }, _init2 = __decoratorStart(null), _b = __decorateElement(_init2, 0, "Baz", _Baz_decorators, _b), __runInitializers(_init2, 1, _b), _b)] = []; assertEq(() => Bar, old); }, "Class decorators: Basic expression: Assignment object binding": () => { @@ -229,11 +235,11 @@ const tests = { }; let Foo2; ({ Foo: Foo2 = (_Foo_decorators = [dec("Foo")], _a = class { - }, _init = [, , ,], _a = __decorateElement(_init, 0, "Foo", _Foo_decorators, _a), __runInitializers(_init, 1, _a), _a) } = {}); + }, _init = __decoratorStart(null), _a = __decorateElement(_init, 0, "Foo", _Foo_decorators, _a), __runInitializers(_init, 1, _a), _a) } = {}); assertEq(() => Foo2, old); let Bar; ({ Bar = (_Baz_decorators = [dec("Baz")], _b = class { - }, _init2 = [, , ,], _b = __decorateElement(_init2, 0, "Baz", _Baz_decorators, _b), __runInitializers(_init2, 1, _b), _b) } = {}); + }, _init2 = __decoratorStart(null), _b = __decorateElement(_init2, 0, "Baz", _Baz_decorators, _b), __runInitializers(_init2, 1, _b), _b) } = {}); assertEq(() => Bar, old); }, "Class decorators: Basic expression: Instance field initializer": () => { @@ -251,13 +257,13 @@ const tests = { }; class Class { Foo = (_Foo_decorators = [dec("Foo")], _a = class { - }, _init = [, , ,], _a = __decorateElement(_init, 0, "Foo", _Foo_decorators, _a), __runInitializers(_init, 1, _a), _a); + }, _init = __decoratorStart(null), _a = __decorateElement(_init, 0, "Foo", _Foo_decorators, _a), __runInitializers(_init, 1, _a), _a); } const Foo2 = new Class().Foo; assertEq(() => Foo2, old); class Class2 { Bar = (_Baz_decorators = [dec("Baz")], _b = class { - }, _init2 = [, , ,], _b = __decorateElement(_init2, 0, "Baz", _Baz_decorators, _b), __runInitializers(_init2, 1, _b), _b); + }, _init2 = __decoratorStart(null), _b = __decorateElement(_init2, 0, "Baz", _Baz_decorators, _b), __runInitializers(_init2, 1, _b), _b); } const Bar = new Class2().Bar; assertEq(() => Bar, old); @@ -277,12 +283,12 @@ const tests = { }; class Class { static Foo = (_Foo_decorators = [dec("Foo")], _a = class { - }, _init = [, , ,], _a = __decorateElement(_init, 0, "Foo", _Foo_decorators, _a), __runInitializers(_init, 1, _a), _a); + }, _init = __decoratorStart(null), _a = __decorateElement(_init, 0, "Foo", _Foo_decorators, _a), __runInitializers(_init, 1, _a), _a); } assertEq(() => Class.Foo, old); class Class2 { static Bar = (_Baz_decorators = [dec("Baz")], _b = class { - }, _init2 = [, , ,], _b = __decorateElement(_init2, 0, "Baz", _Baz_decorators, _b), __runInitializers(_init2, 1, _b), _b); + }, _init2 = __decoratorStart(null), _b = __decorateElement(_init2, 0, "Baz", _Baz_decorators, _b), __runInitializers(_init2, 1, _b), _b); } assertEq(() => Class2.Bar, old); }, @@ -301,7 +307,7 @@ const tests = { }; class Class { #Foo = (_Foo_decorators = [dec("Foo")], _a = class { - }, _init = [, , ,], _a = __decorateElement(_init, 0, "Foo", _Foo_decorators, _a), __runInitializers(_init, 1, _a), _a); + }, _init = __decoratorStart(null), _a = __decorateElement(_init, 0, "Foo", _Foo_decorators, _a), __runInitializers(_init, 1, _a), _a); get Foo() { return this.#Foo; } @@ -313,7 +319,7 @@ const tests = { assertEq(() => Foo2, old); class Class2 { #Bar = (_Baz_decorators = [dec("Baz")], _b = class { - }, _init2 = [, , ,], _b = __decorateElement(_init2, 0, "Baz", _Baz_decorators, _b), __runInitializers(_init2, 1, _b), _b); + }, _init2 = __decoratorStart(null), _b = __decorateElement(_init2, 0, "Baz", _Baz_decorators, _b), __runInitializers(_init2, 1, _b), _b); get Bar() { return this.#Bar; } @@ -339,7 +345,7 @@ const tests = { }; class Class { static #Foo = (_Foo_decorators = [dec("Foo")], _a = class { - }, _init = [, , ,], _a = __decorateElement(_init, 0, "Foo", _Foo_decorators, _a), __runInitializers(_init, 1, _a), _a); + }, _init = __decoratorStart(null), _a = __decorateElement(_init, 0, "Foo", _Foo_decorators, _a), __runInitializers(_init, 1, _a), _a); static get Foo() { return this.#Foo; } @@ -350,7 +356,7 @@ const tests = { assertEq(() => Class.Foo, old); class Class2 { static #Bar = (_Baz_decorators = [dec("Baz")], _b = class { - }, _init2 = [, , ,], _b = __decorateElement(_init2, 0, "Baz", _Baz_decorators, _b), __runInitializers(_init2, 1, _b), _b); + }, _init2 = __decoratorStart(null), _b = __decorateElement(_init2, 0, "Baz", _Baz_decorators, _b), __runInitializers(_init2, 1, _b), _b); static get Bar() { return this.#Bar; } @@ -388,7 +394,7 @@ const tests = { log.push(6); } } - _init = [, , ,]; + _init = __decoratorStart(null); Foo2 = __decorateElement(_init, 0, "Foo", _Foo_decorators, Foo2); __runInitializers(_init, 1, Foo2); log.push(3); @@ -406,7 +412,7 @@ const tests = { _Foo_decorators = [dec]; class Foo2 { } - _init = [, , ,]; + _init = __decoratorStart(null); Foo2 = __decorateElement(_init, 0, "Foo", _Foo_decorators, Foo2); __runInitializers(_init, 1, Foo2); }, TypeError); @@ -420,7 +426,7 @@ const tests = { _Foo_decorators = [dec]; class Foo2 { } - _init = [, , ,]; + _init = __decoratorStart(null); Foo2 = __decorateElement(_init, 0, "Foo", _Foo_decorators, Foo2); __runInitializers(_init, 1, Foo2); }, TypeError); @@ -441,7 +447,7 @@ const tests = { _Foo_decorators = [dec, dec]; class Foo2 { } - _init = [, , ,]; + _init = __decoratorStart(null); Foo2 = __decorateElement(_init, 0, "Foo", _Foo_decorators, Foo2); __runInitializers(_init, 1, Foo2); assertEq(() => got.this, Foo2); @@ -477,7 +483,7 @@ const tests = { [_a = (_baz_dec = [dec(baz, "")], baz)]() { } } - _init = [, , ,]; + _init = __decoratorStart(null); __decorateElement(_init, 1, "foo", _foo_dec, Foo2); __decorateElement(_init, 1, _b, _bar_dec, Foo2); __decorateElement(_init, 1, _a, _baz_dec, Foo2); @@ -511,7 +517,7 @@ const tests = { static [_a = (_baz_dec = [dec(baz, "")], baz)]() { } } - _init = [, , ,]; + _init = __decoratorStart(null); __decorateElement(_init, 9, "foo", _foo_dec, Foo2); __decorateElement(_init, 9, _b, _bar_dec, Foo2); __decorateElement(_init, 9, _a, _baz_dec, Foo2); @@ -547,7 +553,7 @@ const tests = { __privateAdd(this, _Foo_instances); } }; - _init = [, , ,]; + _init = __decoratorStart(null); _Foo_instances = new WeakSet(); foo_fn = function() { }; @@ -580,7 +586,7 @@ const tests = { _foo_dec = [dec]; const _Foo = class _Foo { }; - _init = [, , ,]; + _init = __decoratorStart(null); _Foo_static = new WeakSet(); foo_fn = function() { }; @@ -611,7 +617,7 @@ const tests = { return this.bar; } } - _init = [, , ,]; + _init = __decoratorStart(null); __decorateElement(_init, 1, "foo", _foo_dec, Foo2); assertEq(() => Foo2.prototype.foo, bar); assertEq(() => new Foo2().foo(), 124); @@ -631,7 +637,7 @@ const tests = { return this.bar; } } - _init = [, , ,]; + _init = __decoratorStart(null); __decorateElement(_init, 9, "foo", _foo_dec, Foo2); __runInitializers(_init, 3, Foo2); __publicField(Foo2, "bar", 123); @@ -656,7 +662,7 @@ const tests = { __publicField(this, "bar", 123); } }; - _init = [, , ,]; + _init = __decoratorStart(null); _Foo_instances = new WeakSet(); foo_fn = function() { return this.bar; @@ -680,7 +686,7 @@ const tests = { _foo_dec = [dec]; const _Foo = class _Foo { }; - _init = [, , ,]; + _init = __decoratorStart(null); _Foo_static = new WeakSet(); foo_fn = function() { return this.bar; @@ -725,7 +731,7 @@ const tests = { return log.push(6); } } - _init = [, , ,]; + _init = __decoratorStart(null); __decorateElement(_init, 1, "foo", _foo_dec, Foo2); log.push(3); new Foo2().foo(); @@ -761,7 +767,7 @@ const tests = { return log.push(6); } } - _init = [, , ,]; + _init = __decoratorStart(null); __decorateElement(_init, 9, "foo", _foo_dec, Foo2); __runInitializers(_init, 3, Foo2); log.push(3); @@ -800,7 +806,7 @@ const tests = { __privateAdd(this, _Foo_instances); } }; - _init = [, , ,]; + _init = __decoratorStart(null); _Foo_instances = new WeakSet(); foo_fn = function() { return log.push(6); @@ -840,7 +846,7 @@ const tests = { _foo_dec = [dec1, dec2]; const _Foo = class _Foo { }; - _init = [, , ,]; + _init = __decoratorStart(null); _Foo_static = new WeakSet(); foo_fn = function() { return log.push(6); @@ -870,7 +876,7 @@ const tests = { foo() { } } - _init = [, , ,]; + _init = __decoratorStart(null); __decorateElement(_init, 1, "foo", _foo_dec, Foo2); }, TypeError); }, @@ -885,7 +891,7 @@ const tests = { static foo() { } } - _init = [, , ,]; + _init = __decoratorStart(null); __decorateElement(_init, 9, "foo", _foo_dec, Foo2); __runInitializers(_init, 3, Foo2); }, TypeError); @@ -903,7 +909,7 @@ const tests = { __privateAdd(this, _Foo_instances); } } - _init = [, , ,]; + _init = __decoratorStart(null); _Foo_instances = new WeakSet(); foo_fn = function() { }; @@ -919,7 +925,7 @@ const tests = { _foo_dec = [dec]; class Foo2 { } - _init = [, , ,]; + _init = __decoratorStart(null); _Foo_static = new WeakSet(); foo_fn = function() { }; @@ -942,7 +948,7 @@ const tests = { foo() { } } - _init = [, , ,]; + _init = __decoratorStart(null); __decorateElement(_init, 1, "foo", _foo_dec, Foo2); }, TypeError); }, @@ -957,7 +963,7 @@ const tests = { static foo() { } } - _init = [, , ,]; + _init = __decoratorStart(null); __decorateElement(_init, 9, "foo", _foo_dec, Foo2); __runInitializers(_init, 3, Foo2); }, TypeError); @@ -975,7 +981,7 @@ const tests = { __privateAdd(this, _Foo_instances); } } - _init = [, , ,]; + _init = __decoratorStart(null); _Foo_instances = new WeakSet(); foo_fn = function() { }; @@ -991,7 +997,7 @@ const tests = { _foo_dec = [dec]; class Foo2 { } - _init = [, , ,]; + _init = __decoratorStart(null); _Foo_static = new WeakSet(); foo_fn = function() { }; @@ -1021,7 +1027,7 @@ const tests = { foo() { } } - _init = [, , ,]; + _init = __decoratorStart(null); __decorateElement(_init, 1, "foo", _foo_dec, Foo2); assertEq(() => got, void 0); const instance = new Foo2(); @@ -1046,7 +1052,7 @@ const tests = { static foo() { } } - _init = [, , ,]; + _init = __decoratorStart(null); __decorateElement(_init, 9, "foo", _foo_dec, Foo2); __runInitializers(_init, 3, Foo2); assertEq(() => got.this, Foo2); @@ -1072,7 +1078,7 @@ const tests = { __privateAdd(this, _Foo_instances); } } - _init = [, , ,]; + _init = __decoratorStart(null); _Foo_instances = new WeakSet(); foo_fn = function() { }; @@ -1098,7 +1104,7 @@ const tests = { _foo_dec = [dec, dec]; class Foo2 { } - _init = [, , ,]; + _init = __decoratorStart(null); _Foo_static = new WeakSet(); foo_fn = function() { }; @@ -1131,12 +1137,12 @@ const tests = { _foo_dec = [dec("foo")], _b = (_bar_dec = [dec(bar)], bar), _a = (_baz_dec = [dec(baz)], baz); class Foo2 { constructor() { - __publicField(this, "foo", __runInitializers(_init, 6, this, 123)), __runInitializers(_init, 9, this); - __publicField(this, _b, __runInitializers(_init, 10, this, 123)), __runInitializers(_init, 13, this); - __publicField(this, _a, __runInitializers(_init, 14, this, 123)), __runInitializers(_init, 17, this); + __publicField(this, "foo", __runInitializers(_init, 8, this, 123)), __runInitializers(_init, 11, this); + __publicField(this, _b, __runInitializers(_init, 12, this, 123)), __runInitializers(_init, 15, this); + __publicField(this, _a, __runInitializers(_init, 16, this, 123)), __runInitializers(_init, 19, this); } } - _init = [, , ,]; + _init = __decoratorStart(null); __decorateElement(_init, 5, "foo", _foo_dec, Foo2); __decorateElement(_init, 5, _b, _bar_dec, Foo2); __decorateElement(_init, 5, _a, _baz_dec, Foo2); @@ -1166,13 +1172,13 @@ const tests = { _foo_dec = [dec("foo")], _b = (_bar_dec = [dec(bar)], bar), _a = (_baz_dec = [dec(baz)], baz); class Foo2 { } - _init = [, , ,]; + _init = __decoratorStart(null); __decorateElement(_init, 13, "foo", _foo_dec, Foo2); __decorateElement(_init, 13, _b, _bar_dec, Foo2); __decorateElement(_init, 13, _a, _baz_dec, Foo2); - __publicField(Foo2, "foo", __runInitializers(_init, 6, Foo2, 123)), __runInitializers(_init, 9, Foo2); - __publicField(Foo2, _b, __runInitializers(_init, 10, Foo2, 123)), __runInitializers(_init, 13, Foo2); - __publicField(Foo2, _a, __runInitializers(_init, 14, Foo2, 123)), __runInitializers(_init, 17, Foo2); + __publicField(Foo2, "foo", __runInitializers(_init, 8, Foo2, 123)), __runInitializers(_init, 11, Foo2); + __publicField(Foo2, _b, __runInitializers(_init, 12, Foo2, 123)), __runInitializers(_init, 15, Foo2); + __publicField(Foo2, _a, __runInitializers(_init, 16, Foo2, 123)), __runInitializers(_init, 19, Foo2); assertEq(() => Foo2.foo, 123); assertEq(() => Foo2[bar], 123); assertEq(() => Foo2[baz], 123); @@ -1201,10 +1207,10 @@ const tests = { _foo_dec = [dec]; class Foo2 { constructor() { - __privateAdd(this, _foo, __runInitializers(_init, 6, this, 123)), __runInitializers(_init, 9, this); + __privateAdd(this, _foo, __runInitializers(_init, 8, this, 123)), __runInitializers(_init, 11, this); } } - _init = [, , ,]; + _init = __decoratorStart(null); _foo = new WeakMap(); __decorateElement(_init, 21, "#foo", _foo_dec, _foo); get$foo = (x) => __privateGet(x, _foo); @@ -1234,10 +1240,10 @@ const tests = { _foo_dec = [dec]; class Foo2 { } - _init = [, , ,]; + _init = __decoratorStart(null); _foo = new WeakMap(); __decorateElement(_init, 29, "#foo", _foo_dec, _foo); - __privateAdd(Foo2, _foo, __runInitializers(_init, 6, Foo2, 123)), __runInitializers(_init, 9, Foo2); + __privateAdd(Foo2, _foo, __runInitializers(_init, 8, Foo2, 123)), __runInitializers(_init, 11, Foo2); get$foo = (x) => __privateGet(x, _foo); assertEq(() => get$foo(Foo2), 123); lateAsserts(); @@ -1254,11 +1260,11 @@ const tests = { _foo_dec = [dec], _bar_dec = [dec]; class Foo2 { constructor() { - __publicField(this, "foo", __runInitializers(_init, 6, this, 123)), __runInitializers(_init, 9, this); - __publicField(this, "bar", __runInitializers(_init, 10, this)), __runInitializers(_init, 13, this); + __publicField(this, "foo", __runInitializers(_init, 8, this, 123)), __runInitializers(_init, 11, this); + __publicField(this, "bar", __runInitializers(_init, 12, this)), __runInitializers(_init, 15, this); } } - _init = [, , ,]; + _init = __decoratorStart(null); __decorateElement(_init, 5, "foo", _foo_dec, Foo2); __decorateElement(_init, 5, "bar", _bar_dec, Foo2); assertEq(() => log + "", ""); @@ -1281,12 +1287,12 @@ const tests = { _foo_dec = [dec], _bar_dec = [dec]; const _Foo = class _Foo { }; - _init = [, , ,]; + _init = __decoratorStart(null); __decorateElement(_init, 13, "foo", _foo_dec, _Foo); __decorateElement(_init, 13, "bar", _bar_dec, _Foo); foo = _Foo; - __publicField(_Foo, "foo", __runInitializers(_init, 6, _Foo, 123)), __runInitializers(_init, 9, _Foo); - __publicField(_Foo, "bar", __runInitializers(_init, 10, _Foo)), __runInitializers(_init, 13, _Foo); + __publicField(_Foo, "foo", __runInitializers(_init, 8, _Foo, 123)), __runInitializers(_init, 11, _Foo); + __publicField(_Foo, "bar", __runInitializers(_init, 12, _Foo)), __runInitializers(_init, 15, _Foo); let Foo2 = _Foo; assertEq(() => Foo2.foo, 3); assertEq(() => Foo2.bar, 6); @@ -1308,11 +1314,11 @@ const tests = { _foo_dec = [dec], _bar_dec = [dec]; class Foo2 { constructor() { - __privateAdd(this, _foo, __runInitializers(_init, 6, this, 123)), __runInitializers(_init, 9, this); - __privateAdd(this, _bar, __runInitializers(_init, 10, this)), __runInitializers(_init, 13, this); + __privateAdd(this, _foo, __runInitializers(_init, 8, this, 123)), __runInitializers(_init, 11, this); + __privateAdd(this, _bar, __runInitializers(_init, 12, this)), __runInitializers(_init, 15, this); } } - _init = [, , ,]; + _init = __decoratorStart(null); _foo = new WeakMap(); _bar = new WeakMap(); __decorateElement(_init, 21, "#foo", _foo_dec, _foo); @@ -1345,7 +1351,7 @@ const tests = { _foo_dec = [dec], _bar_dec = [dec]; const _Foo = class _Foo { }; - _init = [, , ,]; + _init = __decoratorStart(null); _foo = new WeakMap(); _bar = new WeakMap(); __decorateElement(_init, 29, "#foo", _foo_dec, _foo); @@ -1355,8 +1361,8 @@ const tests = { has$bar = (x) => __privateIn(_bar, x); get$foo = (x) => __privateGet(x, _foo); get$bar = (x) => __privateGet(x, _bar); - __privateAdd(_Foo, _foo, __runInitializers(_init, 6, _Foo, 123)), __runInitializers(_init, 9, _Foo); - __privateAdd(_Foo, _bar, __runInitializers(_init, 10, _Foo)), __runInitializers(_init, 13, _Foo); + __privateAdd(_Foo, _foo, __runInitializers(_init, 8, _Foo, 123)), __runInitializers(_init, 11, _Foo); + __privateAdd(_Foo, _bar, __runInitializers(_init, 12, _Foo)), __runInitializers(_init, 15, _Foo); let Foo2 = _Foo; assertEq(() => get$foo(Foo2), 3); assertEq(() => get$bar(Foo2), 6); @@ -1377,10 +1383,10 @@ const tests = { _foo_dec = [dec1, dec2]; class Foo2 { constructor() { - __publicField(this, "foo", __runInitializers(_init, 6, this, 123)), __runInitializers(_init, 9, this); + __publicField(this, "foo", __runInitializers(_init, 8, this, 123)), __runInitializers(_init, 11, this); } } - _init = [, , ,]; + _init = __decoratorStart(null); __decorateElement(_init, 5, "foo", _foo_dec, Foo2); log.push(3); var obj = new Foo2(); @@ -1403,9 +1409,9 @@ const tests = { _foo_dec = [dec1, dec2]; class Foo2 { } - _init = [, , ,]; + _init = __decoratorStart(null); __decorateElement(_init, 13, "foo", _foo_dec, Foo2); - __publicField(Foo2, "foo", __runInitializers(_init, 6, Foo2, 123)), __runInitializers(_init, 9, Foo2); + __publicField(Foo2, "foo", __runInitializers(_init, 8, Foo2, 123)), __runInitializers(_init, 11, Foo2); log.push(5); assertEq(() => Foo2.foo, 5); assertEq(() => log + "", "0,1,2,3,4,5"); @@ -1426,10 +1432,10 @@ const tests = { _foo_dec = [dec1, dec2]; class Foo2 { constructor() { - __privateAdd(this, _foo, __runInitializers(_init, 6, this, 123)), __runInitializers(_init, 9, this); + __privateAdd(this, _foo, __runInitializers(_init, 8, this, 123)), __runInitializers(_init, 11, this); } } - _init = [, , ,]; + _init = __decoratorStart(null); _foo = new WeakMap(); __decorateElement(_init, 21, "#foo", _foo_dec, _foo); get$foo = (x) => __privateGet(x, _foo); @@ -1455,10 +1461,10 @@ const tests = { _foo_dec = [dec1, dec2]; class Foo2 { } - _init = [, , ,]; + _init = __decoratorStart(null); _foo = new WeakMap(); __decorateElement(_init, 29, "#foo", _foo_dec, _foo); - __privateAdd(Foo2, _foo, __runInitializers(_init, 6, Foo2, 123)), __runInitializers(_init, 9, Foo2); + __privateAdd(Foo2, _foo, __runInitializers(_init, 8, Foo2, 123)), __runInitializers(_init, 11, Foo2); get$foo = (x) => __privateGet(x, _foo); log.push(5); assertEq(() => get$foo(Foo2), 5); @@ -1473,10 +1479,10 @@ const tests = { _foo_dec = [dec]; class Foo2 { constructor() { - __publicField(this, "foo", __runInitializers(_init, 6, this)), __runInitializers(_init, 9, this); + __publicField(this, "foo", __runInitializers(_init, 8, this)), __runInitializers(_init, 11, this); } } - _init = [, , ,]; + _init = __decoratorStart(null); __decorateElement(_init, 5, "foo", _foo_dec, Foo2); }, TypeError); }, @@ -1489,9 +1495,9 @@ const tests = { _foo_dec = [dec]; class Foo2 { } - _init = [, , ,]; + _init = __decoratorStart(null); __decorateElement(_init, 13, "foo", _foo_dec, Foo2); - __publicField(Foo2, "foo", __runInitializers(_init, 6, Foo2)), __runInitializers(_init, 9, Foo2); + __publicField(Foo2, "foo", __runInitializers(_init, 8, Foo2)), __runInitializers(_init, 11, Foo2); }, TypeError); }, "Field decorators: Return null (private instance field)": () => { @@ -1503,10 +1509,10 @@ const tests = { _foo_dec = [dec]; class Foo2 { constructor() { - __privateAdd(this, _foo, __runInitializers(_init, 6, this)), __runInitializers(_init, 9, this); + __privateAdd(this, _foo, __runInitializers(_init, 8, this)), __runInitializers(_init, 11, this); } } - _init = [, , ,]; + _init = __decoratorStart(null); _foo = new WeakMap(); __decorateElement(_init, 21, "#foo", _foo_dec, _foo); }, TypeError); @@ -1520,10 +1526,10 @@ const tests = { _foo_dec = [dec]; class Foo2 { } - _init = [, , ,]; + _init = __decoratorStart(null); _foo = new WeakMap(); __decorateElement(_init, 29, "#foo", _foo_dec, _foo); - __privateAdd(Foo2, _foo, __runInitializers(_init, 6, Foo2)), __runInitializers(_init, 9, Foo2); + __privateAdd(Foo2, _foo, __runInitializers(_init, 8, Foo2)), __runInitializers(_init, 11, Foo2); }, TypeError); }, "Field decorators: Return object (instance field)": () => { @@ -1535,10 +1541,10 @@ const tests = { _foo_dec = [dec]; class Foo2 { constructor() { - __publicField(this, "foo", __runInitializers(_init, 6, this)), __runInitializers(_init, 9, this); + __publicField(this, "foo", __runInitializers(_init, 8, this)), __runInitializers(_init, 11, this); } } - _init = [, , ,]; + _init = __decoratorStart(null); __decorateElement(_init, 5, "foo", _foo_dec, Foo2); }, TypeError); }, @@ -1551,9 +1557,9 @@ const tests = { _foo_dec = [dec]; class Foo2 { } - _init = [, , ,]; + _init = __decoratorStart(null); __decorateElement(_init, 13, "foo", _foo_dec, Foo2); - __publicField(Foo2, "foo", __runInitializers(_init, 6, Foo2)), __runInitializers(_init, 9, Foo2); + __publicField(Foo2, "foo", __runInitializers(_init, 8, Foo2)), __runInitializers(_init, 11, Foo2); }, TypeError); }, "Field decorators: Return object (private instance field)": () => { @@ -1565,10 +1571,10 @@ const tests = { _foo_dec = [dec]; class Foo2 { constructor() { - __privateAdd(this, _foo, __runInitializers(_init, 6, this)), __runInitializers(_init, 9, this); + __privateAdd(this, _foo, __runInitializers(_init, 8, this)), __runInitializers(_init, 11, this); } } - _init = [, , ,]; + _init = __decoratorStart(null); _foo = new WeakMap(); __decorateElement(_init, 21, "#foo", _foo_dec, _foo); }, TypeError); @@ -1582,10 +1588,10 @@ const tests = { _foo_dec = [dec]; class Foo2 { } - _init = [, , ,]; + _init = __decoratorStart(null); _foo = new WeakMap(); __decorateElement(_init, 29, "#foo", _foo_dec, _foo); - __privateAdd(Foo2, _foo, __runInitializers(_init, 6, Foo2)), __runInitializers(_init, 9, Foo2); + __privateAdd(Foo2, _foo, __runInitializers(_init, 8, Foo2)), __runInitializers(_init, 11, Foo2); }, TypeError); }, "Field decorators: Extra initializer (instance field)": () => { @@ -1604,10 +1610,10 @@ const tests = { _foo_dec = [dec, dec]; class Foo2 { constructor() { - __publicField(this, "foo", __runInitializers(_init, 6, this)), __runInitializers(_init, 9, this); + __publicField(this, "foo", __runInitializers(_init, 8, this)), __runInitializers(_init, 11, this); } } - _init = [, , ,]; + _init = __decoratorStart(null); __decorateElement(_init, 5, "foo", _foo_dec, Foo2); assertEq(() => got, void 0); const instance = new Foo2(); @@ -1630,9 +1636,9 @@ const tests = { _foo_dec = [dec, dec]; class Foo2 { } - _init = [, , ,]; + _init = __decoratorStart(null); __decorateElement(_init, 13, "foo", _foo_dec, Foo2); - __publicField(Foo2, "foo", __runInitializers(_init, 6, Foo2)), __runInitializers(_init, 9, Foo2); + __publicField(Foo2, "foo", __runInitializers(_init, 8, Foo2)), __runInitializers(_init, 11, Foo2); assertEq(() => got.this, Foo2); assertEq(() => got.args.length, 0); }, @@ -1652,10 +1658,10 @@ const tests = { _foo_dec = [dec, dec]; class Foo2 { constructor() { - __privateAdd(this, _foo, __runInitializers(_init, 6, this)), __runInitializers(_init, 9, this); + __privateAdd(this, _foo, __runInitializers(_init, 8, this)), __runInitializers(_init, 11, this); } } - _init = [, , ,]; + _init = __decoratorStart(null); _foo = new WeakMap(); __decorateElement(_init, 21, "#foo", _foo_dec, _foo); assertEq(() => got, void 0); @@ -1679,10 +1685,10 @@ const tests = { _foo_dec = [dec, dec]; class Foo2 { } - _init = [, , ,]; + _init = __decoratorStart(null); _foo = new WeakMap(); __decorateElement(_init, 29, "#foo", _foo_dec, _foo); - __privateAdd(Foo2, _foo, __runInitializers(_init, 6, Foo2)), __runInitializers(_init, 9, Foo2); + __privateAdd(Foo2, _foo, __runInitializers(_init, 8, Foo2)), __runInitializers(_init, 11, Foo2); assertEq(() => got.this, Foo2); assertEq(() => got.args.length, 0); }, @@ -1718,7 +1724,7 @@ const tests = { return this.bar; } } - _init = [, , ,]; + _init = __decoratorStart(null); __decorateElement(_init, 2, "foo", _foo_dec, Foo2); __decorateElement(_init, 2, _b, _bar_dec, Foo2); __decorateElement(_init, 2, _a, _baz_dec, Foo2); @@ -1753,7 +1759,7 @@ const tests = { return this.bar; } } - _init = [, , ,]; + _init = __decoratorStart(null); __decorateElement(_init, 10, "foo", _foo_dec, Foo2); __decorateElement(_init, 10, _b, _bar_dec, Foo2); __decorateElement(_init, 10, _a, _baz_dec, Foo2); @@ -1789,7 +1795,7 @@ const tests = { __privateAdd(this, _bar, 123); } } - _init = [, , ,]; + _init = __decoratorStart(null); _bar = new WeakMap(); _Foo_instances = new WeakSet(); foo_get = function() { @@ -1821,7 +1827,7 @@ const tests = { _foo_dec = [dec]; class Foo2 { } - _init = [, , ,]; + _init = __decoratorStart(null); _bar = new WeakMap(); _Foo_static = new WeakSet(); foo_get = function() { @@ -1854,7 +1860,7 @@ const tests = { return this.bar; } } - _init = [, , ,]; + _init = __decoratorStart(null); __decorateElement(_init, 2, "foo", _foo_dec, Foo2); assertEq(() => Object.getOwnPropertyDescriptor(Foo2.prototype, "foo").get, bar); assertEq(() => new Foo2().foo, 124); @@ -1874,7 +1880,7 @@ const tests = { return this.bar; } } - _init = [, , ,]; + _init = __decoratorStart(null); __decorateElement(_init, 10, "foo", _foo_dec, Foo2); __runInitializers(_init, 3, Foo2); __publicField(Foo2, "bar", 123); @@ -1899,7 +1905,7 @@ const tests = { __privateAdd(this, _bar, 123); } } - _init = [, , ,]; + _init = __decoratorStart(null); _bar = new WeakMap(); _Foo_instances = new WeakSet(); foo_get = function() { @@ -1922,7 +1928,7 @@ const tests = { _foo_dec = [dec]; class Foo2 { } - _init = [, , ,]; + _init = __decoratorStart(null); _bar = new WeakMap(); _Foo_static = new WeakSet(); foo_get = function() { @@ -1966,7 +1972,7 @@ const tests = { return log.push(6); } } - _init = [, , ,]; + _init = __decoratorStart(null); __decorateElement(_init, 2, "foo", _foo_dec, Foo2); log.push(3); new Foo2().foo; @@ -2002,7 +2008,7 @@ const tests = { return log.push(6); } } - _init = [, , ,]; + _init = __decoratorStart(null); __decorateElement(_init, 10, "foo", _foo_dec, Foo2); __runInitializers(_init, 3, Foo2); log.push(3); @@ -2041,7 +2047,7 @@ const tests = { __privateAdd(this, _Foo_instances); } } - _init = [, , ,]; + _init = __decoratorStart(null); _Foo_instances = new WeakSet(); foo_get = function() { return log.push(6); @@ -2079,7 +2085,7 @@ const tests = { _foo_dec = [dec1, dec2]; class Foo2 { } - _init = [, , ,]; + _init = __decoratorStart(null); _Foo_static = new WeakSet(); foo_get = function() { return log.push(6); @@ -2108,7 +2114,7 @@ const tests = { return; } } - _init = [, , ,]; + _init = __decoratorStart(null); __decorateElement(_init, 2, "foo", _foo_dec, Foo2); }, TypeError); }, @@ -2124,7 +2130,7 @@ const tests = { return; } } - _init = [, , ,]; + _init = __decoratorStart(null); __decorateElement(_init, 10, "foo", _foo_dec, Foo2); __runInitializers(_init, 3, Foo2); }, TypeError); @@ -2142,7 +2148,7 @@ const tests = { __privateAdd(this, _Foo_instances); } } - _init = [, , ,]; + _init = __decoratorStart(null); _Foo_instances = new WeakSet(); foo_get = function() { return; @@ -2159,7 +2165,7 @@ const tests = { _foo_dec = [dec]; class Foo2 { } - _init = [, , ,]; + _init = __decoratorStart(null); _Foo_static = new WeakSet(); foo_get = function() { return; @@ -2184,7 +2190,7 @@ const tests = { return; } } - _init = [, , ,]; + _init = __decoratorStart(null); __decorateElement(_init, 2, "foo", _foo_dec, Foo2); }, TypeError); }, @@ -2200,7 +2206,7 @@ const tests = { return; } } - _init = [, , ,]; + _init = __decoratorStart(null); __decorateElement(_init, 10, "foo", _foo_dec, Foo2); __runInitializers(_init, 3, Foo2); }, TypeError); @@ -2218,7 +2224,7 @@ const tests = { __privateAdd(this, _Foo_instances); } } - _init = [, , ,]; + _init = __decoratorStart(null); _Foo_instances = new WeakSet(); foo_get = function() { return; @@ -2235,7 +2241,7 @@ const tests = { _foo_dec = [dec]; class Foo2 { } - _init = [, , ,]; + _init = __decoratorStart(null); _Foo_static = new WeakSet(); foo_get = function() { return; @@ -2267,7 +2273,7 @@ const tests = { return; } } - _init = [, , ,]; + _init = __decoratorStart(null); __decorateElement(_init, 2, "foo", _foo_dec, Foo2); assertEq(() => got, void 0); const instance = new Foo2(); @@ -2293,7 +2299,7 @@ const tests = { return; } } - _init = [, , ,]; + _init = __decoratorStart(null); __decorateElement(_init, 10, "foo", _foo_dec, Foo2); __runInitializers(_init, 3, Foo2); assertEq(() => got.this, Foo2); @@ -2319,7 +2325,7 @@ const tests = { __privateAdd(this, _Foo_instances); } } - _init = [, , ,]; + _init = __decoratorStart(null); _Foo_instances = new WeakSet(); foo_get = function() { return; @@ -2346,7 +2352,7 @@ const tests = { _foo_dec = [dec, dec]; class Foo2 { } - _init = [, , ,]; + _init = __decoratorStart(null); _Foo_static = new WeakSet(); foo_get = function() { return; @@ -2392,7 +2398,7 @@ const tests = { this.bar = x; } } - _init = [, , ,]; + _init = __decoratorStart(null); __decorateElement(_init, 3, "foo", _foo_dec, Foo2); __decorateElement(_init, 3, _b, _bar_dec, Foo2); __decorateElement(_init, 3, _a, _baz_dec, Foo2); @@ -2434,7 +2440,7 @@ const tests = { this.bar = x; } } - _init = [, , ,]; + _init = __decoratorStart(null); __decorateElement(_init, 11, "foo", _foo_dec, Foo2); __decorateElement(_init, 11, _b, _bar_dec, Foo2); __decorateElement(_init, 11, _a, _baz_dec, Foo2); @@ -2477,7 +2483,7 @@ const tests = { __publicField(this, "bar", 0); } } - _init = [, , ,]; + _init = __decoratorStart(null); _Foo_instances = new WeakSet(); foo_set = function(x) { this.bar = x; @@ -2515,7 +2521,7 @@ const tests = { _foo_dec = [dec]; class Foo2 { } - _init = [, , ,]; + _init = __decoratorStart(null); _Foo_static = new WeakSet(); foo_set = function(x) { this.bar = x; @@ -2550,7 +2556,7 @@ const tests = { this.bar = x; } } - _init = [, , ,]; + _init = __decoratorStart(null); __decorateElement(_init, 3, "foo", _foo_dec, Foo2); assertEq(() => Object.getOwnPropertyDescriptor(Foo2.prototype, "foo").set, bar); var obj = new Foo2(); @@ -2572,7 +2578,7 @@ const tests = { this.bar = x; } } - _init = [, , ,]; + _init = __decoratorStart(null); __decorateElement(_init, 11, "foo", _foo_dec, Foo2); __runInitializers(_init, 3, Foo2); __publicField(Foo2, "bar", 123); @@ -2598,7 +2604,7 @@ const tests = { __publicField(this, "bar", 123); } } - _init = [, , ,]; + _init = __decoratorStart(null); _Foo_instances = new WeakSet(); foo_set = function(x) { this.bar = x; @@ -2624,7 +2630,7 @@ const tests = { _foo_dec = [dec]; class Foo2 { } - _init = [, , ,]; + _init = __decoratorStart(null); _Foo_static = new WeakSet(); foo_set = function(x) { this.bar = x; @@ -2670,7 +2676,7 @@ const tests = { log.push(6); } } - _init = [, , ,]; + _init = __decoratorStart(null); __decorateElement(_init, 3, "foo", _foo_dec, Foo2); log.push(3); new Foo2().foo = 123; @@ -2706,7 +2712,7 @@ const tests = { log.push(6); } } - _init = [, , ,]; + _init = __decoratorStart(null); __decorateElement(_init, 11, "foo", _foo_dec, Foo2); __runInitializers(_init, 3, Foo2); log.push(3); @@ -2745,7 +2751,7 @@ const tests = { __privateAdd(this, _Foo_instances); } } - _init = [, , ,]; + _init = __decoratorStart(null); _Foo_instances = new WeakSet(); foo_set = function(x) { log.push(6); @@ -2785,7 +2791,7 @@ const tests = { _foo_dec = [dec1, dec2]; class Foo2 { } - _init = [, , ,]; + _init = __decoratorStart(null); _Foo_static = new WeakSet(); foo_set = function(x) { log.push(6); @@ -2815,7 +2821,7 @@ const tests = { set foo(x) { } } - _init = [, , ,]; + _init = __decoratorStart(null); __decorateElement(_init, 3, "foo", _foo_dec, Foo2); }, TypeError); }, @@ -2830,7 +2836,7 @@ const tests = { static set foo(x) { } } - _init = [, , ,]; + _init = __decoratorStart(null); __decorateElement(_init, 11, "foo", _foo_dec, Foo2); __runInitializers(_init, 3, Foo2); }, TypeError); @@ -2848,7 +2854,7 @@ const tests = { __privateAdd(this, _Foo_instances); } } - _init = [, , ,]; + _init = __decoratorStart(null); _Foo_instances = new WeakSet(); foo_set = function(x) { }; @@ -2864,7 +2870,7 @@ const tests = { _foo_dec = [dec]; class Foo2 { } - _init = [, , ,]; + _init = __decoratorStart(null); _Foo_static = new WeakSet(); foo_set = function(x) { }; @@ -2887,7 +2893,7 @@ const tests = { set foo(x) { } } - _init = [, , ,]; + _init = __decoratorStart(null); __decorateElement(_init, 3, "foo", _foo_dec, Foo2); }, TypeError); }, @@ -2902,7 +2908,7 @@ const tests = { static set foo(x) { } } - _init = [, , ,]; + _init = __decoratorStart(null); __decorateElement(_init, 11, "foo", _foo_dec, Foo2); __runInitializers(_init, 3, Foo2); }, TypeError); @@ -2920,7 +2926,7 @@ const tests = { __privateAdd(this, _Foo_instances); } } - _init = [, , ,]; + _init = __decoratorStart(null); _Foo_instances = new WeakSet(); foo_set = function(x) { }; @@ -2936,7 +2942,7 @@ const tests = { _foo_dec = [dec]; class Foo2 { } - _init = [, , ,]; + _init = __decoratorStart(null); _Foo_static = new WeakSet(); foo_set = function(x) { }; @@ -2966,7 +2972,7 @@ const tests = { set foo(x) { } } - _init = [, , ,]; + _init = __decoratorStart(null); __decorateElement(_init, 3, "foo", _foo_dec, Foo2); assertEq(() => got, void 0); const instance = new Foo2(); @@ -2991,7 +2997,7 @@ const tests = { static set foo(x) { } } - _init = [, , ,]; + _init = __decoratorStart(null); __decorateElement(_init, 11, "foo", _foo_dec, Foo2); __runInitializers(_init, 3, Foo2); assertEq(() => got.this, Foo2); @@ -3017,7 +3023,7 @@ const tests = { __privateAdd(this, _Foo_instances); } } - _init = [, , ,]; + _init = __decoratorStart(null); _Foo_instances = new WeakSet(); foo_set = function(x) { }; @@ -3043,7 +3049,7 @@ const tests = { _foo_dec = [dec, dec]; class Foo2 { } - _init = [, , ,]; + _init = __decoratorStart(null); _Foo_static = new WeakSet(); foo_set = function(x) { }; @@ -3079,12 +3085,12 @@ const tests = { _foo_dec = [dec("foo", "get foo", "set foo")], _b = (_bar_dec = [dec(bar, "get [bar]", "set [bar]")], bar), _a = (_baz_dec = [dec(baz, "get ", "set ")], baz); class Foo2 { constructor() { - __privateAdd(this, _foo, __runInitializers(_init, 6, this, 0)), __runInitializers(_init, 9, this); - __privateAdd(this, __b, __runInitializers(_init, 10, this, 0)), __runInitializers(_init, 13, this); - __privateAdd(this, __a, __runInitializers(_init, 14, this, 0)), __runInitializers(_init, 17, this); + __privateAdd(this, _foo, __runInitializers(_init, 8, this, 0)), __runInitializers(_init, 11, this); + __privateAdd(this, __b, __runInitializers(_init, 12, this, 0)), __runInitializers(_init, 15, this); + __privateAdd(this, __a, __runInitializers(_init, 16, this, 0)), __runInitializers(_init, 19, this); } } - _init = [, , ,]; + _init = __decoratorStart(null); _foo = new WeakMap(); __b = new WeakMap(); __a = new WeakMap(); @@ -3124,16 +3130,16 @@ const tests = { _foo_dec = [dec("foo", "get foo", "set foo")], _b = (_bar_dec = [dec(bar, "get [bar]", "set [bar]")], bar), _a = (_baz_dec = [dec(baz, "get ", "set ")], baz); class Foo2 { } - _init = [, , ,]; + _init = __decoratorStart(null); _foo = new WeakMap(); __b = new WeakMap(); __a = new WeakMap(); __decorateElement(_init, 12, "foo", _foo_dec, Foo2, _foo); __decorateElement(_init, 12, _b, _bar_dec, Foo2, __b); __decorateElement(_init, 12, _a, _baz_dec, Foo2, __a); - __privateAdd(Foo2, _foo, __runInitializers(_init, 6, Foo2, 0)), __runInitializers(_init, 9, Foo2); - __privateAdd(Foo2, __b, __runInitializers(_init, 10, Foo2, 0)), __runInitializers(_init, 13, Foo2); - __privateAdd(Foo2, __a, __runInitializers(_init, 14, Foo2, 0)), __runInitializers(_init, 17, Foo2); + __privateAdd(Foo2, _foo, __runInitializers(_init, 8, Foo2, 0)), __runInitializers(_init, 11, Foo2); + __privateAdd(Foo2, __b, __runInitializers(_init, 12, Foo2, 0)), __runInitializers(_init, 15, Foo2); + __privateAdd(Foo2, __a, __runInitializers(_init, 16, Foo2, 0)), __runInitializers(_init, 19, Foo2); Foo2.foo = 321; assertEq(() => Foo2.foo, 321); Foo2[bar] = 4321; @@ -3170,10 +3176,10 @@ const tests = { class Foo2 { constructor() { __privateAdd(this, _Foo_instances); - __privateAdd(this, _foo, __runInitializers(_init, 6, this, 0)), __runInitializers(_init, 9, this); + __privateAdd(this, _foo, __runInitializers(_init, 8, this, 0)), __runInitializers(_init, 11, this); } } - _init = [, , ,]; + _init = __decoratorStart(null); _foo = new WeakMap(); _Foo_instances = new WeakSet(); _a = __decorateElement(_init, 20, "#foo", _foo_dec, _Foo_instances, _foo), foo_get = _a.get, foo_set = _a.set; @@ -3213,12 +3219,12 @@ const tests = { _foo_dec = [dec]; class Foo2 { } - _init = [, , ,]; + _init = __decoratorStart(null); _foo = new WeakMap(); _Foo_static = new WeakSet(); _a = __decorateElement(_init, 28, "#foo", _foo_dec, _Foo_static, _foo), foo_get = _a.get, foo_set = _a.set; __privateAdd(Foo2, _Foo_static); - __privateAdd(Foo2, _foo, __runInitializers(_init, 6, Foo2, 0)), __runInitializers(_init, 9, Foo2); + __privateAdd(Foo2, _foo, __runInitializers(_init, 8, Foo2, 0)), __runInitializers(_init, 11, Foo2); get$foo = (x) => __privateGet(x, _Foo_static, foo_get); set$foo = (x, y) => { __privateSet(x, _Foo_static, y, foo_set); @@ -3247,10 +3253,10 @@ const tests = { _foo_dec = [dec]; class Foo2 { constructor() { - __privateAdd(this, _foo, __runInitializers(_init, 6, this, 123)), __runInitializers(_init, 9, this); + __privateAdd(this, _foo, __runInitializers(_init, 8, this, 123)), __runInitializers(_init, 11, this); } } - _init = [, , ,]; + _init = __decoratorStart(null); _foo = new WeakMap(); __decorateElement(_init, 4, "foo", _foo_dec, Foo2, _foo); assertEq(() => Object.getOwnPropertyDescriptor(Foo2.prototype, "foo").get, get); @@ -3281,11 +3287,11 @@ const tests = { _foo_dec = [dec]; const _Foo = class _Foo { }; - _init = [, , ,]; + _init = __decoratorStart(null); _foo = new WeakMap(); __decorateElement(_init, 12, "foo", _foo_dec, _Foo, _foo); foo = _Foo; - __privateAdd(_Foo, _foo, __runInitializers(_init, 6, _Foo, 123)), __runInitializers(_init, 9, _Foo); + __privateAdd(_Foo, _foo, __runInitializers(_init, 8, _Foo, 123)), __runInitializers(_init, 11, _Foo); let Foo2 = _Foo; assertEq(() => Object.getOwnPropertyDescriptor(Foo2, "foo").get, get); assertEq(() => Object.getOwnPropertyDescriptor(Foo2, "foo").set, set); @@ -3316,10 +3322,10 @@ const tests = { class Foo2 { constructor() { __privateAdd(this, _Foo_instances); - __privateAdd(this, _foo, __runInitializers(_init, 6, this, 123)), __runInitializers(_init, 9, this); + __privateAdd(this, _foo, __runInitializers(_init, 8, this, 123)), __runInitializers(_init, 11, this); } } - _init = [, , ,]; + _init = __decoratorStart(null); _foo = new WeakMap(); _Foo_instances = new WeakSet(); _a = __decorateElement(_init, 20, "#foo", _foo_dec, _Foo_instances, _foo), foo_get = _a.get, foo_set = _a.set; @@ -3355,7 +3361,7 @@ const tests = { _foo_dec = [dec]; const _Foo = class _Foo { }; - _init = [, , ,]; + _init = __decoratorStart(null); _foo = new WeakMap(); _Foo_static = new WeakSet(); _a = __decorateElement(_init, 28, "#foo", _foo_dec, _Foo_static, _foo), foo_get = _a.get, foo_set = _a.set; @@ -3365,7 +3371,7 @@ const tests = { set$foo = (x, y) => { __privateSet(x, _Foo_static, y, foo_set); }; - __privateAdd(_Foo, _foo, __runInitializers(_init, 6, _Foo, 123)), __runInitializers(_init, 9, _Foo); + __privateAdd(_Foo, _foo, __runInitializers(_init, 8, _Foo, 123)), __runInitializers(_init, 11, _Foo); let Foo2 = _Foo; assertEq(() => get$foo(Foo2), (123 + 1) * 10); assertEq(() => set$foo(Foo2, 321), void 0); @@ -3380,10 +3386,10 @@ const tests = { _foo_dec = [dec]; class Foo2 { constructor() { - __privateAdd(this, _foo, __runInitializers(_init, 6, this)), __runInitializers(_init, 9, this); + __privateAdd(this, _foo, __runInitializers(_init, 8, this)), __runInitializers(_init, 11, this); } } - _init = [, , ,]; + _init = __decoratorStart(null); _foo = new WeakMap(); __decorateElement(_init, 4, "foo", _foo_dec, Foo2, _foo); }, TypeError); @@ -3397,10 +3403,10 @@ const tests = { _foo_dec = [dec]; class Foo2 { } - _init = [, , ,]; + _init = __decoratorStart(null); _foo = new WeakMap(); __decorateElement(_init, 12, "foo", _foo_dec, Foo2, _foo); - __privateAdd(Foo2, _foo, __runInitializers(_init, 6, Foo2)), __runInitializers(_init, 9, Foo2); + __privateAdd(Foo2, _foo, __runInitializers(_init, 8, Foo2)), __runInitializers(_init, 11, Foo2); }, TypeError); }, "Auto-accessor decorators: Return null (private instance auto-accessor)": () => { @@ -3413,10 +3419,10 @@ const tests = { class Foo2 { constructor() { __privateAdd(this, _Foo_instances); - __privateAdd(this, _foo, __runInitializers(_init, 6, this)), __runInitializers(_init, 9, this); + __privateAdd(this, _foo, __runInitializers(_init, 8, this)), __runInitializers(_init, 11, this); } } - _init = [, , ,]; + _init = __decoratorStart(null); _foo = new WeakMap(); _Foo_instances = new WeakSet(); _a = __decorateElement(_init, 20, "#foo", _foo_dec, _Foo_instances, _foo), foo_get = _a.get, foo_set = _a.set; @@ -3431,12 +3437,12 @@ const tests = { _foo_dec = [dec]; class Foo2 { } - _init = [, , ,]; + _init = __decoratorStart(null); _foo = new WeakMap(); _Foo_static = new WeakSet(); _a = __decorateElement(_init, 28, "#foo", _foo_dec, _Foo_static, _foo), foo_get = _a.get, foo_set = _a.set; __privateAdd(Foo2, _Foo_static); - __privateAdd(Foo2, _foo, __runInitializers(_init, 6, Foo2)), __runInitializers(_init, 9, Foo2); + __privateAdd(Foo2, _foo, __runInitializers(_init, 8, Foo2)), __runInitializers(_init, 11, Foo2); }, TypeError); }, "Auto-accessor decorators: Extra initializer (instance auto-accessor)": () => { @@ -3455,10 +3461,10 @@ const tests = { _foo_dec = [dec, dec]; class Foo2 { constructor() { - __privateAdd(this, _foo, __runInitializers(_init, 6, this)), __runInitializers(_init, 9, this); + __privateAdd(this, _foo, __runInitializers(_init, 8, this)), __runInitializers(_init, 11, this); } } - _init = [, , ,]; + _init = __decoratorStart(null); _foo = new WeakMap(); __decorateElement(_init, 4, "foo", _foo_dec, Foo2, _foo); assertEq(() => got, void 0); @@ -3482,10 +3488,10 @@ const tests = { _foo_dec = [dec, dec]; class Foo2 { } - _init = [, , ,]; + _init = __decoratorStart(null); _foo = new WeakMap(); __decorateElement(_init, 12, "foo", _foo_dec, Foo2, _foo); - __privateAdd(Foo2, _foo, __runInitializers(_init, 6, Foo2)), __runInitializers(_init, 9, Foo2); + __privateAdd(Foo2, _foo, __runInitializers(_init, 8, Foo2)), __runInitializers(_init, 11, Foo2); assertEq(() => got.this, Foo2); assertEq(() => got.args.length, 0); }, @@ -3506,10 +3512,10 @@ const tests = { class Foo2 { constructor() { __privateAdd(this, _Foo_instances); - __privateAdd(this, _foo, __runInitializers(_init, 6, this)), __runInitializers(_init, 9, this); + __privateAdd(this, _foo, __runInitializers(_init, 8, this)), __runInitializers(_init, 11, this); } } - _init = [, , ,]; + _init = __decoratorStart(null); _foo = new WeakMap(); _Foo_instances = new WeakSet(); _a = __decorateElement(_init, 20, "#foo", _foo_dec, _Foo_instances, _foo), foo_get = _a.get, foo_set = _a.set; @@ -3534,18 +3540,18 @@ const tests = { _foo_dec = [dec, dec]; class Foo2 { } - _init = [, , ,]; + _init = __decoratorStart(null); _foo = new WeakMap(); _Foo_static = new WeakSet(); _a = __decorateElement(_init, 28, "#foo", _foo_dec, _Foo_static, _foo), foo_get = _a.get, foo_set = _a.set; __privateAdd(Foo2, _Foo_static); - __privateAdd(Foo2, _foo, __runInitializers(_init, 6, Foo2)), __runInitializers(_init, 9, Foo2); + __privateAdd(Foo2, _foo, __runInitializers(_init, 8, Foo2)), __runInitializers(_init, 11, Foo2); assertEq(() => got.this, Foo2); assertEq(() => got.args.length, 0); }, // Decorator list evaluation "Decorator list evaluation: Computed names (class statement)": () => { - var _dec, _a, _dec2, _b, _dec3, _c, _dec4, _d, _dec5, _e, _dec6, _f, _dec7, _g, _dec8, _h, _dec9, _i, _dec10, _j, _Foo_decorators, _init, __b, __a; + var _dec, _a, _dec2, _b, _dec3, _c, _dec4, _d, _dec5, _e, _dec6, _f, _dec7, _g, _dec8, _h, _dec9, _i, _dec10, _j, _Foo_decorators, _init, __b, __a, _k; const log = []; const foo = (n) => { log.push(n); @@ -3575,12 +3581,12 @@ const tests = { } }; _Foo_decorators = [foo(0)]; - class Foo2 extends (foo(1), Object) { + class Foo2 extends (_k = (foo(1), Object)) { constructor() { super(...arguments); __runInitializers(_init, 5, this); - __publicField(this, _h, __runInitializers(_init, 18, this)), __runInitializers(_init, 21, this); - __privateAdd(this, __b, __runInitializers(_init, 10, this)), __runInitializers(_init, 13, this); + __publicField(this, _h, __runInitializers(_init, 20, this)), __runInitializers(_init, 23, this); + __privateAdd(this, __b, __runInitializers(_init, 12, this)), __runInitializers(_init, 15, this); } [_j = (_dec10 = [foo(2)], computed.method)]() { } @@ -3597,7 +3603,7 @@ const tests = { static set [(_c = (_dec3 = [foo(16)], computed.setter), _b = (_dec2 = [foo(18)], computed.accessor), _a = (_dec = [foo(20)], computed.accessor), _c)](x) { } } - _init = [, , ,]; + _init = __decoratorStart(_k); __b = new WeakMap(); __a = new WeakMap(); __decorateElement(_init, 9, _i, _dec9, Foo2); @@ -3612,13 +3618,13 @@ const tests = { __decorateElement(_init, 5, _h, _dec8, Foo2); Foo2 = __decorateElement(_init, 0, "Foo", _Foo_decorators, Foo2); __runInitializers(_init, 3, Foo2); - __publicField(Foo2, _g, __runInitializers(_init, 14, Foo2)), __runInitializers(_init, 17, Foo2); - __privateAdd(Foo2, __a, __runInitializers(_init, 6, Foo2)), __runInitializers(_init, 9, Foo2); + __publicField(Foo2, _g, __runInitializers(_init, 16, Foo2)), __runInitializers(_init, 19, Foo2); + __privateAdd(Foo2, __a, __runInitializers(_init, 8, Foo2)), __runInitializers(_init, 11, Foo2); __runInitializers(_init, 1, Foo2); assertEq(() => "" + log, "0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21"); }, "Decorator list evaluation: Computed names (class expression)": () => { - var _dec, _a, _dec2, _b, _dec3, _c, _dec4, _d, _dec5, _e, _dec6, _f, _dec7, _g, _dec8, _h, _dec9, _i, _dec10, _j, _class_decorators, _init, _k, __b, __a; + var _dec, _a, _dec2, _b, _dec3, _c, _dec4, _d, _dec5, _e, _dec6, _f, _dec7, _g, _dec8, _h, _dec9, _i, _dec10, _j, _class_decorators, _init, _k, __b, __a, _l; const log = []; const foo = (n) => { log.push(n); @@ -3647,12 +3653,12 @@ const tests = { return Symbol("accessor"); } }; - _class_decorators = [foo(0)], _k = class extends (foo(1), Object) { + _class_decorators = [foo(0)], _k = class extends (_l = (foo(1), Object)) { constructor() { super(...arguments); __runInitializers(_init, 5, this); - __publicField(this, _h, __runInitializers(_init, 18, this)), __runInitializers(_init, 21, this); - __privateAdd(this, __b, __runInitializers(_init, 10, this)), __runInitializers(_init, 13, this); + __publicField(this, _h, __runInitializers(_init, 20, this)), __runInitializers(_init, 23, this); + __privateAdd(this, __b, __runInitializers(_init, 12, this)), __runInitializers(_init, 15, this); } [_j = (_dec10 = [foo(2)], computed.method)]() { } @@ -3668,7 +3674,7 @@ const tests = { } static set [(_c = (_dec3 = [foo(16)], computed.setter), _b = (_dec2 = [foo(18)], computed.accessor), _a = (_dec = [foo(20)], computed.accessor), _c)](x) { } - }, _init = [, , ,], __b = new WeakMap(), __a = new WeakMap(), __decorateElement(_init, 9, _i, _dec9, _k), __decorateElement(_init, 10, _e, _dec5, _k), __decorateElement(_init, 11, _c, _dec3, _k), __decorateElement(_init, 12, _a, _dec, _k, __a), __decorateElement(_init, 1, _j, _dec10, _k), __decorateElement(_init, 2, _f, _dec6, _k), __decorateElement(_init, 3, _d, _dec4, _k), __decorateElement(_init, 4, _b, _dec2, _k, __b), __decorateElement(_init, 13, _g, _dec7, _k), __decorateElement(_init, 5, _h, _dec8, _k), _k = __decorateElement(_init, 0, "", _class_decorators, _k), __runInitializers(_init, 3, _k), __publicField(_k, _g, __runInitializers(_init, 14, _k)), __runInitializers(_init, 17, _k), __privateAdd(_k, __a, __runInitializers(_init, 6, _k)), __runInitializers(_init, 9, _k), __runInitializers(_init, 1, _k), _k; + }, _init = __decoratorStart(_l), __b = new WeakMap(), __a = new WeakMap(), __decorateElement(_init, 9, _i, _dec9, _k), __decorateElement(_init, 10, _e, _dec5, _k), __decorateElement(_init, 11, _c, _dec3, _k), __decorateElement(_init, 12, _a, _dec, _k, __a), __decorateElement(_init, 1, _j, _dec10, _k), __decorateElement(_init, 2, _f, _dec6, _k), __decorateElement(_init, 3, _d, _dec4, _k), __decorateElement(_init, 4, _b, _dec2, _k, __b), __decorateElement(_init, 13, _g, _dec7, _k), __decorateElement(_init, 5, _h, _dec8, _k), _k = __decorateElement(_init, 0, "", _class_decorators, _k), __runInitializers(_init, 3, _k), __publicField(_k, _g, __runInitializers(_init, 16, _k)), __runInitializers(_init, 19, _k), __privateAdd(_k, __a, __runInitializers(_init, 8, _k)), __runInitializers(_init, 11, _k), __runInitializers(_init, 1, _k), _k; assertEq(() => "" + log, "0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21"); }, 'Decorator list evaluation: "this" (class statement)': () => { @@ -3687,8 +3693,8 @@ const tests = { constructor() { super(...arguments); __runInitializers(_init, 5, this); - __publicField(this, "field", __runInitializers(_init, 18, this)), __runInitializers(_init, 21, this); - __privateAdd(this, _accessor, __runInitializers(_init, 10, this)), __runInitializers(_init, 13, this); + __publicField(this, "field", __runInitializers(_init, 20, this)), __runInitializers(_init, 23, this); + __privateAdd(this, _accessor, __runInitializers(_init, 12, this)), __runInitializers(_init, 15, this); } method() { } @@ -3705,7 +3711,7 @@ const tests = { static set setter(x) { } } - _init = [, , ,]; + _init = __decoratorStart(_a); _accessor = new WeakMap(); _accessor2 = new WeakMap(); __decorateElement(_init, 9, "method", _method_dec, Foo2); @@ -3720,8 +3726,8 @@ const tests = { __decorateElement(_init, 5, "field", _field_dec2, Foo2); Foo2 = __decorateElement(_init, 0, "Foo", _Foo_decorators, Foo2); __runInitializers(_init, 3, Foo2); - __publicField(Foo2, "field", __runInitializers(_init, 14, Foo2)), __runInitializers(_init, 17, Foo2); - __privateAdd(Foo2, _accessor2, __runInitializers(_init, 6, Foo2)), __runInitializers(_init, 9, Foo2); + __publicField(Foo2, "field", __runInitializers(_init, 16, Foo2)), __runInitializers(_init, 19, Foo2); + __privateAdd(Foo2, _accessor2, __runInitializers(_init, 8, Foo2)), __runInitializers(_init, 11, Foo2); __runInitializers(_init, 1, Foo2); } wrapper.call(ctx); @@ -3742,8 +3748,8 @@ const tests = { constructor() { super(...arguments); __runInitializers(_init, 5, this); - __publicField(this, "field", __runInitializers(_init, 18, this)), __runInitializers(_init, 21, this); - __privateAdd(this, _accessor, __runInitializers(_init, 10, this)), __runInitializers(_init, 13, this); + __publicField(this, "field", __runInitializers(_init, 20, this)), __runInitializers(_init, 23, this); + __privateAdd(this, _accessor, __runInitializers(_init, 12, this)), __runInitializers(_init, 15, this); } method() { } @@ -3759,7 +3765,7 @@ const tests = { } static set setter(x) { } - }, _init = [, , ,], _accessor = new WeakMap(), _accessor2 = new WeakMap(), __decorateElement(_init, 9, "method", _method_dec, _b), __decorateElement(_init, 10, "getter", _getter_dec, _b), __decorateElement(_init, 11, "setter", _setter_dec, _b), __decorateElement(_init, 12, "accessor", _accessor_dec, _b, _accessor2), __decorateElement(_init, 1, "method", _method_dec2, _b), __decorateElement(_init, 2, "getter", _getter_dec2, _b), __decorateElement(_init, 3, "setter", _setter_dec2, _b), __decorateElement(_init, 4, "accessor", _accessor_dec2, _b, _accessor), __decorateElement(_init, 13, "field", _field_dec, _b), __decorateElement(_init, 5, "field", _field_dec2, _b), _b = __decorateElement(_init, 0, "", _class_decorators, _b), __runInitializers(_init, 3, _b), __publicField(_b, "field", __runInitializers(_init, 14, _b)), __runInitializers(_init, 17, _b), __privateAdd(_b, _accessor2, __runInitializers(_init, 6, _b)), __runInitializers(_init, 9, _b), __runInitializers(_init, 1, _b), _b; + }, _init = __decoratorStart(_a), _accessor = new WeakMap(), _accessor2 = new WeakMap(), __decorateElement(_init, 9, "method", _method_dec, _b), __decorateElement(_init, 10, "getter", _getter_dec, _b), __decorateElement(_init, 11, "setter", _setter_dec, _b), __decorateElement(_init, 12, "accessor", _accessor_dec, _b, _accessor2), __decorateElement(_init, 1, "method", _method_dec2, _b), __decorateElement(_init, 2, "getter", _getter_dec2, _b), __decorateElement(_init, 3, "setter", _setter_dec2, _b), __decorateElement(_init, 4, "accessor", _accessor_dec2, _b, _accessor), __decorateElement(_init, 13, "field", _field_dec, _b), __decorateElement(_init, 5, "field", _field_dec2, _b), _b = __decorateElement(_init, 0, "", _class_decorators, _b), __runInitializers(_init, 3, _b), __publicField(_b, "field", __runInitializers(_init, 16, _b)), __runInitializers(_init, 19, _b), __privateAdd(_b, _accessor2, __runInitializers(_init, 8, _b)), __runInitializers(_init, 11, _b), __runInitializers(_init, 1, _b), _b; } wrapper.call(ctx); assertEq(() => "" + log, "0,1,2,3,4,5,6,7,8,9,10,11"); @@ -3775,8 +3781,8 @@ const tests = { constructor() { super(...arguments); __runInitializers(_init, 5, this); - __publicField(this, "field", __runInitializers(_init, 18, this)), __runInitializers(_init, 21, this); - __privateAdd(this, _accessor, __runInitializers(_init, 10, this)), __runInitializers(_init, 13, this); + __publicField(this, "field", __runInitializers(_init, 20, this)), __runInitializers(_init, 23, this); + __privateAdd(this, _accessor, __runInitializers(_init, 12, this)), __runInitializers(_init, 15, this); } method() { } @@ -3793,7 +3799,7 @@ const tests = { static set setter(x) { } } - _init = [, , ,]; + _init = __decoratorStart(_a); _accessor = new WeakMap(); _accessor2 = new WeakMap(); __decorateElement(_init, 9, "method", _method_dec, Foo2); @@ -3808,8 +3814,8 @@ const tests = { __decorateElement(_init, 5, "field", _field_dec2, Foo2); Foo2 = __decorateElement(_init, 0, "Foo", _Foo_decorators, Foo2); __runInitializers(_init, 3, Foo2); - __publicField(Foo2, "field", __runInitializers(_init, 14, Foo2)), __runInitializers(_init, 17, Foo2); - __privateAdd(Foo2, _accessor2, __runInitializers(_init, 6, Foo2)), __runInitializers(_init, 9, Foo2); + __publicField(Foo2, "field", __runInitializers(_init, 16, Foo2)), __runInitializers(_init, 19, Foo2); + __privateAdd(Foo2, _accessor2, __runInitializers(_init, 8, Foo2)), __runInitializers(_init, 11, Foo2); __runInitializers(_init, 1, Foo2); } await wrapper(); @@ -3825,8 +3831,8 @@ const tests = { constructor() { super(...arguments); __runInitializers(_init, 5, this); - __publicField(this, "field", __runInitializers(_init, 18, this)), __runInitializers(_init, 21, this); - __privateAdd(this, _accessor, __runInitializers(_init, 10, this)), __runInitializers(_init, 13, this); + __publicField(this, "field", __runInitializers(_init, 20, this)), __runInitializers(_init, 23, this); + __privateAdd(this, _accessor, __runInitializers(_init, 12, this)), __runInitializers(_init, 15, this); } method() { } @@ -3842,7 +3848,7 @@ const tests = { } static set setter(x) { } - }, _init = [, , ,], _accessor = new WeakMap(), _accessor2 = new WeakMap(), __decorateElement(_init, 9, "method", _method_dec, _b), __decorateElement(_init, 10, "getter", _getter_dec, _b), __decorateElement(_init, 11, "setter", _setter_dec, _b), __decorateElement(_init, 12, "accessor", _accessor_dec, _b, _accessor2), __decorateElement(_init, 1, "method", _method_dec2, _b), __decorateElement(_init, 2, "getter", _getter_dec2, _b), __decorateElement(_init, 3, "setter", _setter_dec2, _b), __decorateElement(_init, 4, "accessor", _accessor_dec2, _b, _accessor), __decorateElement(_init, 13, "field", _field_dec, _b), __decorateElement(_init, 5, "field", _field_dec2, _b), _b = __decorateElement(_init, 0, "", _class_decorators, _b), __runInitializers(_init, 3, _b), __publicField(_b, "field", __runInitializers(_init, 14, _b)), __runInitializers(_init, 17, _b), __privateAdd(_b, _accessor2, __runInitializers(_init, 6, _b)), __runInitializers(_init, 9, _b), __runInitializers(_init, 1, _b), _b; + }, _init = __decoratorStart(_a), _accessor = new WeakMap(), _accessor2 = new WeakMap(), __decorateElement(_init, 9, "method", _method_dec, _b), __decorateElement(_init, 10, "getter", _getter_dec, _b), __decorateElement(_init, 11, "setter", _setter_dec, _b), __decorateElement(_init, 12, "accessor", _accessor_dec, _b, _accessor2), __decorateElement(_init, 1, "method", _method_dec2, _b), __decorateElement(_init, 2, "getter", _getter_dec2, _b), __decorateElement(_init, 3, "setter", _setter_dec2, _b), __decorateElement(_init, 4, "accessor", _accessor_dec2, _b, _accessor), __decorateElement(_init, 13, "field", _field_dec, _b), __decorateElement(_init, 5, "field", _field_dec2, _b), _b = __decorateElement(_init, 0, "", _class_decorators, _b), __runInitializers(_init, 3, _b), __publicField(_b, "field", __runInitializers(_init, 16, _b)), __runInitializers(_init, 19, _b), __privateAdd(_b, _accessor2, __runInitializers(_init, 8, _b)), __runInitializers(_init, 11, _b), __runInitializers(_init, 1, _b), _b; } await wrapper(); assertEq(() => "" + log, "0,1,2,3,4,5,6,7,8,9,10,11"); @@ -3863,8 +3869,8 @@ const tests = { constructor() { super(...arguments); __runInitializers(_init, 5, this); - __publicField(this, "field", __runInitializers(_init, 18, this)), __runInitializers(_init, 21, this); - __privateAdd(this, _accessor, __runInitializers(_init, 10, this)), __runInitializers(_init, 13, this); + __publicField(this, "field", __runInitializers(_init, 20, this)), __runInitializers(_init, 23, this); + __privateAdd(this, _accessor, __runInitializers(_init, 12, this)), __runInitializers(_init, 15, this); } method() { } @@ -3881,7 +3887,7 @@ const tests = { static set setter(x) { } } - _init = [, , ,]; + _init = __decoratorStart(_a); _accessor = new WeakMap(); _accessor2 = new WeakMap(); __decorateElement(_init, 9, "method", _method_dec, Foo2); @@ -3896,8 +3902,8 @@ const tests = { __decorateElement(_init, 5, "field", _field_dec2, Foo2); Foo2 = __decorateElement(_init, 0, "Foo", _Foo_decorators, Foo2); __runInitializers(_init, 3, Foo2); - __publicField(Foo2, "field", __runInitializers(_init, 14, Foo2)), __runInitializers(_init, 17, Foo2); - __privateAdd(Foo2, _accessor2, __runInitializers(_init, 6, Foo2)), __runInitializers(_init, 9, Foo2); + __publicField(Foo2, "field", __runInitializers(_init, 16, Foo2)), __runInitializers(_init, 19, Foo2); + __privateAdd(Foo2, _accessor2, __runInitializers(_init, 8, Foo2)), __runInitializers(_init, 11, Foo2); __runInitializers(_init, 1, Foo2); } } @@ -3918,8 +3924,8 @@ const tests = { constructor() { super(...arguments); __runInitializers(_init, 5, this); - __publicField(this, "field", __runInitializers(_init, 18, this)), __runInitializers(_init, 21, this); - __privateAdd(this, _accessor, __runInitializers(_init, 10, this)), __runInitializers(_init, 13, this); + __publicField(this, "field", __runInitializers(_init, 20, this)), __runInitializers(_init, 23, this); + __privateAdd(this, _accessor, __runInitializers(_init, 12, this)), __runInitializers(_init, 15, this); } method() { } @@ -3935,7 +3941,7 @@ const tests = { } static set setter(x) { } - }, _init = [, , ,], _accessor = new WeakMap(), _accessor2 = new WeakMap(), __decorateElement(_init, 9, "method", _method_dec, _b), __decorateElement(_init, 10, "getter", _getter_dec, _b), __decorateElement(_init, 11, "setter", _setter_dec, _b), __decorateElement(_init, 12, "accessor", _accessor_dec, _b, _accessor2), __decorateElement(_init, 1, "method", _method_dec2, _b), __decorateElement(_init, 2, "getter", _getter_dec2, _b), __decorateElement(_init, 3, "setter", _setter_dec2, _b), __decorateElement(_init, 4, "accessor", _accessor_dec2, _b, _accessor), __decorateElement(_init, 13, "field", _field_dec, _b), __decorateElement(_init, 5, "field", _field_dec2, _b), _b = __decorateElement(_init, 0, "", _class_decorators, _b), __runInitializers(_init, 3, _b), __publicField(_b, "field", __runInitializers(_init, 14, _b)), __runInitializers(_init, 17, _b), __privateAdd(_b, _accessor2, __runInitializers(_init, 6, _b)), __runInitializers(_init, 9, _b), __runInitializers(_init, 1, _b), _b; + }, _init = __decoratorStart(_a), _accessor = new WeakMap(), _accessor2 = new WeakMap(), __decorateElement(_init, 9, "method", _method_dec, _b), __decorateElement(_init, 10, "getter", _getter_dec, _b), __decorateElement(_init, 11, "setter", _setter_dec, _b), __decorateElement(_init, 12, "accessor", _accessor_dec, _b, _accessor2), __decorateElement(_init, 1, "method", _method_dec2, _b), __decorateElement(_init, 2, "getter", _getter_dec2, _b), __decorateElement(_init, 3, "setter", _setter_dec2, _b), __decorateElement(_init, 4, "accessor", _accessor_dec2, _b, _accessor), __decorateElement(_init, 13, "field", _field_dec, _b), __decorateElement(_init, 5, "field", _field_dec2, _b), _b = __decorateElement(_init, 0, "", _class_decorators, _b), __runInitializers(_init, 3, _b), __publicField(_b, "field", __runInitializers(_init, 16, _b)), __runInitializers(_init, 19, _b), __privateAdd(_b, _accessor2, __runInitializers(_init, 8, _b)), __runInitializers(_init, 11, _b), __runInitializers(_init, 1, _b), _b; } } assertEq(() => "" + log, "0,1,2,3,4,5,6,7,8,9,10,11"); @@ -3956,8 +3962,8 @@ const tests = { constructor() { __runInitializers(_init, 5, this); __privateAdd(this, _foo, 10); - __publicField(this, "field", __runInitializers(_init, 18, this)), __runInitializers(_init, 21, this); - __privateAdd(this, _accessor, __runInitializers(_init, 10, this)), __runInitializers(_init, 13, this); + __publicField(this, "field", __runInitializers(_init, 20, this)), __runInitializers(_init, 23, this); + __privateAdd(this, _accessor, __runInitializers(_init, 12, this)), __runInitializers(_init, 15, this); } method() { } @@ -3974,7 +3980,7 @@ const tests = { static set setter(x) { } }; - _init = [, , ,]; + _init = __decoratorStart(null); _foo = new WeakMap(); _accessor = new WeakMap(); _accessor2 = new WeakMap(); @@ -3990,8 +3996,8 @@ const tests = { __decorateElement(_init, 5, "field", _field_dec2, _Foo); _Foo = __decorateElement(_init, 0, "Foo", _Foo_decorators, _Foo); __runInitializers(_init, 3, _Foo); - __publicField(_Foo, "field", __runInitializers(_init, 14, _Foo)), __runInitializers(_init, 17, _Foo); - __privateAdd(_Foo, _accessor2, __runInitializers(_init, 6, _Foo)), __runInitializers(_init, 9, _Foo); + __publicField(_Foo, "field", __runInitializers(_init, 16, _Foo)), __runInitializers(_init, 19, _Foo); + __privateAdd(_Foo, _accessor2, __runInitializers(_init, 8, _Foo)), __runInitializers(_init, 11, _Foo); __runInitializers(_init, 1, _Foo); let Foo2 = _Foo; } @@ -4025,8 +4031,8 @@ const tests = { constructor() { __runInitializers(_init, 5, this); __privateAdd(this, _foo, 10); - __publicField(this, "field", __runInitializers(_init, 18, this)), __runInitializers(_init, 21, this); - __privateAdd(this, _accessor, __runInitializers(_init, 10, this)), __runInitializers(_init, 13, this); + __publicField(this, "field", __runInitializers(_init, 20, this)), __runInitializers(_init, 23, this); + __privateAdd(this, _accessor, __runInitializers(_init, 12, this)), __runInitializers(_init, 15, this); } method() { } @@ -4042,7 +4048,7 @@ const tests = { } static set setter(x) { } - }, _init = [, , ,], _foo = new WeakMap(), _accessor = new WeakMap(), _accessor2 = new WeakMap(), __decorateElement(_init, 9, "method", _method_dec, _a), __decorateElement(_init, 10, "getter", _getter_dec, _a), __decorateElement(_init, 11, "setter", _setter_dec, _a), __decorateElement(_init, 12, "accessor", _accessor_dec, _a, _accessor2), __decorateElement(_init, 1, "method", _method_dec2, _a), __decorateElement(_init, 2, "getter", _getter_dec2, _a), __decorateElement(_init, 3, "setter", _setter_dec2, _a), __decorateElement(_init, 4, "accessor", _accessor_dec2, _a, _accessor), __decorateElement(_init, 13, "field", _field_dec, _a), __decorateElement(_init, 5, "field", _field_dec2, _a), _a = __decorateElement(_init, 0, "Foo", _Foo_decorators, _a), __runInitializers(_init, 3, _a), __publicField(_a, "field", __runInitializers(_init, 14, _a)), __runInitializers(_init, 17, _a), __privateAdd(_a, _accessor2, __runInitializers(_init, 6, _a)), __runInitializers(_init, 9, _a), __runInitializers(_init, 1, _a), _a; + }, _init = __decoratorStart(null), _foo = new WeakMap(), _accessor = new WeakMap(), _accessor2 = new WeakMap(), __decorateElement(_init, 9, "method", _method_dec, _a), __decorateElement(_init, 10, "getter", _getter_dec, _a), __decorateElement(_init, 11, "setter", _setter_dec, _a), __decorateElement(_init, 12, "accessor", _accessor_dec, _a, _accessor2), __decorateElement(_init, 1, "method", _method_dec2, _a), __decorateElement(_init, 2, "getter", _getter_dec2, _a), __decorateElement(_init, 3, "setter", _setter_dec2, _a), __decorateElement(_init, 4, "accessor", _accessor_dec2, _a, _accessor), __decorateElement(_init, 13, "field", _field_dec, _a), __decorateElement(_init, 5, "field", _field_dec2, _a), _a = __decorateElement(_init, 0, "Foo", _Foo_decorators, _a), __runInitializers(_init, 3, _a), __publicField(_a, "field", __runInitializers(_init, 16, _a)), __runInitializers(_init, 19, _a), __privateAdd(_a, _accessor2, __runInitializers(_init, 8, _a)), __runInitializers(_init, 11, _a), __runInitializers(_init, 1, _a), _a; } } const log = []; @@ -4062,8 +4068,8 @@ const tests = { let _Foo = class _Foo { constructor() { __runInitializers(_init, 5, this); - __publicField(this, "field", __runInitializers(_init, 18, this)), __runInitializers(_init, 21, this); - __privateAdd(this, _accessor, __runInitializers(_init, 10, this)), __runInitializers(_init, 13, this); + __publicField(this, "field", __runInitializers(_init, 20, this)), __runInitializers(_init, 23, this); + __privateAdd(this, _accessor, __runInitializers(_init, 12, this)), __runInitializers(_init, 15, this); } method() { } @@ -4080,7 +4086,7 @@ const tests = { static set setter(x) { } }; - _init = [, , ,]; + _init = __decoratorStart(null); _accessor = new WeakMap(); _accessor2 = new WeakMap(); __decorateElement(_init, 9, "method", _method_dec, _Foo); @@ -4095,8 +4101,8 @@ const tests = { __decorateElement(_init, 5, "field", _field_dec2, _Foo); _Foo = __decorateElement(_init, 0, "Foo", _Foo_decorators, _Foo); __runInitializers(_init, 3, _Foo); - __publicField(_Foo, "field", __runInitializers(_init, 14, _Foo)), __runInitializers(_init, 17, _Foo); - __privateAdd(_Foo, _accessor2, __runInitializers(_init, 6, _Foo)), __runInitializers(_init, 9, _Foo); + __publicField(_Foo, "field", __runInitializers(_init, 16, _Foo)), __runInitializers(_init, 19, _Foo); + __privateAdd(_Foo, _accessor2, __runInitializers(_init, 8, _Foo)), __runInitializers(_init, 11, _Foo); __runInitializers(_init, 1, _Foo); let Foo2 = _Foo; const originalFoo = Foo2; @@ -4121,8 +4127,8 @@ const tests = { const originalFoo = (_Foo_decorators = [capture(() => Foo)], _method_dec2 = [capture(() => _a)], _method_dec = [capture(() => _a)], _field_dec2 = [capture(() => _a)], _field_dec = [capture(() => _a)], _getter_dec2 = [capture(() => _a)], _getter_dec = [capture(() => _a)], _setter_dec2 = [capture(() => _a)], _setter_dec = [capture(() => _a)], _accessor_dec2 = [capture(() => _a)], _accessor_dec = [capture(() => _a)], _a = class { constructor() { __runInitializers(_init, 5, this); - __publicField(this, "field", __runInitializers(_init, 18, this)), __runInitializers(_init, 21, this); - __privateAdd(this, _accessor, __runInitializers(_init, 10, this)), __runInitializers(_init, 13, this); + __publicField(this, "field", __runInitializers(_init, 20, this)), __runInitializers(_init, 23, this); + __privateAdd(this, _accessor, __runInitializers(_init, 12, this)), __runInitializers(_init, 15, this); } method() { } @@ -4138,13 +4144,210 @@ const tests = { } static set setter(x) { } - }, _init = [, , ,], _accessor = new WeakMap(), _accessor2 = new WeakMap(), __decorateElement(_init, 9, "method", _method_dec, _a), __decorateElement(_init, 10, "getter", _getter_dec, _a), __decorateElement(_init, 11, "setter", _setter_dec, _a), __decorateElement(_init, 12, "accessor", _accessor_dec, _a, _accessor2), __decorateElement(_init, 1, "method", _method_dec2, _a), __decorateElement(_init, 2, "getter", _getter_dec2, _a), __decorateElement(_init, 3, "setter", _setter_dec2, _a), __decorateElement(_init, 4, "accessor", _accessor_dec2, _a, _accessor), __decorateElement(_init, 13, "field", _field_dec, _a), __decorateElement(_init, 5, "field", _field_dec2, _a), _a = __decorateElement(_init, 0, "Foo", _Foo_decorators, _a), __runInitializers(_init, 3, _a), __publicField(_a, "field", __runInitializers(_init, 14, _a)), __runInitializers(_init, 17, _a), __privateAdd(_a, _accessor2, __runInitializers(_init, 6, _a)), __runInitializers(_init, 9, _a), __runInitializers(_init, 1, _a), _a); + }, _init = __decoratorStart(null), _accessor = new WeakMap(), _accessor2 = new WeakMap(), __decorateElement(_init, 9, "method", _method_dec, _a), __decorateElement(_init, 10, "getter", _getter_dec, _a), __decorateElement(_init, 11, "setter", _setter_dec, _a), __decorateElement(_init, 12, "accessor", _accessor_dec, _a, _accessor2), __decorateElement(_init, 1, "method", _method_dec2, _a), __decorateElement(_init, 2, "getter", _getter_dec2, _a), __decorateElement(_init, 3, "setter", _setter_dec2, _a), __decorateElement(_init, 4, "accessor", _accessor_dec2, _a, _accessor), __decorateElement(_init, 13, "field", _field_dec, _a), __decorateElement(_init, 5, "field", _field_dec2, _a), _a = __decorateElement(_init, 0, "Foo", _Foo_decorators, _a), __runInitializers(_init, 3, _a), __publicField(_a, "field", __runInitializers(_init, 16, _a)), __runInitializers(_init, 19, _a), __privateAdd(_a, _accessor2, __runInitializers(_init, 8, _a)), __runInitializers(_init, 11, _a), __runInitializers(_init, 1, _a), _a); const firstFn = fns.shift(); assertThrows(() => firstFn(), ReferenceError); for (const fn of fns) { assertEq(() => fn(), originalFoo); } }, + // Decorator metadata + "Decorator metadata: class statement": () => { + var _staticSetter_dec, _staticGetter_dec, _staticMethod_dec, _staticAccessor_dec, _staticField_dec, _instanceSetter_dec, _instanceGetter_dec, _instanceMethod_dec, _instanceAccessor_dec, _instanceField_dec, _Foo_decorators, _init, _instanceAccessor, _staticAccessor, _staticSetter_dec2, _staticGetter_dec2, _staticMethod_dec2, _staticAccessor_dec2, _staticField_dec2, _instanceSetter_dec2, _instanceGetter_dec2, _instanceMethod_dec2, _instanceAccessor_dec2, _instanceField_dec2, _a, _Bar_decorators, _init2, _instanceField, _instanceAccessor2, _b, instanceAccessor_get, instanceAccessor_set, _Bar_instances, instanceMethod_fn, instanceGetter_get, instanceSetter_set, _staticField, _staticAccessor2, _c, staticAccessor_get, staticAccessor_set, _Bar_static, staticMethod_fn, staticGetter_get, staticSetter_set; + let counter = 0; + const dec = (_, ctx) => { + ctx.metadata[ctx.name] = counter++; + }; + _Foo_decorators = [dec], _instanceField_dec = [dec], _instanceAccessor_dec = [dec], _instanceMethod_dec = [dec], _instanceGetter_dec = [dec], _instanceSetter_dec = [dec], _staticField_dec = [dec], _staticAccessor_dec = [dec], _staticMethod_dec = [dec], _staticGetter_dec = [dec], _staticSetter_dec = [dec]; + class Foo2 { + constructor() { + __runInitializers(_init, 5, this); + __publicField(this, "instanceField", __runInitializers(_init, 20, this)), __runInitializers(_init, 23, this); + __privateAdd(this, _instanceAccessor, __runInitializers(_init, 12, this)), __runInitializers(_init, 15, this); + } + instanceMethod() { + } + get instanceGetter() { + return; + } + set instanceSetter(_) { + } + static staticMethod() { + } + static get staticGetter() { + return; + } + static set staticSetter(_) { + } + } + _init = __decoratorStart(null); + _instanceAccessor = new WeakMap(); + _staticAccessor = new WeakMap(); + __decorateElement(_init, 12, "staticAccessor", _staticAccessor_dec, Foo2, _staticAccessor); + __decorateElement(_init, 9, "staticMethod", _staticMethod_dec, Foo2); + __decorateElement(_init, 10, "staticGetter", _staticGetter_dec, Foo2); + __decorateElement(_init, 11, "staticSetter", _staticSetter_dec, Foo2); + __decorateElement(_init, 4, "instanceAccessor", _instanceAccessor_dec, Foo2, _instanceAccessor); + __decorateElement(_init, 1, "instanceMethod", _instanceMethod_dec, Foo2); + __decorateElement(_init, 2, "instanceGetter", _instanceGetter_dec, Foo2); + __decorateElement(_init, 3, "instanceSetter", _instanceSetter_dec, Foo2); + __decorateElement(_init, 13, "staticField", _staticField_dec, Foo2); + __decorateElement(_init, 5, "instanceField", _instanceField_dec, Foo2); + Foo2 = __decorateElement(_init, 0, "Foo", _Foo_decorators, Foo2); + __runInitializers(_init, 3, Foo2); + __publicField(Foo2, "staticField", __runInitializers(_init, 16, Foo2)), __runInitializers(_init, 19, Foo2); + __privateAdd(Foo2, _staticAccessor, __runInitializers(_init, 8, Foo2)), __runInitializers(_init, 11, Foo2); + __runInitializers(_init, 1, Foo2); + _Bar_decorators = [dec]; + class Bar extends (_a = Foo2, _instanceField_dec2 = [dec], _instanceAccessor_dec2 = [dec], _instanceMethod_dec2 = [dec], _instanceGetter_dec2 = [dec], _instanceSetter_dec2 = [dec], _staticField_dec2 = [dec], _staticAccessor_dec2 = [dec], _staticMethod_dec2 = [dec], _staticGetter_dec2 = [dec], _staticSetter_dec2 = [dec], _a) { + constructor() { + super(...arguments); + __runInitializers(_init2, 5, this); + __privateAdd(this, _Bar_instances); + __privateAdd(this, _instanceField, __runInitializers(_init2, 20, this)), __runInitializers(_init2, 23, this); + __privateAdd(this, _instanceAccessor2, __runInitializers(_init2, 12, this)), __runInitializers(_init2, 15, this); + } + } + _init2 = __decoratorStart(_a); + _instanceField = new WeakMap(); + _instanceAccessor2 = new WeakMap(); + _Bar_instances = new WeakSet(); + instanceMethod_fn = function() { + }; + instanceGetter_get = function() { + return; + }; + instanceSetter_set = function(_) { + }; + _staticField = new WeakMap(); + _staticAccessor2 = new WeakMap(); + _Bar_static = new WeakSet(); + staticMethod_fn = function() { + }; + staticGetter_get = function() { + return; + }; + staticSetter_set = function(_) { + }; + _c = __decorateElement(_init2, 28, "#staticAccessor", _staticAccessor_dec2, _Bar_static, _staticAccessor2), staticAccessor_get = _c.get, staticAccessor_set = _c.set; + staticMethod_fn = __decorateElement(_init2, 25, "#staticMethod", _staticMethod_dec2, _Bar_static, staticMethod_fn); + staticGetter_get = __decorateElement(_init2, 26, "#staticGetter", _staticGetter_dec2, _Bar_static, staticGetter_get); + staticSetter_set = __decorateElement(_init2, 27, "#staticSetter", _staticSetter_dec2, _Bar_static, staticSetter_set); + _b = __decorateElement(_init2, 20, "#instanceAccessor", _instanceAccessor_dec2, _Bar_instances, _instanceAccessor2), instanceAccessor_get = _b.get, instanceAccessor_set = _b.set; + instanceMethod_fn = __decorateElement(_init2, 17, "#instanceMethod", _instanceMethod_dec2, _Bar_instances, instanceMethod_fn); + instanceGetter_get = __decorateElement(_init2, 18, "#instanceGetter", _instanceGetter_dec2, _Bar_instances, instanceGetter_get); + instanceSetter_set = __decorateElement(_init2, 19, "#instanceSetter", _instanceSetter_dec2, _Bar_instances, instanceSetter_set); + __decorateElement(_init2, 29, "#staticField", _staticField_dec2, _staticField); + __decorateElement(_init2, 21, "#instanceField", _instanceField_dec2, _instanceField); + __privateAdd(Bar, _Bar_static); + Bar = __decorateElement(_init2, 0, "Bar", _Bar_decorators, Bar); + __runInitializers(_init2, 3, Bar); + __privateAdd(Bar, _staticField, __runInitializers(_init2, 16, Bar)), __runInitializers(_init2, 19, Bar); + __privateAdd(Bar, _staticAccessor2, __runInitializers(_init2, 8, Bar)), __runInitializers(_init2, 11, Bar); + __runInitializers(_init2, 1, Bar); + const order = (meta) => "" + [ + meta["staticAccessor"], + meta["staticMethod"], + meta["staticGetter"], + meta["staticSetter"], + meta["#staticAccessor"], + meta["#staticMethod"], + meta["#staticGetter"], + meta["#staticSetter"], + meta["instanceAccessor"], + meta["instanceMethod"], + meta["instanceGetter"], + meta["instanceSetter"], + meta["#instanceAccessor"], + meta["#instanceMethod"], + meta["#instanceGetter"], + meta["#instanceSetter"], + meta["staticField"], + meta["#staticField"], + meta["instanceField"], + meta["#instanceField"], + meta["Foo"], + meta["Bar"] + ]; + const foo = Foo2[Symbol.metadata]; + const bar = Bar[Symbol.metadata]; + assertEq(() => order(foo), "0,1,2,3,,,,,4,5,6,7,,,,,8,,9,,10,"); + assertEq(() => order(bar), "0,1,2,3,11,12,13,14,4,5,6,7,15,16,17,18,8,19,9,20,10,21"); + assertEq(() => Object.getPrototypeOf(bar), foo); + }, + "Decorator metadata: class expression": () => { + var _staticSetter_dec, _staticGetter_dec, _staticMethod_dec, _staticAccessor_dec, _staticField_dec, _instanceSetter_dec, _instanceGetter_dec, _instanceMethod_dec, _instanceAccessor_dec, _instanceField_dec, _Foo_decorators, _init, _a, _instanceAccessor, _staticAccessor, _staticSetter_dec2, _staticGetter_dec2, _staticMethod_dec2, _staticAccessor_dec2, _staticField_dec2, _instanceSetter_dec2, _instanceGetter_dec2, _instanceMethod_dec2, _instanceAccessor_dec2, _instanceField_dec2, _b, _Bar_decorators, _init2, _instanceField, _instanceAccessor2, _c, instanceAccessor_get, instanceAccessor_set, _Bar_instances, instanceMethod_fn, instanceGetter_get, instanceSetter_set, _d, _staticField, _staticAccessor2, _e, staticAccessor_get, staticAccessor_set, _Bar_static, staticMethod_fn, staticGetter_get, staticSetter_set; + let counter = 0; + const dec = (_, ctx) => { + ctx.metadata[ctx.name] = counter++; + }; + const Foo2 = (_Foo_decorators = [dec], _instanceField_dec = [dec], _instanceAccessor_dec = [dec], _instanceMethod_dec = [dec], _instanceGetter_dec = [dec], _instanceSetter_dec = [dec], _staticField_dec = [dec], _staticAccessor_dec = [dec], _staticMethod_dec = [dec], _staticGetter_dec = [dec], _staticSetter_dec = [dec], _a = class { + constructor() { + __runInitializers(_init, 5, this); + __publicField(this, "instanceField", __runInitializers(_init, 20, this)), __runInitializers(_init, 23, this); + __privateAdd(this, _instanceAccessor, __runInitializers(_init, 12, this)), __runInitializers(_init, 15, this); + } + instanceMethod() { + } + get instanceGetter() { + return; + } + set instanceSetter(_) { + } + static staticMethod() { + } + static get staticGetter() { + return; + } + static set staticSetter(_) { + } + }, _init = __decoratorStart(null), _instanceAccessor = new WeakMap(), _staticAccessor = new WeakMap(), __decorateElement(_init, 12, "staticAccessor", _staticAccessor_dec, _a, _staticAccessor), __decorateElement(_init, 9, "staticMethod", _staticMethod_dec, _a), __decorateElement(_init, 10, "staticGetter", _staticGetter_dec, _a), __decorateElement(_init, 11, "staticSetter", _staticSetter_dec, _a), __decorateElement(_init, 4, "instanceAccessor", _instanceAccessor_dec, _a, _instanceAccessor), __decorateElement(_init, 1, "instanceMethod", _instanceMethod_dec, _a), __decorateElement(_init, 2, "instanceGetter", _instanceGetter_dec, _a), __decorateElement(_init, 3, "instanceSetter", _instanceSetter_dec, _a), __decorateElement(_init, 13, "staticField", _staticField_dec, _a), __decorateElement(_init, 5, "instanceField", _instanceField_dec, _a), _a = __decorateElement(_init, 0, "Foo", _Foo_decorators, _a), __runInitializers(_init, 3, _a), __publicField(_a, "staticField", __runInitializers(_init, 16, _a)), __runInitializers(_init, 19, _a), __privateAdd(_a, _staticAccessor, __runInitializers(_init, 8, _a)), __runInitializers(_init, 11, _a), __runInitializers(_init, 1, _a), _a), Bar = (_Bar_decorators = [dec], _d = class extends (_b = Foo2, _instanceField_dec2 = [dec], _instanceAccessor_dec2 = [dec], _instanceMethod_dec2 = [dec], _instanceGetter_dec2 = [dec], _instanceSetter_dec2 = [dec], _staticField_dec2 = [dec], _staticAccessor_dec2 = [dec], _staticMethod_dec2 = [dec], _staticGetter_dec2 = [dec], _staticSetter_dec2 = [dec], _b) { + constructor() { + super(...arguments); + __runInitializers(_init2, 5, this); + __privateAdd(this, _Bar_instances); + __privateAdd(this, _instanceField, __runInitializers(_init2, 20, this)), __runInitializers(_init2, 23, this); + __privateAdd(this, _instanceAccessor2, __runInitializers(_init2, 12, this)), __runInitializers(_init2, 15, this); + } + }, _init2 = __decoratorStart(_b), _instanceField = new WeakMap(), _instanceAccessor2 = new WeakMap(), _Bar_instances = new WeakSet(), instanceMethod_fn = function() { + }, instanceGetter_get = function() { + return; + }, instanceSetter_set = function(_) { + }, _staticField = new WeakMap(), _staticAccessor2 = new WeakMap(), _Bar_static = new WeakSet(), staticMethod_fn = function() { + }, staticGetter_get = function() { + return; + }, staticSetter_set = function(_) { + }, _e = __decorateElement(_init2, 28, "#staticAccessor", _staticAccessor_dec2, _Bar_static, _staticAccessor2), staticAccessor_get = _e.get, staticAccessor_set = _e.set, staticMethod_fn = __decorateElement(_init2, 25, "#staticMethod", _staticMethod_dec2, _Bar_static, staticMethod_fn), staticGetter_get = __decorateElement(_init2, 26, "#staticGetter", _staticGetter_dec2, _Bar_static, staticGetter_get), staticSetter_set = __decorateElement(_init2, 27, "#staticSetter", _staticSetter_dec2, _Bar_static, staticSetter_set), _c = __decorateElement(_init2, 20, "#instanceAccessor", _instanceAccessor_dec2, _Bar_instances, _instanceAccessor2), instanceAccessor_get = _c.get, instanceAccessor_set = _c.set, instanceMethod_fn = __decorateElement(_init2, 17, "#instanceMethod", _instanceMethod_dec2, _Bar_instances, instanceMethod_fn), instanceGetter_get = __decorateElement(_init2, 18, "#instanceGetter", _instanceGetter_dec2, _Bar_instances, instanceGetter_get), instanceSetter_set = __decorateElement(_init2, 19, "#instanceSetter", _instanceSetter_dec2, _Bar_instances, instanceSetter_set), __decorateElement(_init2, 29, "#staticField", _staticField_dec2, _staticField), __decorateElement(_init2, 21, "#instanceField", _instanceField_dec2, _instanceField), __privateAdd(_d, _Bar_static), _d = __decorateElement(_init2, 0, "Bar", _Bar_decorators, _d), __runInitializers(_init2, 3, _d), __privateAdd(_d, _staticField, __runInitializers(_init2, 16, _d)), __runInitializers(_init2, 19, _d), __privateAdd(_d, _staticAccessor2, __runInitializers(_init2, 8, _d)), __runInitializers(_init2, 11, _d), __runInitializers(_init2, 1, _d), _d); + const order = (meta) => "" + [ + meta["staticAccessor"], + meta["staticMethod"], + meta["staticGetter"], + meta["staticSetter"], + meta["#staticAccessor"], + meta["#staticMethod"], + meta["#staticGetter"], + meta["#staticSetter"], + meta["instanceAccessor"], + meta["instanceMethod"], + meta["instanceGetter"], + meta["instanceSetter"], + meta["#instanceAccessor"], + meta["#instanceMethod"], + meta["#instanceGetter"], + meta["#instanceSetter"], + meta["staticField"], + meta["#staticField"], + meta["instanceField"], + meta["#instanceField"], + meta["Foo"], + meta["Bar"] + ]; + const foo = Foo2[Symbol.metadata]; + const bar = Bar[Symbol.metadata]; + assertEq(() => order(foo), "0,1,2,3,,,,,4,5,6,7,,,,,8,,9,,10,"); + assertEq(() => order(bar), "0,1,2,3,11,12,13,14,4,5,6,7,15,16,17,18,8,19,9,20,10,21"); + assertEq(() => Object.getPrototypeOf(bar), foo); + }, // Initializer order "Initializer order (public members, class statement)": () => { var _accessor_dec, _accessor_dec2, _setter_dec, _setter_dec2, _getter_dec, _getter_dec2, _field_dec, _field_dec2, _method_dec, _method_dec2, _a, _Foo_decorators, _init, _accessor, _accessor2; @@ -4312,8 +4515,8 @@ const tests = { log.push("ctor:start"); super(); __runInitializers(_init, 5, this); - __publicField(this, "field", __runInitializers(_init, 18, this)), __runInitializers(_init, 21, this); - __privateAdd(this, _accessor, __runInitializers(_init, 10, this)), __runInitializers(_init, 13, this); + __publicField(this, "field", __runInitializers(_init, 20, this)), __runInitializers(_init, 23, this); + __privateAdd(this, _accessor, __runInitializers(_init, 12, this)), __runInitializers(_init, 15, this); log.push("ctor:end"); } method() { @@ -4331,7 +4534,7 @@ const tests = { static set setter(x) { } } - _init = [, , ,]; + _init = __decoratorStart(_a); _accessor = new WeakMap(); _accessor2 = new WeakMap(); __decorateElement(_init, 9, "method", _method_dec, Foo2); @@ -4347,8 +4550,8 @@ const tests = { Foo2 = __decorateElement(_init, 0, "Foo", _Foo_decorators, Foo2); __runInitializers(_init, 3, Foo2); log.push("static:start"); - __publicField(Foo2, "field", __runInitializers(_init, 14, Foo2)), __runInitializers(_init, 17, Foo2); - __privateAdd(Foo2, _accessor2, __runInitializers(_init, 6, Foo2)), __runInitializers(_init, 9, Foo2); + __publicField(Foo2, "field", __runInitializers(_init, 16, Foo2)), __runInitializers(_init, 19, Foo2); + __privateAdd(Foo2, _accessor2, __runInitializers(_init, 8, Foo2)), __runInitializers(_init, 11, Foo2); log.push("static:end"); __runInitializers(_init, 1, Foo2); log.push("after"); @@ -4521,8 +4724,8 @@ const tests = { log.push("ctor:start"); super(); __runInitializers(_init, 5, this); - __publicField(this, "field", __runInitializers(_init, 18, this)), __runInitializers(_init, 21, this); - __privateAdd(this, _accessor, __runInitializers(_init, 10, this)), __runInitializers(_init, 13, this); + __publicField(this, "field", __runInitializers(_init, 20, this)), __runInitializers(_init, 23, this); + __privateAdd(this, _accessor, __runInitializers(_init, 12, this)), __runInitializers(_init, 15, this); log.push("ctor:end"); } method() { @@ -4539,7 +4742,7 @@ const tests = { } static set setter(x) { } - }, _init = [, , ,], _accessor = new WeakMap(), _accessor2 = new WeakMap(), __decorateElement(_init, 9, "method", _method_dec, _b), __decorateElement(_init, 10, "getter", _getter_dec, _b), __decorateElement(_init, 11, "setter", _setter_dec, _b), __decorateElement(_init, 12, "accessor", _accessor_dec, _b, _accessor2), __decorateElement(_init, 1, "method", _method_dec2, _b), __decorateElement(_init, 2, "getter", _getter_dec2, _b), __decorateElement(_init, 3, "setter", _setter_dec2, _b), __decorateElement(_init, 4, "accessor", _accessor_dec2, _b, _accessor), __decorateElement(_init, 13, "field", _field_dec, _b), __decorateElement(_init, 5, "field", _field_dec2, _b), _b = __decorateElement(_init, 0, "Foo", _Foo_decorators, _b), __runInitializers(_init, 3, _b), log.push("static:start"), __publicField(_b, "field", __runInitializers(_init, 14, _b)), __runInitializers(_init, 17, _b), __privateAdd(_b, _accessor2, __runInitializers(_init, 6, _b)), __runInitializers(_init, 9, _b), log.push("static:end"), __runInitializers(_init, 1, _b), _b); + }, _init = __decoratorStart(_a), _accessor = new WeakMap(), _accessor2 = new WeakMap(), __decorateElement(_init, 9, "method", _method_dec, _b), __decorateElement(_init, 10, "getter", _getter_dec, _b), __decorateElement(_init, 11, "setter", _setter_dec, _b), __decorateElement(_init, 12, "accessor", _accessor_dec, _b, _accessor2), __decorateElement(_init, 1, "method", _method_dec2, _b), __decorateElement(_init, 2, "getter", _getter_dec2, _b), __decorateElement(_init, 3, "setter", _setter_dec2, _b), __decorateElement(_init, 4, "accessor", _accessor_dec2, _b, _accessor), __decorateElement(_init, 13, "field", _field_dec, _b), __decorateElement(_init, 5, "field", _field_dec2, _b), _b = __decorateElement(_init, 0, "Foo", _Foo_decorators, _b), __runInitializers(_init, 3, _b), log.push("static:start"), __publicField(_b, "field", __runInitializers(_init, 16, _b)), __runInitializers(_init, 19, _b), __privateAdd(_b, _accessor2, __runInitializers(_init, 8, _b)), __runInitializers(_init, 11, _b), log.push("static:end"), __runInitializers(_init, 1, _b), _b); log.push("after"); new Foo2(); log.push("end"); @@ -4712,12 +4915,12 @@ const tests = { super(); __runInitializers(_init, 5, this); __privateAdd(this, _Foo_instances); - __privateAdd(this, _field, __runInitializers(_init, 18, this)), __runInitializers(_init, 21, this); - __privateAdd(this, _accessor, __runInitializers(_init, 10, this)), __runInitializers(_init, 13, this); + __privateAdd(this, _field, __runInitializers(_init, 20, this)), __runInitializers(_init, 23, this); + __privateAdd(this, _accessor, __runInitializers(_init, 12, this)), __runInitializers(_init, 15, this); log.push("ctor:end"); } } - _init = [, , ,]; + _init = __decoratorStart(_a); _Foo_instances = new WeakSet(); method_fn = function() { }; @@ -4752,8 +4955,8 @@ const tests = { Foo2 = __decorateElement(_init, 0, "Foo", _Foo_decorators, Foo2); __runInitializers(_init, 3, Foo2); log.push("static:start"); - __privateAdd(Foo2, _staticField, __runInitializers(_init, 14, Foo2)), __runInitializers(_init, 17, Foo2); - __privateAdd(Foo2, _staticAccessor, __runInitializers(_init, 6, Foo2)), __runInitializers(_init, 9, Foo2); + __privateAdd(Foo2, _staticField, __runInitializers(_init, 16, Foo2)), __runInitializers(_init, 19, Foo2); + __privateAdd(Foo2, _staticAccessor, __runInitializers(_init, 8, Foo2)), __runInitializers(_init, 11, Foo2); log.push("static:end"); __runInitializers(_init, 1, Foo2); log.push("after"); @@ -4927,11 +5130,11 @@ const tests = { super(); __runInitializers(_init, 5, this); __privateAdd(this, _Foo_instances); - __privateAdd(this, _field, __runInitializers(_init, 18, this)), __runInitializers(_init, 21, this); - __privateAdd(this, _accessor, __runInitializers(_init, 10, this)), __runInitializers(_init, 13, this); + __privateAdd(this, _field, __runInitializers(_init, 20, this)), __runInitializers(_init, 23, this); + __privateAdd(this, _accessor, __runInitializers(_init, 12, this)), __runInitializers(_init, 15, this); log.push("ctor:end"); } - }, _init = [, , ,], _Foo_instances = new WeakSet(), method_fn = function() { + }, _init = __decoratorStart(_a), _Foo_instances = new WeakSet(), method_fn = function() { }, _Foo_static = new WeakSet(), staticMethod_fn = function() { }, _field = new WeakMap(), _staticField = new WeakMap(), getter_get = function() { return; @@ -4939,7 +5142,7 @@ const tests = { return; }, setter_set = function(x) { }, staticSetter_set = function(x) { - }, _accessor = new WeakMap(), _staticAccessor = new WeakMap(), staticMethod_fn = __decorateElement(_init, 25, "#staticMethod", _staticMethod_dec, _Foo_static, staticMethod_fn), staticGetter_get = __decorateElement(_init, 26, "#staticGetter", _staticGetter_dec, _Foo_static, staticGetter_get), staticSetter_set = __decorateElement(_init, 27, "#staticSetter", _staticSetter_dec, _Foo_static, staticSetter_set), _d = __decorateElement(_init, 28, "#staticAccessor", _staticAccessor_dec, _Foo_static, _staticAccessor), staticAccessor_get = _d.get, staticAccessor_set = _d.set, method_fn = __decorateElement(_init, 17, "#method", _method_dec, _Foo_instances, method_fn), getter_get = __decorateElement(_init, 18, "#getter", _getter_dec, _Foo_instances, getter_get), setter_set = __decorateElement(_init, 19, "#setter", _setter_dec, _Foo_instances, setter_set), _c = __decorateElement(_init, 20, "#accessor", _accessor_dec, _Foo_instances, _accessor), accessor_get = _c.get, accessor_set = _c.set, __decorateElement(_init, 29, "#staticField", _staticField_dec, _staticField), __decorateElement(_init, 21, "#field", _field_dec, _field), __privateAdd(_b, _Foo_static), _b = __decorateElement(_init, 0, "Foo", _Foo_decorators, _b), __runInitializers(_init, 3, _b), log.push("static:start"), __privateAdd(_b, _staticField, __runInitializers(_init, 14, _b)), __runInitializers(_init, 17, _b), __privateAdd(_b, _staticAccessor, __runInitializers(_init, 6, _b)), __runInitializers(_init, 9, _b), log.push("static:end"), __runInitializers(_init, 1, _b), _b); + }, _accessor = new WeakMap(), _staticAccessor = new WeakMap(), staticMethod_fn = __decorateElement(_init, 25, "#staticMethod", _staticMethod_dec, _Foo_static, staticMethod_fn), staticGetter_get = __decorateElement(_init, 26, "#staticGetter", _staticGetter_dec, _Foo_static, staticGetter_get), staticSetter_set = __decorateElement(_init, 27, "#staticSetter", _staticSetter_dec, _Foo_static, staticSetter_set), _d = __decorateElement(_init, 28, "#staticAccessor", _staticAccessor_dec, _Foo_static, _staticAccessor), staticAccessor_get = _d.get, staticAccessor_set = _d.set, method_fn = __decorateElement(_init, 17, "#method", _method_dec, _Foo_instances, method_fn), getter_get = __decorateElement(_init, 18, "#getter", _getter_dec, _Foo_instances, getter_get), setter_set = __decorateElement(_init, 19, "#setter", _setter_dec, _Foo_instances, setter_set), _c = __decorateElement(_init, 20, "#accessor", _accessor_dec, _Foo_instances, _accessor), accessor_get = _c.get, accessor_set = _c.set, __decorateElement(_init, 29, "#staticField", _staticField_dec, _staticField), __decorateElement(_init, 21, "#field", _field_dec, _field), __privateAdd(_b, _Foo_static), _b = __decorateElement(_init, 0, "Foo", _Foo_decorators, _b), __runInitializers(_init, 3, _b), log.push("static:start"), __privateAdd(_b, _staticField, __runInitializers(_init, 16, _b)), __runInitializers(_init, 19, _b), __privateAdd(_b, _staticAccessor, __runInitializers(_init, 8, _b)), __runInitializers(_init, 11, _b), log.push("static:end"), __runInitializers(_init, 1, _b), _b); log.push("after"); new Foo2(); log.push("end"); diff --git a/scripts/decorator-tests.ts b/scripts/decorator-tests.ts index 7b6ec084952..c84f76acc0c 100644 --- a/scripts/decorator-tests.ts +++ b/scripts/decorator-tests.ts @@ -1,3 +1,8 @@ +// Polyfill this in case it's missing +if (!('metadata' in Symbol as any)) { + (Symbol as any).metadata = Symbol('Symbol.metadata') +} + const tests: Record Promise | void> = { // Class decorators 'Class decorators: Basic statement': () => { @@ -2798,6 +2803,99 @@ const tests: Record Promise | void> = { } }, + // Decorator metadata + 'Decorator metadata: class statement': () => { + let counter = 0 + const dec = (_: any, ctx: DecoratorContext) => { + ctx.metadata[ctx.name!] = counter++ + } + @dec class Foo { + @dec instanceField: undefined + @dec accessor instanceAccessor: undefined + @dec instanceMethod() { } + @dec get instanceGetter() { return } + @dec set instanceSetter(_: undefined) { } + + @dec static staticField: undefined + @dec static accessor staticAccessor: undefined + @dec static staticMethod() { } + @dec static get staticGetter() { return } + @dec static set staticSetter(_: undefined) { } + } + @dec class Bar extends Foo { + @dec #instanceField: undefined + @dec accessor #instanceAccessor: undefined + @dec #instanceMethod() { } + @dec get #instanceGetter() { return } + @dec set #instanceSetter(_: undefined) { } + + @dec static #staticField: undefined + @dec static accessor #staticAccessor: undefined + @dec static #staticMethod() { } + @dec static get #staticGetter() { return } + @dec static set #staticSetter(_: undefined) { } + } + const order = (meta: DecoratorMetadataObject) => '' + [ + meta['staticAccessor'], meta['staticMethod'], meta['staticGetter'], meta['staticSetter'], + meta['#staticAccessor'], meta['#staticMethod'], meta['#staticGetter'], meta['#staticSetter'], + meta['instanceAccessor'], meta['instanceMethod'], meta['instanceGetter'], meta['instanceSetter'], + meta['#instanceAccessor'], meta['#instanceMethod'], meta['#instanceGetter'], meta['#instanceSetter'], + meta['staticField'], meta['#staticField'], + meta['instanceField'], meta['#instanceField'], + meta['Foo'], meta['Bar'], + ] + const foo = Foo[Symbol.metadata]! + const bar = Bar[Symbol.metadata]! + assertEq(() => order(foo), '0,1,2,3,,,,,4,5,6,7,,,,,8,,9,,10,') + assertEq(() => order(bar), '0,1,2,3,11,12,13,14,4,5,6,7,15,16,17,18,8,19,9,20,10,21') + assertEq(() => Object.getPrototypeOf(bar), foo) + }, + 'Decorator metadata: class expression': () => { + let counter = 0 + const dec = (_: any, ctx: DecoratorContext) => { + ctx.metadata[ctx.name!] = counter++ + } + const Foo = @dec class { + @dec instanceField: undefined + @dec accessor instanceAccessor: undefined + @dec instanceMethod() { } + @dec get instanceGetter() { return } + @dec set instanceSetter(_: undefined) { } + + @dec static staticField: undefined + @dec static accessor staticAccessor: undefined + @dec static staticMethod() { } + @dec static get staticGetter() { return } + @dec static set staticSetter(_: undefined) { } + }, Bar = @dec class extends Foo { + @dec #instanceField: undefined + @dec accessor #instanceAccessor: undefined + @dec #instanceMethod() { } + @dec get #instanceGetter() { return } + @dec set #instanceSetter(_: undefined) { } + + @dec static #staticField: undefined + @dec static accessor #staticAccessor: undefined + @dec static #staticMethod() { } + @dec static get #staticGetter() { return } + @dec static set #staticSetter(_: undefined) { } + } + const order = (meta: DecoratorMetadataObject) => '' + [ + meta['staticAccessor'], meta['staticMethod'], meta['staticGetter'], meta['staticSetter'], + meta['#staticAccessor'], meta['#staticMethod'], meta['#staticGetter'], meta['#staticSetter'], + meta['instanceAccessor'], meta['instanceMethod'], meta['instanceGetter'], meta['instanceSetter'], + meta['#instanceAccessor'], meta['#instanceMethod'], meta['#instanceGetter'], meta['#instanceSetter'], + meta['staticField'], meta['#staticField'], + meta['instanceField'], meta['#instanceField'], + meta['Foo'], meta['Bar'], + ] + const foo = Foo[Symbol.metadata]! + const bar = Bar[Symbol.metadata]! + assertEq(() => order(foo), '0,1,2,3,,,,,4,5,6,7,,,,,8,,9,,10,') + assertEq(() => order(bar), '0,1,2,3,11,12,13,14,4,5,6,7,15,16,17,18,8,19,9,20,10,21') + assertEq(() => Object.getPrototypeOf(bar), foo) + }, + // Initializer order 'Initializer order (public members, class statement)': () => { const log: string[] = []