Commit 9ace845f authored by Joyee Cheung's avatar Joyee Cheung Committed by Commit Bot

[ast] simplify ClassScope::ResolvePrivateNamesPartially

Previously when an unresolved private name is not found
in the current scope but found in an outer class scope,
we forget to push it to the outer class scope so the
name would never get bound.

This patch simplifies ClassScope::ResolvePrivateNamesPartially()
and removes the search in outer class scopes since they are incomplete
at this point. Instead just push any private name that can't be
resolved in the current scope to the outer class scope so that it
gets handled later when the outer class scope is complete.

Bug: chromium:952722
Change-Id: Ia0dda74cac57a0a1e25a9a09575f55633c6093b5
Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/1567709Reviewed-by: 's avatarToon Verwaest <verwaest@chromium.org>
Commit-Queue: Joyee Cheung <joyee@igalia.com>
Cr-Commit-Position: refs/heads/master@{#60863}
parent 1ab717db
...@@ -2492,29 +2492,19 @@ VariableProxy* ClassScope::ResolvePrivateNamesPartially() { ...@@ -2492,29 +2492,19 @@ VariableProxy* ClassScope::ResolvePrivateNamesPartially() {
} }
// If the current scope does not have declared private names, // If the current scope does not have declared private names,
// start looking from the outer class scope. // try looking from the outer class scope later.
if (var == nullptr && outer_class_scope != nullptr) { if (var == nullptr) {
var = outer_class_scope->LookupPrivateName(proxy); // There's no outer class scope so we are certain that the variable
} // cannot be resolved later.
if (outer_class_scope == nullptr) {
// The outer class scopes are incomplete at this point, so even if return proxy;
// we have found it in any of the outer class scopes, we still delay }
// the resolution until this method is called for outer scopes
// when they are complete.
if (var != nullptr) {
proxy = next;
continue;
}
// There's no outer class scope so we are certain that the variable // The private name may be found later in the outer class scope,
// cannot be resolved later. // so push it to the outer sopce.
if (outer_class_scope == nullptr) { outer_class_scope->AddUnresolvedPrivateName(proxy);
return proxy;
} }
// The private name may still be found later in the outer class scope,
// so push it to the outer sopce.
outer_class_scope->AddUnresolvedPrivateName(proxy);
proxy = next; proxy = next;
} }
......
// 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: --no-lazy
class A {
static #a = 1;
static b = class {
static get_A() { return val.#a; }
}
}
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