class-name-static-initializer-anonymous.js (713B)
1 // Copyright 2019 André Bargull. All rights reserved. 2 // This code is governed by the BSD license found in the LICENSE file. 3 4 /*--- 5 esid: sec-runtime-semantics-classdefinitionevaluation 6 description: > 7 The inferred class-name is present when executing static field initializers of anonymous class expressions. 8 info: | 9 14.6.13 Runtime Semantics: ClassDefinitionEvaluation 10 11 [...] 12 17. Perform MakeClassConstructor(F). 13 18. If className is not undefined, then 14 a. Perform SetFunctionName(F, className). 15 [...] 16 17 features: [class-static-fields-public] 18 ---*/ 19 20 var className; 21 22 var C = class { 23 static f = (className = this.name); 24 } 25 26 assert.sameValue(className, "C"); 27 28 reportCompare(0, 0);