tor-browser

The Tor Browser
git clone https://git.dasho.dev/tor-browser.git
Log | Files | Refs | README | LICENSE

private-method-access-on-inner-arrow-function.js (1246B)


      1 // This file was procedurally generated from the following sources:
      2 // - src/class-elements/private-method-access-on-inner-arrow-function.case
      3 // - src/class-elements/default/cls-decl.template
      4 /*---
      5 description: PrivateName of private method 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  #m() { return 'Test262'; }
     26 
     27  method() {
     28    let arrowFunction = () => {
     29      return this.#m();
     30    }
     31 
     32    return arrowFunction();
     33  }
     34 }
     35 
     36 let c = new C();
     37 assert.sameValue(c.method(), 'Test262');
     38 let o = {};
     39 assert.throws(TypeError, function() {
     40  c.method.call(o);
     41 }, 'accessed private method from an ordinary object');
     42 
     43 reportCompare(0, 0);