diff options
author | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-07 19:33:14 +0000 |
---|---|---|
committer | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-07 19:33:14 +0000 |
commit | 36d22d82aa202bb199967e9512281e9a53db42c9 (patch) | |
tree | 105e8c98ddea1c1e4784a60a5a6410fa416be2de /js/src/tests/test262/language/statements/class/elements/private-static-field-shadowed-by-getter-on-nested-class.js | |
parent | Initial commit. (diff) | |
download | firefox-esr-36d22d82aa202bb199967e9512281e9a53db42c9.tar.xz firefox-esr-36d22d82aa202bb199967e9512281e9a53db42c9.zip |
Adding upstream version 115.7.0esr.upstream/115.7.0esrupstream
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'js/src/tests/test262/language/statements/class/elements/private-static-field-shadowed-by-getter-on-nested-class.js')
-rw-r--r-- | js/src/tests/test262/language/statements/class/elements/private-static-field-shadowed-by-getter-on-nested-class.js | 92 |
1 files changed, 92 insertions, 0 deletions
diff --git a/js/src/tests/test262/language/statements/class/elements/private-static-field-shadowed-by-getter-on-nested-class.js b/js/src/tests/test262/language/statements/class/elements/private-static-field-shadowed-by-getter-on-nested-class.js new file mode 100644 index 0000000000..7e62f99a8f --- /dev/null +++ b/js/src/tests/test262/language/statements/class/elements/private-static-field-shadowed-by-getter-on-nested-class.js @@ -0,0 +1,92 @@ +// This file was procedurally generated from the following sources: +// - src/class-elements/private-static-field-shadowed-by-getter-on-nested-class.case +// - src/class-elements/default/cls-decl.template +/*--- +description: PrivateName of private static field can be shadowed on inner classes by a private getter (field definitions in a class declaration) +esid: prod-FieldDefinition +features: [class-static-fields-private, class-static-fields-public, class-methods-private, class] +flags: [generated] +info: | + Updated Productions + + CallExpression[Yield, Await]: + CoverCallExpressionAndAsyncArrowHead[?Yield, ?Await] + SuperCall[?Yield, ?Await] + CallExpression[?Yield, ?Await]Arguments[?Yield, ?Await] + CallExpression[?Yield, ?Await][Expression[+In, ?Yield, ?Await]] + CallExpression[?Yield, ?Await].IdentifierName + CallExpression[?Yield, ?Await]TemplateLiteral[?Yield, ?Await] + CallExpression[?Yield, ?Await].PrivateIdentifier + + ClassTail : ClassHeritage { ClassBody } + ... + 6. Let classPrivateEnvironment be NewDeclarativeEnvironment(outerPrivateEnvironment). + 7. Let classPrivateEnvRec be classPrivateEnvironment's EnvironmentRecord. + ... + 15. Set the running execution context's LexicalEnvironment to classScope. + 16. Set the running execution context's PrivateEnvironment to classPrivateEnvironment. + ... + 33. If PrivateBoundIdentifiers of ClassBody contains a Private Name P such that P's [[Kind]] field is either "method" or "accessor" and P's [[Brand]] is F, + a. PrivateBrandAdd(F, F). + 34. For each item fieldRecord in order from staticFields, + a. Perform ? DefineField(F, field). + + FieldDefinition : ClassElementName Initializer_opt + 1. Let name be the result of evaluating ClassElementName. + 2. ReturnIfAbrupt(name). + 3. If Initializer_opt is present, + a. Let lex be the Lexical Environment of the running execution context. + b. Let formalParameterList be an instance of the production FormalParameters : [empty]. + c. Let privateScope be the PrivateEnvironment of the running execution context. + d. Let initializer be FunctionCreate(Method, formalParameterList, Initializer, lex, true, privateScope). + e. Perform MakeMethod(initializer, homeObject). + f. Let isAnonymousFunctionDefinition be IsAnonymousFunctionDefinition(Initializer). + 4. Else, + a. Let initializer be empty. + b. Let isAnonymousFunctionDeclaration be false. + 5. Return a Record { [[Name]]: name, [[Initializer]]: initializer, [[IsAnonymousFunctionDefinition]]: isAnonymousFunctionDefinition }. + + MemberExpression : MemberExpression.PrivateIdentifier + 1. Let baseReference be the result of evaluating MemberExpression. + 2. Let baseValue be ? GetValue(baseReference). + 3. Let bv be ? RequireObjectCoercible(baseValue). + 4. Let fieldNameString be the StringValue of PrivateIdentifier. + 5. Return MakePrivateReference(bv, fieldNameString). + + MakePrivateReference(baseValue, privateIdentifier) + 1. Let env be the running execution context's PrivateEnvironment. + 2. Let privateNameBinding be ? ResolveBinding(privateIdentifier, env). + 3. Let privateName be GetValue(privateNameBinding). + 4. Assert: privateName is a Private Name. + 5. Return a value of type Reference whose base value is baseValue, whose referenced name is privateName, whose strict reference flag is true. + +---*/ + + +class C { + static #m = 'outer class'; + + static fieldAccess() { + return this.#m; + } + + static B = class { + get #m() { return 'inner class'; } + + static access(o) { + return o.#m; + } + } +} + +assert.sameValue(C.fieldAccess(), 'outer class'); + +let b = new C.B(); + +assert.sameValue(C.B.access(b), 'inner class'); + +assert.throws(TypeError, function() { + C.B.access(C); +}, 'accessed private getter from an arbritary object'); + +reportCompare(0, 0); |