Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(142)

Unified Diff: src/scopes.cc

Issue 1087543004: [strong] Allow mutually recursive classes. (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: . Created 5 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « src/parser.cc ('k') | src/variables.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/scopes.cc
diff --git a/src/scopes.cc b/src/scopes.cc
index b796452e00589b17b837a0eb6b5224885d9c389b..364f2f1cf7ce88ca08e207172c1cba1613dbb3f7 100644
--- a/src/scopes.cc
+++ b/src/scopes.cc
@@ -1138,6 +1138,30 @@ bool Scope::CheckStrongModeDeclaration(VariableProxy* proxy, Variable* var) {
scope = scope->outer_scope();
}
+ // Allow references from methods to classes declared later, if we detect no
+ // problematic dependency cycles.
+
+ if (ClassVariableForMethod() && var->is_class()) {
+ // A method is referring to some other class, possibly declared
+ // later. Referring to a class declared earlier is always OK and covered by
+ // the code outside this if. Here we only need to allow special cases for
+ // referring to a class which is declared later.
+
+ // Referring to a class C declared later is OK under the following
+ // circumstances:
+
+ // 1. The class declarations are in a consecutive group with no other
+ // declarations or statements in between, and
+
+ // 2. There is no dependency cycle where the first edge is an initialization
+ // time dependency (computed property name or extends clause) from C to
+ // something that depends on this class directly or transitively.
+
+ // TODO(marja,rossberg): implement these checks. Here we undershoot the
+ // target and allow referring to any class.
+ return true;
+ }
+
// If both the use and the declaration are inside an eval scope (possibly
// indirectly), or one of them is, we need to check whether they are inside
// the same eval scope or different ones.
« no previous file with comments | « src/parser.cc ('k') | src/variables.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698