private-method-double-initialisation-get.js (762B)
1 // Copyright (C) 2021 André Bargull. All rights reserved. 2 // This code is governed by the BSD license found in the LICENSE file. 3 4 /*--- 5 description: > 6 Throws TypeError when attempting to install private methods multiple times. 7 esid: sec-privatemethodoraccessoradd 8 info: | 9 7.3.28 PrivateMethodOrAccessorAdd ( method, O ) 10 1. Assert: method.[[Kind]] is either method or accessor. 11 2. Let entry be ! PrivateElementFind(method.[[Key]], O). 12 3. If entry is not empty, throw a TypeError exception. 13 ... 14 15 features: [class, class-methods-private] 16 ---*/ 17 18 class Base { 19 constructor(o) { 20 return o; 21 } 22 } 23 24 class C extends Base { 25 get #p() {} 26 } 27 28 var obj = {}; 29 30 new C(obj); 31 32 assert.throws(TypeError, function() { 33 new C(obj); 34 }); 35 36 reportCompare(0, 0);