| 1 |
// This file was procedurally generated from the following sources: |
| 2 |
// - src/class-elements/private-async-method-name.case |
| 3 |
// - src/class-elements/default/cls-decl.template |
| 4 |
/*--- |
| 5 |
description: Private async methods have name property properly configured (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 |
ClassElement : MethodDefinition |
| 13 |
1. Return ClassElementEvaluation of MethodDefinition with arguments ! Get(homeObject, "prototype"),enumerable, and "prototype". |
| 14 |
|
| 15 |
ClassElement : MethodDefinition |
| 16 |
ClassElement : static MethodDefinition |
| 17 |
1. Perform ? PropertyDefinitionEvaluation with parameters object and enumerable. |
| 18 |
2. Return empty. |
| 19 |
|
| 20 |
AsyncMethod : async [no LineTerminator here] ClassElementName (UniqueFormalParameters) { AsyncFunctionBody } |
| 21 |
1. Let propKey be the result of evaluating ClassElementName. |
| 22 |
... |
| 23 |
10. Perform ? DefineOrdinaryMethod(key, homeObject, closure, enumerable). |
| 24 |
|
| 25 |
ClassElementName : PrivateIdentifier |
| 26 |
1. Let bindingName be StringValue of PrivateIdentifier. |
| 27 |
... |
| 28 |
5. If scopeEnvRec's binding for bindingName is uninitialized, |
| 29 |
a. Let field be NewPrivateName(bindingName). |
| 30 |
b. Perform ! scopeEnvRec.InitializeBinding(bindingName, field). |
| 31 |
6. Otherwise, |
| 32 |
a. Let field be scopeEnvRec.GetBindingValue(bindingName). |
| 33 |
7. Assert: field.[[Description]] is bindingName. |
| 34 |
8. Return field. |
| 35 |
|
| 36 |
DefineOrdinaryMethod(key, homeObject, closure, enumerable) |
| 37 |
1. Perform SetFunctionName(closure, key). |
| 38 |
2. If key is a Private Name, |
| 39 |
a. Assert: key does not have a [[Kind]] field. |
| 40 |
b. Set key.[[Kind]] to "method". |
| 41 |
c. Set key.[[Value]] to closure. |
| 42 |
d. Set key.[[Brand]] to homeObject. |
| 43 |
3. Else, |
| 44 |
a. Let desc be the PropertyDescriptor{[[Value]]: closure, [[Writable]]: true, [[Enumerable]]: enumerable, [[Configurable]]: true}. |
| 45 |
b. Perform ? DefinePropertyOrThrow(homeObject, key, desc). |
| 46 |
|
| 47 |
---*/ |
| 48 |
|
| 49 |
|
| 50 |
class C { |
| 51 |
async #method() {}; |
| 52 |
|
| 53 |
getPrivateMethod() { |
| 54 |
return this.#method; |
| 55 |
} |
| 56 |
} |
| 57 |
|
| 58 |
let c = new C(); |
| 59 |
assert.sameValue(c.getPrivateMethod().name, "#method"); |
| 60 |
|
| 61 |
reportCompare(0, 0); |