summaryrefslogtreecommitdiffstats
path: root/js/src/tests/test262/language/statements/class/elements/super-access-inside-a-private-setter.js
blob: 3a95d15c89926d2bea401c6d72d3ed3895f64e07 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
// Copyright (C) 2019 Caio Lima (Igalia SL). All rights reserved.
// This code is governed by the BSD license found in the LICENSE file.

/*---
description: Private setter contains proper HomeObject
esid: sec-method-definitions-runtime-semantics-classelementevaluation
info: |
  MethodDefinition : set ClassElementName ( PropertySetParameterList ) { FunctionBody }
    1. Let key be the result of evaluating ClassElementName.
    2. ReturnIfAbrupt(key).
    3. If the function code for this MethodDefinition is strict mode code, let strict be true. Otherwise let strict be false.
    4. Let scope be the running execution context's LexicalEnvironment.
    5. Let closure be FunctionCreate(Method, PropertySetParameterList, FunctionBody, scope, strict).
    6. Perform MakeMethod(closure, homeObject).
    7. Perform SetFunctionName(closure, key, "set").
    8. If key is a Private Name,
      a. If key has a [[Kind]] field,
        i. Assert: key.[[Kind]] is "accessor".
        ii. Assert: key.[[Brand]] is homeObject.
        iii. Assert: key does not have a [[Set]] field.
        iv. Set key.[[Set]] to closure.
      b. Otherwise,
        i. Set key.[[Kind]] to "accessor".
        ii. Set key.[[Brand]] to homeObject.
        iii. Set key.[[Set]] to closure.
    9. Else,
      a. Let desc be the PropertyDescriptor{[[Set]]: closure, [[Enumerable]]: enumerable, [[Configurable]]: true}.
      b. Perform ? DefinePropertyOrThrow(homeObject, key, desc).
features: [class-methods-private, class]
---*/

class A {
  method(v) {
    return v;
  }
}

class C extends A {
  set #m(v) {
    this._v = super.method(v);
  }

  access() {
    return this.#m = "Test262";
  }
}

let c = new C();
c.access();
assert.sameValue(c._v, "Test262");

reportCompare(0, 0);