summaryrefslogtreecommitdiffstats
path: root/js/src/tests/test262/language/statements/class/elements/super-access-inside-a-private-method.js
blob: df4478828f2c3b69bc9abd126304d5224a6f73fb (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 method contains proper HomeObject
esid: sec-method-definitions-runtime-semantics-classelementevaluation
info: |
  MethodDefinition : ClassElementName ( UniqueFormalParameters ) { FunctionBody }
    1. Let methodDef be DefineMethod of MethodDefinition with argument homeObject.
    2. ReturnIfAbrupt(methodDef).
    3. Perform ? DefineOrdinaryMethod(methodDef.[[Key]], homeObject, methodDef.[[Closure]], _enumerable).

  MethodDefinition : PropertyName ( UniqueFormalParameters ) { FunctionBody }
    1. Let propKey be the result of evaluating PropertyName.
    2. ReturnIfAbrupt(propKey).
    3. Let scope be the running execution context's LexicalEnvironment.
    4. If functionPrototype is present as a parameter, then
      a. Let kind be Normal.
      b. Let prototype be functionPrototype.
    5. Else,
      a. Let kind be Method.
      b. Let prototype be the intrinsic object %FunctionPrototype%.
    6. Let closure be FunctionCreate(kind, UniqueFormalParameters, FunctionBody, scope, prototype).
    7. Perform MakeMethod(closure, object).
    8. Set closure.[[SourceText]] to the source text matched by MethodDefinition.
    9. Return the Record { [[Key]]: propKey, [[Closure]]: closure }.
features: [class-methods-private, class]
---*/

class A {
  method() {
    return "Test262";
  }
}

class C extends A {
  #m() {
    return super.method();
  }

  access(o) {
    return this.#m.call(o);
  }
}

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

let o = {};
assert.sameValue(c.access(o), "Test262");

reportCompare(0, 0);