| 1 |
// Copyright (C) 2019 Caio Lima (Igalia SL). All rights reserved. |
| 2 |
// This code is governed by the BSD license found in the LICENSE file. |
| 3 |
|
| 4 |
/*--- |
| 5 |
description: Private setter contains proper HomeObject |
| 6 |
esid: sec-method-definitions-runtime-semantics-classelementevaluation |
| 7 |
info: | |
| 8 |
MethodDefinition : set ClassElementName ( PropertySetParameterList ) { FunctionBody } |
| 9 |
1. Let key be the result of evaluating ClassElementName. |
| 10 |
2. ReturnIfAbrupt(key). |
| 11 |
3. If the function code for this MethodDefinition is strict mode code, let strict be true. Otherwise let strict be false. |
| 12 |
4. Let scope be the running execution context's LexicalEnvironment. |
| 13 |
5. Let closure be FunctionCreate(Method, PropertySetParameterList, FunctionBody, scope, strict). |
| 14 |
6. Perform MakeMethod(closure, homeObject). |
| 15 |
7. Perform SetFunctionName(closure, key, "set"). |
| 16 |
8. If key is a Private Name, |
| 17 |
a. If key has a [[Kind]] field, |
| 18 |
i. Assert: key.[[Kind]] is "accessor". |
| 19 |
ii. Assert: key.[[Brand]] is homeObject. |
| 20 |
iii. Assert: key does not have a [[Set]] field. |
| 21 |
iv. Set key.[[Set]] to closure. |
| 22 |
b. Otherwise, |
| 23 |
i. Set key.[[Kind]] to "accessor". |
| 24 |
ii. Set key.[[Brand]] to homeObject. |
| 25 |
iii. Set key.[[Set]] to closure. |
| 26 |
9. Else, |
| 27 |
a. Let desc be the PropertyDescriptor{[[Set]]: closure, [[Enumerable]]: enumerable, [[Configurable]]: true}. |
| 28 |
b. Perform ? DefinePropertyOrThrow(homeObject, key, desc). |
| 29 |
features: [class-methods-private, class] |
| 30 |
---*/ |
| 31 |
|
| 32 |
class A { |
| 33 |
method(v) { |
| 34 |
return v; |
| 35 |
} |
| 36 |
} |
| 37 |
|
| 38 |
class C extends A { |
| 39 |
set #m(v) { |
| 40 |
this._v = super.method(v); |
| 41 |
} |
| 42 |
|
| 43 |
access() { |
| 44 |
return this.#m = "Test262"; |
| 45 |
} |
| 46 |
} |
| 47 |
|
| 48 |
let c = new C(); |
| 49 |
c.access(); |
| 50 |
assert.sameValue(c._v, "Test262"); |
| 51 |
|
| 52 |
reportCompare(0, 0); |