| 1 |
// Copyright (C) 2016 the V8 project authors. All rights reserved. |
| 2 |
// This code is governed by the BSD license found in the LICENSE file. |
| 3 |
/*--- |
| 4 |
esid: sec-super-keyword |
| 5 |
es6id: 12.3.5 |
| 6 |
description: Value of reference returned by SuperProperty |
| 7 |
info: | |
| 8 |
1. Let propertyKey be StringValue of IdentifierName. |
| 9 |
2. If the code matched by the syntactic production that is being evaluated is |
| 10 |
strict mode code, let strict be true, else let strict be false. |
| 11 |
3. Return ? MakeSuperPropertyReference(propertyKey, strict). |
| 12 |
|
| 13 |
12.3.5.3 Runtime Semantics: MakeSuperPropertyReference |
| 14 |
|
| 15 |
1. Let env be GetThisEnvironment( ). |
| 16 |
2. If env.HasSuperBinding() is false, throw a ReferenceError exception. |
| 17 |
3. Let actualThis be ? env.GetThisBinding(). |
| 18 |
4. Let baseValue be ? env.GetSuperBase(). |
| 19 |
5. Let bv be ? RequireObjectCoercible(baseValue). |
| 20 |
6. Return a value of type Reference that is a Super Reference whose base |
| 21 |
value component is bv, whose referenced name component is propertyKey, |
| 22 |
whose thisValue component is actualThis, and whose strict reference flag |
| 23 |
is strict. |
| 24 |
features: [class] |
| 25 |
---*/ |
| 26 |
|
| 27 |
var fromA, fromB; |
| 28 |
class A {} |
| 29 |
class B extends A {} |
| 30 |
class C extends B { |
| 31 |
method() { |
| 32 |
fromA = super.fromA; |
| 33 |
fromB = super.fromB; |
| 34 |
} |
| 35 |
} |
| 36 |
|
| 37 |
A.prototype.fromA = 'a'; |
| 38 |
A.prototype.fromB = 'a'; |
| 39 |
B.prototype.fromB = 'b'; |
| 40 |
C.prototype.fromA = 'c'; |
| 41 |
C.prototype.fromB = 'c'; |
| 42 |
|
| 43 |
C.prototype.method(); |
| 44 |
|
| 45 |
assert.sameValue(fromA, 'a'); |
| 46 |
assert.sameValue(fromB, 'b'); |