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

Unified Diff: runtime/vm/parser.cc

Issue 2085003002: Parse field initializer expressions in the correct scope class (Closed) Base URL: git@github.com:dart-lang/sdk.git@master
Patch Set: Created 4 years, 6 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 | « no previous file | tests/language/language_dart2js.status » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: runtime/vm/parser.cc
diff --git a/runtime/vm/parser.cc b/runtime/vm/parser.cc
index 5c1bc446c6f8d008038b7e68547ce0bc79df2ade..46196029d1a70e4fa6ea925a2f6639f9813bda13 100644
--- a/runtime/vm/parser.cc
+++ b/runtime/vm/parser.cc
@@ -2648,17 +2648,18 @@ void Parser::CheckFieldsInitialized(const Class& cls) {
AstNode* Parser::ParseExternalInitializedField(const Field& field) {
// Only use this function if the initialized field originates
- // from a different class. We need to save and restore current
- // class, library, and token stream (script).
+ // from a different class. We need to save and restore the
+ // library and token stream (script).
+ // The current_class remains unchanged, so that type arguments
+ // are resolved in the correct scope class.
ASSERT(current_class().raw() != field.Origin());
- const Class& saved_class = Class::Handle(Z, current_class().raw());
const Library& saved_library = Library::Handle(Z, library().raw());
const Script& saved_script = Script::Handle(Z, script().raw());
const TokenPosition saved_token_pos = TokenPos();
- set_current_class(Class::Handle(Z, field.Origin()));
- set_library(Library::Handle(Z, current_class().library()));
- SetScript(Script::Handle(Z, current_class().script()), field.token_pos());
+ const Class& origin_class = Class::Handle(Z, field.Origin());
+ set_library(Library::Handle(Z, origin_class.library()));
+ SetScript(Script::Handle(Z, origin_class.script()), field.token_pos());
ASSERT(IsIdentifier());
ConsumeToken();
@@ -2678,7 +2679,6 @@ AstNode* Parser::ParseExternalInitializedField(const Field& field) {
init_expr = new(Z) LiteralNode(field.token_pos(), expr_value);
}
}
- set_current_class(saved_class);
set_library(saved_library);
SetScript(saved_script, saved_token_pos);
return init_expr;
« no previous file with comments | « no previous file | tests/language/language_dart2js.status » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698