static-private-getter-access-on-inner-class.js (1262B)
1 // This file was procedurally generated from the following sources: 2 // - src/class-elements/static-private-getter-access-on-inner-class.case 3 // - src/class-elements/default/cls-decl.template 4 /*--- 5 description: static private getter access inside of an inner class (field definitions in a class declaration) 6 esid: prod-FieldDefinition 7 features: [class-static-methods-private, class-static-fields-public, class] 8 flags: [generated] 9 info: | 10 PrivateFieldGet (P, O) 11 1. Assert: P is a Private Name. 12 2. If O is not an object, throw a TypeError exception. 13 3. If P.[[Kind]] is "field", 14 ... 15 4. Perform ? PrivateBrandCheck(O, P). 16 5. If P.[[Kind]] is "method", 17 a. Return P.[[Value]]. 18 ... 19 20 PrivateBrandCheck(O, P) 21 1. If O.[[PrivateBrands]] does not contain an entry e such that SameValue(e, P.[[Brand]]) is true, 22 a. Throw a TypeError exception. 23 24 ---*/ 25 26 27 class C { 28 static get #f() { 29 return 'Test262'; 30 } 31 32 static Inner = class { 33 static access(o) { 34 return o.#f; 35 } 36 } 37 } 38 39 assert.sameValue(C.Inner.access(C), 'Test262'); 40 assert.throws(TypeError, function() { 41 C.Inner.access(C.Inner); 42 }, 'Accessed static private getter from an object which did not contain it'); 43 44 reportCompare(0, 0);