blob: b6d42862e2dc92f858a18c81b6e1bd27ed5f9b6d [file] [log] [blame] [edit]
// Copyright (C) 2019 Caio Lima (Igalia SL). All rights reserved.
// This code is governed by the BSD license found in the LICENSE file.
/*---
desc: PrivateName of private method is visible on inner arrow function of class scope
info: |
Updated Productions
CallExpression[Yield, Await]:
CoverCallExpressionAndAsyncArrowHead[?Yield, ?Await]
SuperCall[?Yield, ?Await]
CallExpression[?Yield, ?Await]Arguments[?Yield, ?Await]
CallExpression[?Yield, ?Await][Expression[+In, ?Yield, ?Await]]
CallExpression[?Yield, ?Await].IdentifierName
CallExpression[?Yield, ?Await]TemplateLiteral[?Yield, ?Await]
CallExpression[?Yield, ?Await].PrivateName
template: default
features: [class-methods-private]
---*/
//- elements
#m() { return 'Test262'; }
method() {
let arrowFunction = () => {
return this.#m();
}
return arrowFunction();
}
//- assertions
let c = new C();
assert.sameValue(c.method(), 'Test262');
let o = {};
assert.throws(TypeError, function() {
c.method.call(o);
}, 'accessed private method from an ordinary object');