From 48826f724f9f51a333051ab212a87dd40dbfebd7 Mon Sep 17 00:00:00 2001 From: Ms2ger Date: Tue, 13 Aug 2019 14:43:59 +0200 Subject: [PATCH] Normative: Add private methods and getter/setters. This includes changes from https://tc39.es/proposal-private-methods/. --- spec.html | 362 ++++++++++++++++++++++++++++++++++++++++-------------- 1 file changed, 270 insertions(+), 92 deletions(-) diff --git a/spec.html b/spec.html index 9a00a91abca..6df2c22d907 100644 --- a/spec.html +++ b/spec.html @@ -1350,6 +1350,16 @@

Object Internal Methods and Internal Slots

Internal method names are polymorphic. This means that different object values may perform different algorithms when a common internal method name is invoked upon them. That actual object upon which an internal method is invoked is the “target” of the invocation. If, at runtime, the implementation of an algorithm attempts to use an internal method of an object that the object does not support, a *TypeError* exception is thrown.

Internal slots correspond to internal state that is associated with objects and used by various ECMAScript specification algorithms. Internal slots are not object properties and they are not inherited. Depending upon the specific internal slot specification, such state may consist of values of any ECMAScript language type or of specific ECMAScript specification type values. Unless explicitly specified otherwise, internal slots are allocated as part of the process of creating an object and may not be dynamically added to an object. Unless specified otherwise, the initial value of an internal slot is the value *undefined*. Various algorithms within this specification create objects that have internal slots. However, the ECMAScript language provides no direct way to associate internal slots with an object.

All objects have an internal slot named [[PrivateFieldValues]], which is a List of PrivateField Records. This List represents the values of the private fields for the object. Initially, it is an empty List.

+

All objects have an internal slot named [[PrivateBrands]], which is a List of ECMAScript values which are used for checking to see if an object supports a private method or accessor. The entries in the list correspond to the "original prototype" (or, in the case of static methods, the "original constructor") which contained the private method or accessor. Initially, it is an empty List.

+ +

Although this specification uses logic of a [[PrivateBrand]] List which is held per-instance, the use of this list obeys certain invariants:

+ + +

Internal methods and internal slots are identified within this specification using names enclosed in double square brackets [[ ]].

summarizes the essential internal methods used by this specification that are applicable to all objects created or manipulated by ECMAScript code. Every object must have algorithms for all of the essential internal methods. However, all objects do not necessarily use the same algorithms for those methods.

The “Signature” column of and other similar tables describes the invocation pattern for each internal method. The invocation pattern always includes a parenthesized list of descriptive parameter names. If a parameter name is the same as an ECMAScript type name then the name describes the required type of the parameter value. If an internal method explicitly returns a value, its parameter list is followed by the symbol “→” and the type name of the returned value. The type names used in signatures refer to the types defined in clause augmented by the following additional names. “any” means the value may be any ECMAScript language type.

@@ -3641,7 +3651,7 @@

The ClassFieldDefinition Record Specification Type

Private Names

-

The Private Name specification type is used to describe a globally unique record which represents a private field. A Private Name may be installed on any ECMAScript object with the PrivateFieldAdd internal algorithm, and then read or written using PrivateFieldGet and PrivateFieldSet.

+

The Private Name specification type is used to describe a globally unique record which represents a private class element (field, method, or accessor). A Private Name may be installed on any ECMAScript object with the PrivateFieldAdd internal algorithm, and then read or written using PrivateFieldGet and PrivateFieldSet.

Each Private Name holds the following information:

@@ -3654,6 +3664,9 @@

Private Names

Type + + For which types is it present + Description @@ -3667,10 +3680,83 @@

Private Names

~string~ + + All + The string value passed to NewPrivateName when creating this Private Name. + + + [[Kind]] + + + `"field"`, `"method"` or `"accessor"` + + + All + + + Indicates what the private name is used for. + + + + + [[Brand]] + + + an ECMAScript value + + + `"method"` or `"accessor"` + + + The "original" class of the private method or accessor; checked for in the [[PrivateBrands]] internal slot of instances before access is provided. + + + + + [[Value]] + + + Function + + + `"method"` + + + The value of the private method. + + + + + [[Get]] + + + Function + + + `"accessor"` + + + The getter for a private accessor. + + + + + [[Set]] + + + Function + + + `"accessor"` + + + The setter for a private accessor. + +
@@ -5135,9 +5221,18 @@

PrivateFieldGet ( _P_, _O_ )

1. Assert: _P_ is a Private Name. 1. Assert: Type(_O_) is Object. - 1. Let _entry_ be ! PrivateFieldFind(_P_, _O_). - 1. If _entry_ is ~empty~, throw a *TypeError* exception. - 1. Return _entry_.[[PrivateFieldValue]]. + 1. If _P_.[[Kind]] is `"field"`, + 1. Let _entry_ be ! PrivateFieldFind(_P_, _O_). + 1. If _entry_ is ~empty~, throw a *TypeError* exception. + 1. Return _entry_.[[PrivateFieldValue]]. + 1. Perform ? PrivateBrandCheck(_O_, _P_). + 1. If _P_.[[Kind]] is `"method"`, + 1. Return _P_.[[Value]]. + 1. Else, + 1. Assert: _P_.[[Kind]] is `"accessor"`. + 1. If _P_ does not have a [[Get]] field, throw a *TypeError* exception. + 1. Let _getter_ be _P_.[[Get]]. + 1. Return ? Call(_getter_, _O_).
@@ -5146,9 +5241,19 @@

PrivateFieldSet ( _P_, _O_, _value_ )

1. Assert: _P_ is a Private Name. 1. Assert: Type(_O_) is Object. - 1. Let _entry_ be ! PrivateFieldFind(_P_, _O_). - 1. If _entry_ is ~empty~, throw a *TypeError* exception. - 1. Set _entry_.[[PrivateFieldValue]] to _value_. + 1. If _P_.[[Kind]] is `"field"`, + 1. Let _entry_ be ! PrivateFieldFind(_P_, _O_). + 1. If _entry_ is ~empty~, throw a *TypeError* exception. + 1. Set _entry_.[[PrivateFieldValue]] to _value_. + 1. Return. + 1. If _P_.[[Kind]] is `"method"`, throw a *TypeError* exception. + 1. Else, + 1. Assert: _P_.[[Kind]] is `"accessor"`. + 1. Perform ? PrivateBrandCheck(_O_, _P_). + 1. If _P_ does not have a [[Set]] field, throw a *TypeError* exception. + 1. Let _setter_ be _P_.[[Set]]. + 1. Perform ? Call(_setter_, _O_, _value_). + 1. Return. @@ -5178,12 +5283,31 @@

InitializeInstanceElements ( _O_, _constructor_ )

1. Assert: Type(_O_) is Object. 1. Assert: _constructor_ is an ECMAScript function object. + 1. If _constructor_.[[PrivateBrand]] is not *undefined*, + 1. Perform ? PrivateBrandAdd(_O_, _constructor_.[[PrivateBrand]]). 1. Let _fields_ be the value of _constructor_.[[Fields]]. 1. For each item _fieldRecord_ in order from _fields_, 1. Perform ? DefineField(_O_, _fieldRecord_). 1. Return. + + +

PrivateBrandCheck ( _O_, _P_ )

+ + 1. If _O_.[[PrivateBrands]] does not contain an entry _e_ such that SameValue(_e_, _P_.[[Brand]]) is *true*, + 1. Throw a *TypeError* exception. + +
+ + +

PrivateBrandAdd ( _O_, _brand_ )

+ + 1. If _O_.[[PrivateBrands]] contains an entry _e_ such that SameValue(_e_, _brand_) is *true*, + 1. Throw a *TypeError* exception. + 1. Append _brand_ to _O_.[[PrivateBrands]]. + +
@@ -12069,6 +12193,9 @@

Static Semantics: Early Errors

  • It is a Syntax Error if HasDirectSuper of |MethodDefinition| is *true*.
  • +
  • + It is a Syntax Error if PrivateBoundIdentifiers of |MethodDefinition| is non-empty. +
  • In addition to describing an actual object initializer the |ObjectLiteral| productions are also used as a cover grammar for |ObjectAssignmentPattern| and may be recognized as part of a |CoverParenthesizedExpressionAndArrowParameterList|. When |ObjectLiteral| appears in a context where |ObjectAssignmentPattern| is required the following Early Error rules are not applied. In addition, they are not applied when initially parsing a |CoverParenthesizedExpressionAndArrowParameterList| or |CoverCallExpressionAndAsyncArrowHead|.

    PropertyDefinition : CoverInitializedName @@ -19229,12 +19356,12 @@

    Method Definitions

    Syntax

    MethodDefinition[Yield, Await] : - PropertyName[?Yield, ?Await] `(` UniqueFormalParameters[~Yield, ~Await] `)` `{` FunctionBody[~Yield, ~Await] `}` + ClassElementName[?Yield, ?Await] `(` UniqueFormalParameters[~Yield, ~Await] `)` `{` FunctionBody[~Yield, ~Await] `}` GeneratorMethod[?Yield, ?Await] AsyncMethod[?Yield, ?Await] AsyncGeneratorMethod[?Yield, ?Await] - `get` PropertyName[?Yield, ?Await] `(` `)` `{` FunctionBody[~Yield, ~Await] `}` - `set` PropertyName[?Yield, ?Await] `(` PropertySetParameterList `)` `{` FunctionBody[~Yield, ~Await] `}` + `get` ClassElementName[?Yield, ?Await] `(` `)` `{` FunctionBody[~Yield, ~Await] `}` + `set` ClassElementName[?Yield, ?Await] `(` PropertySetParameterList `)` `{` FunctionBody[~Yield, ~Await] `}` PropertySetParameterList : FormalParameter[~Yield, ~Await] @@ -19242,7 +19369,7 @@

    Syntax

    Static Semantics: Early Errors

    - MethodDefinition : PropertyName `(` UniqueFormalParameters `)` `{` FunctionBody `}` + MethodDefinition : ClassElementName `(` UniqueFormalParameters `)` `{` FunctionBody `}`
    • It is a Syntax Error if ContainsUseStrict of |FunctionBody| is *true* and IsSimpleParameterList of |UniqueFormalParameters| is *false*. @@ -19251,7 +19378,7 @@

      Static Semantics: Early Errors

      It is a Syntax Error if any element of the BoundNames of |UniqueFormalParameters| also occurs in the LexicallyDeclaredNames of |FunctionBody|.
    - MethodDefinition : `set` PropertyName `(` PropertySetParameterList `)` `{` FunctionBody `}` + MethodDefinition : `set` ClassElementName `(` PropertySetParameterList `)` `{` FunctionBody `}`
    • It is a Syntax Error if BoundNames of |PropertySetParameterList| contains any duplicate elements. @@ -19271,12 +19398,12 @@

      Static Semantics: ComputedPropertyContains

      MethodDefinition : - PropertyName `(` UniqueFormalParameters `)` `{` FunctionBody `}` - `get` PropertyName `(` `)` `{` FunctionBody `}` - `set` PropertyName `(` PropertySetParameterList `)` `{` FunctionBody `}` + ClassElementName `(` UniqueFormalParameters `)` `{` FunctionBody `}` + `get` ClassElementName `(` `)` `{` FunctionBody `}` + `set` ClassElementName `(` PropertySetParameterList `)` `{` FunctionBody `}` - 1. Return the result of ComputedPropertyContains for |PropertyName| with argument _symbol_. + 1. Return the result of ComputedPropertyContains for |ClassElementName| with argument _symbol_. @@ -19293,16 +19420,16 @@

      Static Semantics: ExpectedArgumentCount

      Static Semantics: HasDirectSuper

      - MethodDefinition : PropertyName `(` UniqueFormalParameters `)` `{` FunctionBody `}` + MethodDefinition : ClassElementName `(` UniqueFormalParameters `)` `{` FunctionBody `}` 1. If |UniqueFormalParameters| Contains |SuperCall| is *true*, return *true*. 1. Return |FunctionBody| Contains |SuperCall|. - MethodDefinition : `get` PropertyName `(` `)` `{` FunctionBody `}` + MethodDefinition : `get` ClassElementName `(` `)` `{` FunctionBody `}` 1. Return |FunctionBody| Contains |SuperCall|. - MethodDefinition : `set` PropertyName `(` PropertySetParameterList `)` `{` FunctionBody `}` + MethodDefinition : `set` ClassElementName `(` PropertySetParameterList `)` `{` FunctionBody `}` 1. If |PropertySetParameterList| Contains |SuperCall| is *true*, return *true*. 1. Return |FunctionBody| Contains |SuperCall|. @@ -19314,18 +19441,18 @@

      Static Semantics: PropName

      MethodDefinition : - PropertyName `(` UniqueFormalParameters `)` `{` FunctionBody `}` - `get` PropertyName `(` `)` `{` FunctionBody `}` - `set` PropertyName `(` PropertySetParameterList `)` `{` FunctionBody `}` + ClassElementName `(` UniqueFormalParameters `)` `{` FunctionBody `}` + `get` ClassElementName `(` `)` `{` FunctionBody `}` + `set` ClassElementName `(` PropertySetParameterList `)` `{` FunctionBody `}` - 1. Return PropName of |PropertyName|. + 1. Return PropName of |ClassElementName|.

      Static Semantics: SpecialMethod

      - MethodDefinition : PropertyName `(` UniqueFormalParameters `)` `{` FunctionBody `}` + MethodDefinition : ClassElementName `(` UniqueFormalParameters `)` `{` FunctionBody `}` 1. Return *false*. @@ -19334,8 +19461,8 @@

      Static Semantics: SpecialMethod

      GeneratorMethod AsyncMethod AsyncGeneratorMethod - `get` PropertyName `(` `)` `{` FunctionBody `}` - `set` PropertyName `(` PropertySetParameterList `)` `{` FunctionBody `}` + `get` ClassElementName `(` `)` `{` FunctionBody `}` + `set` ClassElementName `(` PropertySetParameterList `)` `{` FunctionBody `}` 1. Return *true*. @@ -19345,7 +19472,7 @@

      Static Semantics: SpecialMethod

      Runtime Semantics: DefineMethod

      With parameter _object_ and optional parameter _functionPrototype_.

      - MethodDefinition : PropertyName `(` UniqueFormalParameters `)` `{` FunctionBody `}` + MethodDefinition : ClassElementName `(` UniqueFormalParameters `)` `{` FunctionBody `}` 1. Let _propKey_ be the result of evaluating |PropertyName|. 1. ReturnIfAbrupt(_propKey_). @@ -19368,14 +19495,13 @@

      Runtime Semantics: DefineMethod

      Runtime Semantics: PropertyDefinitionEvaluation

      With parameters _object_ and _enumerable_.

      - MethodDefinition : PropertyName `(` UniqueFormalParameters `)` `{` FunctionBody `}` + MethodDefinition : ClassElementName `(` UniqueFormalParameters `)` `{` FunctionBody `}` 1. Let _methodDef_ be ? DefineMethod of |MethodDefinition| with argument _object_. 1. Perform SetFunctionName(_methodDef_.[[Closure]], _methodDef_.[[Key]]). - 1. Let _desc_ be the PropertyDescriptor { [[Value]]: _methodDef_.[[Closure]], [[Writable]]: *true*, [[Enumerable]]: _enumerable_, [[Configurable]]: *true* }. - 1. Return ? DefinePropertyOrThrow(_object_, _methodDef_.[[Key]], _desc_). + 1. Perform ? DefineOrdinaryMethod(_methodDef_.[[Key]], _object_, _methodDef_.[[Closure]], _enumerable_). - MethodDefinition : `get` PropertyName `(` `)` `{` FunctionBody `}` + MethodDefinition : `get` ClassElementName `(` `)` `{` FunctionBody `}` 1. Let _propKey_ be the result of evaluating |PropertyName|. 1. ReturnIfAbrupt(_propKey_). @@ -19386,10 +19512,21 @@

      Runtime Semantics: PropertyDefinitionEvaluation

      1. Perform MakeMethod(_closure_, _object_). 1. Perform SetFunctionName(_closure_, _propKey_, `"get"`). 1. Set _closure_.[[SourceText]] to the source text matched by |MethodDefinition|. - 1. Let _desc_ be the PropertyDescriptor { [[Get]]: _closure_, [[Enumerable]]: _enumerable_, [[Configurable]]: *true* }. - 1. Return ? DefinePropertyOrThrow(_object_, _propKey_, _desc_). + 1. If _propKey_ is a Private Name, + 1. If _propKey_ has a [[Kind]] field, + 1. Assert: _propKey_.[[Kind]] is `"accessor"`. + 1. Assert: _propKey_.[[Brand]] is _object_. + 1. Assert: _propKey_ does not have a [[Get]] field. + 1. Set _propKey_.[[Get]] to _closure_. + 1. Otherwise, + 1. Set _propKey_.[[Kind]] to `"accessor"`. + 1. Set _propKey_.[[Brand]] to _object_. + 1. Set _propKey_.[[Get]] to _closure_. + 1. Else, + 1. Let _desc_ be the PropertyDescriptor { [[Get]]: _closure_, [[Enumerable]]: _enumerable_, [[Configurable]]: *true* }. + 1. Return ? DefinePropertyOrThrow(_object_, _propKey_, _desc_).
      - MethodDefinition : `set` PropertyName `(` PropertySetParameterList `)` `{` FunctionBody `}` + MethodDefinition : `set` ClassElementName `(` PropertySetParameterList `)` `{` FunctionBody `}` 1. Let _propKey_ be the result of evaluating |PropertyName|. 1. ReturnIfAbrupt(_propKey_). @@ -19399,8 +19536,19 @@

      Runtime Semantics: PropertyDefinitionEvaluation

      1. Perform MakeMethod(_closure_, _object_). 1. Perform SetFunctionName(_closure_, _propKey_, `"set"`). 1. Set _closure_.[[SourceText]] to the source text matched by |MethodDefinition|. - 1. Let _desc_ be the PropertyDescriptor { [[Set]]: _closure_, [[Enumerable]]: _enumerable_, [[Configurable]]: *true* }. - 1. Return ? DefinePropertyOrThrow(_object_, _propKey_, _desc_). + 1. If _propKey_ is a Private Name, + 1. If _propKey_ has a [[Kind]] field, + 1. Assert: _propKey_.[[Kind]] is `"accessor"`. + 1. Assert: _propKey_.[[Brand]] is _object_. + 1. Assert: _propKey_ does not have a [[Set]] field. + 1. Set _propKey_.[[Set]] to _closure_. + 1. Otherwise, + 1. Set _propKey_.[[Kind]] to `"accessor"`. + 1. Set _propKey_.[[Brand]] to _object_. + 1. Set _propKey_.[[Set]] to _closure_. + 1. Else, + 1. Let _desc_ be the PropertyDescriptor { [[Set]]: _closure_, [[Enumerable]]: _enumerable_, [[Configurable]]: *true* }. + 1. Return ? DefinePropertyOrThrow(_object_, _propKey_, _desc_).
      @@ -19410,7 +19558,7 @@

      Generator Function Definitions

      Syntax

      GeneratorMethod[Yield, Await] : - `*` PropertyName[?Yield, ?Await] `(` UniqueFormalParameters[+Yield, ~Await] `)` `{` GeneratorBody `}` + `*` ClassElementName[?Yield, ?Await] `(` UniqueFormalParameters[+Yield, ~Await] `)` `{` GeneratorBody `}` GeneratorDeclaration[Yield, Await, Default] : `function` `*` BindingIdentifier[?Yield, ?Await] `(` FormalParameters[+Yield, ~Await] `)` `{` GeneratorBody `}` @@ -19439,7 +19587,7 @@

      Syntax

      Static Semantics: Early Errors

      - GeneratorMethod : `*` PropertyName `(` UniqueFormalParameters `)` `{` GeneratorBody `}` + GeneratorMethod : `*` ClassElementName `(` UniqueFormalParameters `)` `{` GeneratorBody `}`
      • It is a Syntax Error if HasDirectSuper of |GeneratorMethod| is *true*. @@ -19512,9 +19660,9 @@

        Static Semantics: BoundNames

        Static Semantics: ComputedPropertyContains

        With parameter _symbol_.

        - GeneratorMethod : `*` PropertyName `(` UniqueFormalParameters `)` `{` GeneratorBody `}` + GeneratorMethod : `*` ClassElementName `(` UniqueFormalParameters `)` `{` GeneratorBody `}` - 1. Return the result of ComputedPropertyContains for |PropertyName| with argument _symbol_. + 1. Return the result of ComputedPropertyContains for |ClassElementName| with argument _symbol_. @@ -19540,7 +19688,7 @@

        Static Semantics: Contains

        Static Semantics: HasDirectSuper

        - GeneratorMethod : `*` PropertyName `(` UniqueFormalParameters `)` `{` GeneratorBody `}` + GeneratorMethod : `*` ClassElementName `(` UniqueFormalParameters `)` `{` GeneratorBody `}` 1. If |UniqueFormalParameters| Contains |SuperCall| is *true*, return *true*. 1. Return |GeneratorBody| Contains |SuperCall|. @@ -19585,9 +19733,9 @@

        Static Semantics: IsFunctionDefinition

        Static Semantics: PropName

        - GeneratorMethod : `*` PropertyName `(` UniqueFormalParameters `)` `{` GeneratorBody `}` + GeneratorMethod : `*` ClassElementName `(` UniqueFormalParameters `)` `{` GeneratorBody `}` - 1. Return PropName of |PropertyName|. + 1. Return PropName of |ClassElementName|.
        @@ -19636,7 +19784,7 @@

        Runtime Semantics: InstantiateFunctionObject

        Runtime Semantics: PropertyDefinitionEvaluation

        With parameters _object_ and _enumerable_.

        - GeneratorMethod : `*` PropertyName `(` UniqueFormalParameters `)` `{` GeneratorBody `}` + GeneratorMethod : `*` ClassElementName `(` UniqueFormalParameters `)` `{` GeneratorBody `}` 1. Let _propKey_ be the result of evaluating |PropertyName|. 1. ReturnIfAbrupt(_propKey_). @@ -19646,10 +19794,8 @@

        Runtime Semantics: PropertyDefinitionEvaluation

        1. Perform MakeMethod(_closure_, _object_). 1. Let _prototype_ be ObjectCreate(%GeneratorPrototype%). 1. Perform DefinePropertyOrThrow(_closure_, `"prototype"`, PropertyDescriptor { [[Value]]: _prototype_, [[Writable]]: *true*, [[Enumerable]]: *false*, [[Configurable]]: *false* }). - 1. Perform SetFunctionName(_closure_, _propKey_). 1. Set _closure_.[[SourceText]] to the source text matched by |GeneratorMethod|. - 1. Let _desc_ be the PropertyDescriptor { [[Value]]: _closure_, [[Writable]]: *true*, [[Enumerable]]: _enumerable_, [[Configurable]]: *true* }. - 1. Return ? DefinePropertyOrThrow(_object_, _propKey_, _desc_). + 1. Return DefineOrdinaryMethod(_propKey_, _object_, _closure_, _enumerable_).
        @@ -19770,7 +19916,7 @@

        Async Generator Function Definitions

        Syntax

        AsyncGeneratorMethod[Yield, Await] : - `async` [no LineTerminator here] `*` PropertyName[?Yield, ?Await] `(` UniqueFormalParameters[+Yield, +Await] `)` `{` AsyncGeneratorBody `}` + `async` [no LineTerminator here] `*` ClassElementName[?Yield, ?Await] `(` UniqueFormalParameters[+Yield, +Await] `)` `{` AsyncGeneratorBody `}` AsyncGeneratorDeclaration[Yield, Await, Default] : `async` [no LineTerminator here] `function` `*` BindingIdentifier[?Yield, ?Await] `(` FormalParameters[+Yield, +Await] `)` `{` AsyncGeneratorBody `}` @@ -19791,7 +19937,7 @@

        Syntax

        Static Semantics: Early Errors

        - AsyncGeneratorMethod : `async` `*` PropertyName `(` UniqueFormalParameters `)` `{` AsyncGeneratorBody `}` + AsyncGeneratorMethod : `async` `*` ClassElementName `(` UniqueFormalParameters `)` `{` AsyncGeneratorBody `}`
        • It is a Syntax Error if HasDirectSuper of |AsyncGeneratorMethod| is *true*.
        • It is a Syntax Error if |UniqueFormalParameters| Contains |YieldExpression| is *true*.
        • @@ -19840,9 +19986,9 @@

          Static Semantics: BoundNames

          Static Semantics: ComputedPropertyContains

          With parameter _symbol_.

          - AsyncGeneratorMethod : `async` `*` PropertyName `(` UniqueFormalParameters `)` `{` AsyncGeneratorBody `}` + AsyncGeneratorMethod : `async` `*` ClassElementName `(` UniqueFormalParameters `)` `{` AsyncGeneratorBody `}` - 1. Return the result of ComputedPropertyContains for |PropertyName| with argument _symbol_. + 1. Return the result of ComputedPropertyContains for |ClassElementName| with argument _symbol_. @@ -19868,7 +20014,7 @@

          Static Semantics: Contains

          Static Semantics: HasDirectSuper

          - AsyncGeneratorMethod : `async` `*` PropertyName `(` UniqueFormalParameters `)` `{` AsyncGeneratorBody `}` + AsyncGeneratorMethod : `async` `*` ClassElementName `(` UniqueFormalParameters `)` `{` AsyncGeneratorBody `}` 1. If |UniqueFormalParameters| Contains |SuperCall| is *true*, return *true*. 1. Return |AsyncGeneratorBody| Contains |SuperCall|. @@ -19913,9 +20059,9 @@

          Static Semantics: IsFunctionDefinition

          Static Semantics: PropName

          - AsyncGeneratorMethod : `async` `*` PropertyName `(` UniqueFormalParameters `)` `{` AsyncGeneratorBody `}` + AsyncGeneratorMethod : `async` `*` ClassElementName `(` UniqueFormalParameters `)` `{` AsyncGeneratorBody `}` - 1. Return PropName of |PropertyName|. + 1. Return PropName of |ClassElementName|.
          @@ -19969,10 +20115,10 @@

          Runtime Semantics: InstantiateFunctionObject

          Runtime Semantics: PropertyDefinitionEvaluation

          With parameter _object_ and _enumerable_.

          - AsyncGeneratorMethod : `async` `*` PropertyName `(` UniqueFormalParameters `)` `{` AsyncGeneratorBody `}` + AsyncGeneratorMethod : `async` `*` ClassElementName `(` UniqueFormalParameters `)` `{` AsyncGeneratorBody `}` - 1. Let _propKey_ be the result of evaluating |PropertyName|. + 1. Let _propKey_ be the result of evaluating |ClassElementName|. 1. ReturnIfAbrupt(_propKey_). 1. Let _scope_ be the running execution context's LexicalEnvironment. 1. Let _privateScope_ be the PrivateEnvironment of the running execution context. @@ -19980,10 +20126,8 @@

          Runtime Semantics: PropertyDefinitionEvaluation

          1. Perform ! MakeMethod(_closure_, _object_). 1. Let _prototype_ be ! ObjectCreate(%AsyncGeneratorPrototype%). 1. Perform ! DefinePropertyOrThrow(_closure_, `"prototype"`, PropertyDescriptor { [[Value]]: _prototype_, [[Writable]]: *true*, [[Enumerable]]: *false*, [[Configurable]]: *false* }). - 1. Perform ! SetFunctionName(_closure_, _propKey_). 1. Set _closure_.[[SourceText]] to the source text matched by |AsyncGeneratorMethod|. - 1. Let _desc_ be PropertyDescriptor { [[Value]]: _closure_, [[Writable]]: *true*, [[Enumerable]]: _enumerable_, [[Configurable]]: *true* }. - 1. Return ? DefinePropertyOrThrow(_object_, _propKey_, _desc_). + 1. Perform ? DefineOrdinaryMethod(_propKey_, _object_, _closure_, _enumerable_).
          @@ -20100,7 +20244,7 @@

          Static Semantics: Early Errors

          It is a Syntax Error if PrototypePropertyNameList of |ClassElementList| contains more than one occurrence of `"constructor"`.
        • - It is a Syntax Error if PrivateBoundIdentifiers of |ClassElementList| contains any duplicate entries. + It is a Syntax Error if PrivateBoundIdentifiers of |ClassElementList| contains any duplicate entries, unless the name is used once for a getter and once for a setter and in no other entries.
        ClassElement : MethodDefinition @@ -20120,6 +20264,9 @@

        Static Semantics: Early Errors

      • It is a Syntax Error if PropName of |MethodDefinition| is `"prototype"`.
      • +
      • + It is a Syntax Error if PrivateBoundIdentifiers of |MethodDefinition| is non-empty. +
      ClassElement : FieldDefinition `;` @@ -20364,6 +20511,21 @@

      Static Semantics: AllPrivateIdentifiersValid

      For all other grammatical productions, recurse on subexpressions/substatements, passing in the _names_ of the caller. If all pieces return *true*, then return *true*. If any returns *false*, return *false*.
      + +

      DefineOrdinaryMethod ( _key_, _homeObject_, _closure_, _enumerable_ )

      + + 1. Perform SetFunctionName(_closure_, _key_). + 1. If _key_ is a Private Name, + 1. Assert: _key_ does not have a [[Kind]] field. + 1. Set _key_.[[Kind]] to `"method"`. + 1. Set _key_.[[Value]] to _closure_. + 1. Set _key_.[[Brand]] to _homeObject_. + 1. Else, + 1. Let _desc_ be the PropertyDescriptor{[[Value]]: _closure_, [[Writable]]: *true*, [[Enumerable]]: _enumerable_, [[Configurable]]: *true*}. + 1. Perform ? DefinePropertyOrThrow(_homeObject_, _key_, _desc_). + +
      +

      Runtime Semantics: ClassElementEvaluation

      With parameters _object_ and _enumerable_.

      @@ -20372,13 +20534,13 @@

      Runtime Semantics: ClassElementEvaluation

      1. Return ClassFieldDefinitionEvaluation of |FieldDefinition| with parameter _object_. + ClassElement : MethodDefinition ClassElement : `static` MethodDefinition - 1. Perform ? PropertyDefinitionEvaluation with parameters _object_ and _enumerable_. - 1. Return ~empty~. + 1. Return PropertyDefinitionEvaluation of |MethodDefinition| with arguments _object_ and _enumerable_.
      @@ -20400,15 +20562,6 @@

      Static Semantics: PrivateBoundIdentifiers

      ClassElementName : PropertyName - - - 1. Return a new empty List. - - - - ClassElement : MethodDefinition `;` - - ClassElement : `static` MethodDefinition `;` ClassElement : `;` @@ -20424,6 +20577,25 @@

      Static Semantics: PrivateBoundIdentifiers

      1. Append to _names_ the elements of PrivateBoundIdentifiers of |ClassElement|. 1. Return _names_. + + + MethodDefinition : + ClassElementName `(` UniqueFormalParameters `)` `{` FunctionBody `}` + `get` ClassElementName `(` `)` `{` FunctionBody `}` + `set` ClassElementName `(` PropertySetParameterList `)` `{` FunctionBody `}` + + GeneratorMethod : + `*` ClassElementName `(` UniqueFormalParameters `)` `{` GeneratorBody `}` + + AsyncMethod : + `async` ClassElementName `(` UniqueFormalParameters `)` `{` AsyncFunctionBody `}` + + AsyncGeneratorMethod : + `async` `*` ClassElementName `(` UniqueFormalParameters `)` `{` AsyncFunctionBody `}` + + + 1. Return PrivateBoundIdentifiers of |ClassElementName|. + @@ -20449,19 +20621,19 @@

      Static Semantics: ContainsArguments

      MethodDefinition : - PropertyName `(` UniqueFormalParameters `)` `{` FunctionBody `}` - `get` PropertyName `(` `)` `{` FunctionBody `}` - `set` PropertyName `(` PropertySetParameterList `)` `{` FunctionBody `}` + ClassElementName `(` UniqueFormalParameters `)` `{` FunctionBody `}` + `get` ClassElementName `(` `)` `{` FunctionBody `}` + `set` ClassElementName `(` PropertySetParameterList `)` `{` FunctionBody `}` - 1. Return the result of ContainsArguments for |PropertyName|. + 1. Return the result of ContainsArguments for |ClassElementName|. - GeneratorMethod : `*` PropertyName `(` UniqueFormalParameters `)` `{` GeneratorBody `}` + GeneratorMethod : `*` ClassElementName `(` UniqueFormalParameters `)` `{` GeneratorBody `}` - 1. Return the result of ContainsArguments for |PropertyName|. + 1. Return the result of ContainsArguments for |ClassElementName|. @@ -20481,7 +20653,7 @@

      Static Semantics: ContainsArguments

      - AsyncMethod : `async` [no LineTerminator here] PropertyName `(` UniqueFormalParameters `)` `{` AsyncFunctionBody `}` + AsyncMethod : `async` [no LineTerminator here] ClassElementName `(` UniqueFormalParameters `)` `{` AsyncFunctionBody `}` 1. Return the result of ContainsArguments for |PropertyName|. @@ -20576,6 +20748,8 @@

      Runtime Semantics: ClassDefinitionEvaluation

      1. If _classBinding_ is not *undefined*, then 1. Perform _classScopeEnvRec_.InitializeBinding(_classBinding_, _F_). 1. Set _F_.[[Fields]] to _instanceFields_. + 1. If PrivateBoundIdentifiers of |ClassBody| contains a Private Name _P_ such that _P_'s [[Kind]] field is either `"method"` or `"accessor"`, + 1. Set _F_.[[PrivateBrand]] to _proto_. 1. Set the running execution context's PrivateEnvironment to _outerPrivateEnvironment_. 1. Return _F_.
      @@ -20646,10 +20820,16 @@

      Runtime Semantics: Evaluation

      1. Let _privateIdentifier_ be StringValue of |PrivateIdentifier|. - 1. Let _privateName_ be NewPrivateName(_privateIdentifier_). 1. Let _scope_ be the running execution context's PrivateEnvironment. 1. Let _scopeEnvRec_ be _scope_'s EnvironmentRecord. - 1. Perform ! _scopeEnvRec_.InitializeBinding(_privateIdentifier_, _privateName_). + 1. Assert: _scopeEnvRec_ has a binding for _privateIdentifier_. + 1. If _scopeEnvRec_'s binding for _privateIdentifier_ is uninitialized, + 1. Let _privateName_ be NewPrivateName(_privateIdentifier_). + 1. Perform ! _scopeEnvRec_.InitializeBinding(_privateIdentifier_, _privateName_). + 1. Otherwise, + 1. Let _privateName_ be _scopeEnvRec_.GetBindingValue(_privateIdentifier_). + 1. NOTE: The only case where this may occur is in getter/setter pairs; other duplicates are prohibited as a Syntax Error. + 1. Assert: _privateName_.[[Description]] is _privateIdentifier_. 1. Return _privateName_.
      @@ -20698,7 +20878,7 @@

      Syntax

      `async` [no LineTerminator here] `function` BindingIdentifier[~Yield, +Await] `(` FormalParameters[~Yield, +Await] `)` `{` AsyncFunctionBody `}` AsyncMethod[Yield, Await] : - `async` [no LineTerminator here] PropertyName[?Yield, ?Await] `(` UniqueFormalParameters[~Yield, +Await] `)` `{` AsyncFunctionBody `}` + `async` [no LineTerminator here] ClassElementName[?Yield, ?Await] `(` UniqueFormalParameters[~Yield, +Await] `)` `{` AsyncFunctionBody `}` AsyncFunctionBody : FunctionBody[~Yield, +Await] @@ -20727,7 +20907,7 @@

      Syntax

      Static Semantics: Early Errors

      - AsyncMethod : `async` PropertyName `(` UniqueFormalParameters `)` `{` AsyncFunctionBody `}` + AsyncMethod : `async` ClassElementName `(` UniqueFormalParameters `)` `{` AsyncFunctionBody `}`
      • It is a Syntax Error if ContainsUseStrict of |AsyncFunctionBody| is *true* and IsSimpleParameterList of |UniqueFormalParameters| is *false*.
      • @@ -20778,10 +20958,10 @@

        Static Semantics: BoundNames

        Static Semantics: ComputedPropertyContains

        With parameter _symbol_.

        - AsyncMethod : `async` PropertyName `(` UniqueFormalParameters `)` `{` AsyncFunctionBody `}` + AsyncMethod : `async` ClassElementName `(` UniqueFormalParameters `)` `{` AsyncFunctionBody `}` - 1. Return the result of ComputedPropertyContains for |PropertyName| with argument _symbol_. + 1. Return the result of ComputedPropertyContains for |ClassElementName| with argument _symbol_. @@ -20805,7 +20985,7 @@

        Static Semantics: Contains

        Static Semantics: HasDirectSuper

        - AsyncMethod : `async` PropertyName `(` UniqueFormalParameters `)` `{` AsyncFunctionBody `}` + AsyncMethod : `async` ClassElementName `(` UniqueFormalParameters `)` `{` AsyncFunctionBody `}` 1. If |UniqueFormalParameters| Contains |SuperCall| is *true*, return *true*. @@ -20856,10 +21036,10 @@

        Static Semantics: IsFunctionDefinition

        Static Semantics: PropName

        - AsyncMethod : `async` PropertyName `(` UniqueFormalParameters `)` `{` AsyncFunctionBody `}` + AsyncMethod : `async` ClassElementName `(` UniqueFormalParameters `)` `{` AsyncFunctionBody `}` - 1. Return PropName of |PropertyName|. + 1. Return PropName of |ClassElementName|.
        @@ -20920,19 +21100,17 @@

        Runtime Semantics: EvaluateBody

        Runtime Semantics: PropertyDefinitionEvaluation

        With parameters _object_ and _enumerable_.

        - AsyncMethod : `async` PropertyName `(` UniqueFormalParameters `)` `{` AsyncFunctionBody `}` + AsyncMethod : `async` ClassElementName `(` UniqueFormalParameters `)` `{` AsyncFunctionBody `}` - 1. Let _propKey_ be the result of evaluating |PropertyName|. + 1. Let _propKey_ be the result of evaluating |ClassElementName|. 1. ReturnIfAbrupt(_propKey_). 1. Let _scope_ be the LexicalEnvironment of the running execution context. 1. Let _privateScope_ be the PrivateEnvironment of the running execution context. 1. Let _closure_ be ! AsyncFunctionCreate(~Method~, |UniqueFormalParameters|, |AsyncFunctionBody|, _scope_, _privateScope_). 1. Perform ! MakeMethod(_closure_, _object_). - 1. Perform ! SetFunctionName(_closure_, _propKey_). 1. Set _closure_.[[SourceText]] to the source text matched by |AsyncMethod|. - 1. Let _desc_ be the PropertyDescriptor { [[Value]]: _closure_, [[Writable]]: *true*, [[Enumerable]]: _enumerable_, [[Configurable]]: *true* }. - 1. Return ? DefinePropertyOrThrow(_object_, _propKey_, _desc_). + 1. Perform ? DefineOrdinaryMethod(_propKey_, _object_, _closure_, _enumerable_).