private-setter-access-on-inner-arrow-function.js (1248B)
1 // This file was procedurally generated from the following sources: 2 // - src/class-elements/private-setter-access-on-inner-arrow-function.case 3 // - src/class-elements/default/cls-decl.template 4 /*--- 5 description: PrivateName of private setter is visible on inner arrow function of class scope (field definitions in a class declaration) 6 esid: prod-FieldDefinition 7 features: [class-methods-private, class] 8 flags: [generated] 9 info: | 10 Updated Productions 11 12 CallExpression[Yield, Await]: 13 CoverCallExpressionAndAsyncArrowHead[?Yield, ?Await] 14 SuperCall[?Yield, ?Await] 15 CallExpression[?Yield, ?Await]Arguments[?Yield, ?Await] 16 CallExpression[?Yield, ?Await][Expression[+In, ?Yield, ?Await]] 17 CallExpression[?Yield, ?Await].IdentifierName 18 CallExpression[?Yield, ?Await]TemplateLiteral[?Yield, ?Await] 19 CallExpression[?Yield, ?Await].PrivateName 20 21 ---*/ 22 23 24 class C { 25 set #m(v) { this._v = v; } 26 27 method() { 28 let arrowFunction = () => { 29 this.#m = 'Test262'; 30 } 31 32 arrowFunction(); 33 } 34 } 35 36 let c = new C(); 37 c.method(); 38 assert.sameValue(c._v, 'Test262'); 39 let o = {}; 40 assert.throws(TypeError, function() { 41 c.method.call(o); 42 }, 'accessed private setter from an ordinary object'); 43 44 reportCompare(0, 0);