private-field-presence-field-shadowed.js (902B)
1 // Copyright 2021 the V8 project authors. All rights reserved. 2 // This code is governed by the BSD license found in the LICENSE file. 3 4 /*--- 5 description: Value when private name describes a field 6 info: | 7 7. Let privateName be ? GetValue(privateNameBinding). 8 8. Assert: privateName is a Private Name. 9 9. If privateName.[[Kind]] is "field", 10 a. If ! PrivateFieldFind(privateName, rval) is not empty, then return true. 11 [...] 12 11. Return false. 13 esid: sec-relational-operators-runtime-semantics-evaluation 14 features: [class-fields-private, class-fields-private-in] 15 ---*/ 16 17 let Child; 18 19 class Parent { 20 #field; 21 22 static init() { 23 Child = class { 24 #field; 25 26 static isNameIn(value) { 27 return #field in value; 28 } 29 }; 30 } 31 } 32 33 Parent.init(); 34 35 assert.sameValue(Child.isNameIn(new Parent()), false); 36 assert.sameValue(Child.isNameIn(new Child()), true); 37 38 reportCompare(0, 0);