From 85a4484c52211a141f2475cca9441e878da3a8dc Mon Sep 17 00:00:00 2001 From: Rick Waldron Date: Thu, 24 May 2018 15:10:13 -0400 Subject: [PATCH] SuperProperty evaluation order super[super()] should evaluate and resolve super() first --- .../in-constructor-superproperty-evaluation.js | 16 ++++++++++++++++ .../statements/class/super/in-constructor.js | 4 ++-- .../language/statements/class/super/in-getter.js | 4 ++-- .../statements/class/super/in-methods.js | 4 ++-- .../language/statements/class/super/in-setter.js | 4 ++-- .../statements/class/super/in-static-getter.js | 4 ++-- .../statements/class/super/in-static-methods.js | 4 ++-- .../statements/class/super/in-static-setter.js | 4 ++-- 8 files changed, 30 insertions(+), 14 deletions(-) create mode 100644 test/language/statements/class/super/in-constructor-superproperty-evaluation.js diff --git a/test/language/statements/class/super/in-constructor-superproperty-evaluation.js b/test/language/statements/class/super/in-constructor-superproperty-evaluation.js new file mode 100644 index 0000000000..21f40a750a --- /dev/null +++ b/test/language/statements/class/super/in-constructor-superproperty-evaluation.js @@ -0,0 +1,16 @@ +// Copyright (C) 2018 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +esid: sec-makesuperpropertyreference +description: > + SuperProperty evaluation order: super() thisBinding initialization occurs first. +---*/ +class Derived extends Object { + constructor() { + super[super()]; + } +} + +var derived = new Derived(); +assert.sameValue(derived instanceof Derived, true); +assert.sameValue(derived instanceof Object, true); diff --git a/test/language/statements/class/super/in-constructor.js b/test/language/statements/class/super/in-constructor.js index 5601f1fec6..f22f47b3fa 100644 --- a/test/language/statements/class/super/in-constructor.js +++ b/test/language/statements/class/super/in-constructor.js @@ -1,7 +1,7 @@ // Copyright (C) 2014 the V8 project authors. All rights reserved. // This code is governed by the BSD license found in the LICENSE file. /*--- -es6id: 14.5 +esid: sec-makesuperpropertyreference description: > class super in constructor ---*/ @@ -18,4 +18,4 @@ class C extends B { } new C; -assert.sameValue(calls, 1, "The value of `calls` is `1`"); \ No newline at end of file +assert.sameValue(calls, 1, "The value of `calls` is `1`"); diff --git a/test/language/statements/class/super/in-getter.js b/test/language/statements/class/super/in-getter.js index 4a54cd5993..6e3a165b48 100644 --- a/test/language/statements/class/super/in-getter.js +++ b/test/language/statements/class/super/in-getter.js @@ -1,7 +1,7 @@ // Copyright (C) 2014 the V8 project authors. All rights reserved. // This code is governed by the BSD license found in the LICENSE file. /*--- -es6id: 14.5 +esid: sec-makesuperpropertyreference description: > class super in getter ---*/ @@ -19,4 +19,4 @@ class C extends B { return super.method(); } } -assert.sameValue(new C().y, 1, "The value of `new C().y` is `1`"); \ No newline at end of file +assert.sameValue(new C().y, 1, "The value of `new C().y` is `1`"); diff --git a/test/language/statements/class/super/in-methods.js b/test/language/statements/class/super/in-methods.js index fa7246bac8..54dd00fc2d 100644 --- a/test/language/statements/class/super/in-methods.js +++ b/test/language/statements/class/super/in-methods.js @@ -1,7 +1,7 @@ // Copyright (C) 2014 the V8 project authors. All rights reserved. // This code is governed by the BSD license found in the LICENSE file. /*--- -es6id: 14.5 +esid: sec-makesuperpropertyreference description: > class super in methods ---*/ @@ -19,4 +19,4 @@ class C extends B { return super.method(); } } -assert.sameValue(new C().method(), 1, "`new C().method()` returns `1`"); \ No newline at end of file +assert.sameValue(new C().method(), 1, "`new C().method()` returns `1`"); diff --git a/test/language/statements/class/super/in-setter.js b/test/language/statements/class/super/in-setter.js index 118900ec0d..a621c45471 100644 --- a/test/language/statements/class/super/in-setter.js +++ b/test/language/statements/class/super/in-setter.js @@ -1,7 +1,7 @@ // Copyright (C) 2014 the V8 project authors. All rights reserved. // This code is governed by the BSD license found in the LICENSE file. /*--- -es6id: 14.5 +esid: sec-makesuperpropertyreference description: > class super in setter ---*/ @@ -20,4 +20,4 @@ class C extends B { assert.sameValue(super.method(), 1, "`super.method()` returns `1`"); } } -assert.sameValue(new C().y = 3, 3, "`new C().y = 3` is `3`"); \ No newline at end of file +assert.sameValue(new C().y = 3, 3, "`new C().y = 3` is `3`"); diff --git a/test/language/statements/class/super/in-static-getter.js b/test/language/statements/class/super/in-static-getter.js index 33643fa8ee..05da99a9a3 100644 --- a/test/language/statements/class/super/in-static-getter.js +++ b/test/language/statements/class/super/in-static-getter.js @@ -1,7 +1,7 @@ // Copyright (C) 2014 the V8 project authors. All rights reserved. // This code is governed by the BSD license found in the LICENSE file. /*--- -es6id: 14.5 +esid: sec-makesuperpropertyreference description: > class super in static getter ---*/ @@ -19,4 +19,4 @@ class C extends B { return super.method(); } } -assert.sameValue(C.x, 1, "The value of `C.x` is `1`"); \ No newline at end of file +assert.sameValue(C.x, 1, "The value of `C.x` is `1`"); diff --git a/test/language/statements/class/super/in-static-methods.js b/test/language/statements/class/super/in-static-methods.js index 24d3ee146e..81b7d5992e 100644 --- a/test/language/statements/class/super/in-static-methods.js +++ b/test/language/statements/class/super/in-static-methods.js @@ -1,7 +1,7 @@ // Copyright (C) 2014 the V8 project authors. All rights reserved. // This code is governed by the BSD license found in the LICENSE file. /*--- -es6id: 14.5 +esid: sec-makesuperpropertyreference description: > class super in static methods ---*/ @@ -19,4 +19,4 @@ class C extends B { return super.method(); } } -assert.sameValue(C.method(), 1, "`C.method()` returns `1`"); \ No newline at end of file +assert.sameValue(C.method(), 1, "`C.method()` returns `1`"); diff --git a/test/language/statements/class/super/in-static-setter.js b/test/language/statements/class/super/in-static-setter.js index 91b3ad0367..1cbb933794 100644 --- a/test/language/statements/class/super/in-static-setter.js +++ b/test/language/statements/class/super/in-static-setter.js @@ -1,7 +1,7 @@ // Copyright (C) 2014 the V8 project authors. All rights reserved. // This code is governed by the BSD license found in the LICENSE file. /*--- -es6id: 14.5 +esid: sec-makesuperpropertyreference description: > class super in static setter ---*/ @@ -20,4 +20,4 @@ class C extends B { assert.sameValue(super.method(), 1, "`super.method()` returns `1`"); } } -assert.sameValue(C.x = 3, 3, "`C.x = 3` is `3`"); \ No newline at end of file +assert.sameValue(C.x = 3, 3, "`C.x = 3` is `3`");