Commit 2685658c authored by Shu-yu Guo's avatar Shu-yu Guo Committed by Commit Bot

[class] Fix parenthesized calls of optional chains containing private fields

Bug: v8:10552
Change-Id: I1160ff0f9d2c91bb3c2ad3e0d5e1f36953538420
Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/2211402Reviewed-by: 's avatarLeszek Swirski <leszeks@chromium.org>
Commit-Queue: Shu-yu Guo <syg@chromium.org>
Cr-Commit-Position: refs/heads/master@{#67959}
parent 843a1f45
......@@ -927,6 +927,7 @@ Call::CallType Call::GetCallType() const {
}
if (property != nullptr) {
if (property->IsPrivateReference()) {
if (is_optional_chain) return PRIVATE_OPTIONAL_CHAIN_CALL;
return PRIVATE_CALL;
}
bool is_super = property->IsSuperAccess();
......
......@@ -1630,6 +1630,7 @@ class Call final : public Expression {
NAMED_SUPER_PROPERTY_CALL,
KEYED_SUPER_PROPERTY_CALL,
PRIVATE_CALL,
PRIVATE_OPTIONAL_CHAIN_CALL,
SUPER_CALL,
OTHER_CALL,
};
......
......@@ -4886,7 +4886,8 @@ void BytecodeGenerator::VisitCall(Call* expr) {
break;
}
case Call::NAMED_OPTIONAL_CHAIN_PROPERTY_CALL:
case Call::KEYED_OPTIONAL_CHAIN_PROPERTY_CALL: {
case Call::KEYED_OPTIONAL_CHAIN_PROPERTY_CALL:
case Call::PRIVATE_OPTIONAL_CHAIN_CALL: {
OptionalChain* chain = callee_expr->AsOptionalChain();
Property* property = chain->expression()->AsProperty();
BuildOptionalChain([&]() {
......
// Copyright 2020 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.
class C {
static #c = C;
static #m() { return this; }
static test(C) {
assertEquals(C?.#m(), C);
assertEquals((C?.#m)(), C);
assertEquals(C?.#c?.#m(), C);
assertEquals((C?.#c?.#m)(), C);
}
}
C.test(C);
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment