fe6839ba6d
This patch uses a bit in the Variable bit fields to distinguish static private names from instance private names, so that we can check the conflicts of private accessors that are complementary but with different staticness in the parser, and use this information later when generating code for checking static brands for private method access. Design doc: https://docs.google.com/document/d/1rgGRw5RdzaRrM-GrIMhsn-DLULtADV2dmIdh_iIZxlc/edit Bug: v8:8330 Change-Id: I8d70600e594e3d07f77ea519751b7ca2e0de87b5 Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/1781010 Reviewed-by: Toon Verwaest <verwaest@chromium.org> Reviewed-by: Ross McIlroy <rmcilroy@chromium.org> Commit-Queue: Joyee Cheung <joyee@igalia.com> Cr-Commit-Position: refs/heads/master@{#63677}
45 lines
1.6 KiB
JavaScript
45 lines
1.6 KiB
JavaScript
// Copyright 2019 the V8 project authors. All rights reserved.
|
|
// Use of this source code is governed by a BSD-style license that can be
|
|
// found in the LICENSE file.
|
|
|
|
// Flags: --harmony-private-methods
|
|
|
|
"use strict";
|
|
|
|
// Static private methods
|
|
{
|
|
let store = 1;
|
|
class C {
|
|
static #a() { return store; }
|
|
}
|
|
}
|
|
|
|
// Complementary static private accessors.
|
|
{
|
|
let store = 1;
|
|
class C {
|
|
static get #a() { return store; }
|
|
static set #a(val) { store = val; }
|
|
}
|
|
}
|
|
|
|
// Duplicate static private accessors and methods.
|
|
{
|
|
assertThrows('class C { static get #a() {} static get #a() {} }', SyntaxError);
|
|
assertThrows('class C { static get #a() {} static #a() {} }', SyntaxError);
|
|
assertThrows('class C { static get #a() {} get #a() {} }', SyntaxError);
|
|
assertThrows('class C { static get #a() {} set #a(val) {} }', SyntaxError);
|
|
assertThrows('class C { static get #a() {} #a() {} }', SyntaxError);
|
|
|
|
assertThrows('class C { static set #a(val) {} static set #a(val) {} }', SyntaxError);
|
|
assertThrows('class C { static set #a(val) {} static #a() {} }', SyntaxError);
|
|
assertThrows('class C { static set #a(val) {} get #a() {} }', SyntaxError);
|
|
assertThrows('class C { static set #a(val) {} set #a(val) {} }', SyntaxError);
|
|
assertThrows('class C { static set #a(val) {} #a() {} }', SyntaxError);
|
|
|
|
assertThrows('class C { static #a() {} static #a() {} }', SyntaxError);
|
|
assertThrows('class C { static #a() {} #a(val) {} }', SyntaxError);
|
|
assertThrows('class C { static #a() {} set #a(val) {} }', SyntaxError);
|
|
assertThrows('class C { static #a() {} get #a() {} }', SyntaxError);
|
|
}
|