a6dd7f1c98
This patch adds: - VariableMode::kPrivateMethod - VariableMode::kPrivateSetterOnly - VariableMode::kPrivateGetterOnly - VariableMode::kPrivateGetterAndSetter And replace the previous RequiresBrandCheckFlag by inferring whether the brand check is required from these VariableModes. It is then possible to check duplicate non-complementary accessors in the parsers and throw early errors, and allow complementary accessors to be associated with the same private name variable. This patch also adds the following AssignType: - PRIVATE_METHOD - PRIVATE_GETTER_ONLY - PRIVATE_SETTER_ONLY - PRIVATE_GETTER_AND_SETTER corresponding to the new VariableModes so that it's possible to generate specialized code for different type of private accessor declarations. Design doc: https://docs.google.com/document/d/10W4begYfs7lmldSqBoQBBt_BKamgT8igqxF9u50RGrI/edit Bug: v8:8330 Change-Id: I0fb61b1be248630d1eadd74fb16d7d64a421f4c4 Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/1695204 Commit-Queue: Joyee Cheung <joyee@igalia.com> Reviewed-by: Ross McIlroy <rmcilroy@chromium.org> Cr-Commit-Position: refs/heads/master@{#62988}
37 lines
740 B
JavaScript
37 lines
740 B
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";
|
|
|
|
// Complementary private accessors.
|
|
{
|
|
class C {
|
|
get #a() { }
|
|
set #a(val) { }
|
|
}
|
|
|
|
new C;
|
|
}
|
|
|
|
// Nested private accessors.
|
|
{
|
|
class C {
|
|
a() { this.#a; }
|
|
get #a() {
|
|
class D { get #a() { } }
|
|
return new D;
|
|
}
|
|
}
|
|
new C().a();
|
|
}
|
|
|
|
// Duplicate private accessors.
|
|
// https://tc39.es/proposal-private-methods/#sec-static-semantics-early-errors
|
|
{
|
|
assertThrows('class C { get #a() {} get #a() {} }', SyntaxError);
|
|
assertThrows('class C { set #a(val) {} set #a(val) {} }', SyntaxError);
|
|
}
|