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

Unified Diff: runtime/vm/parser.cc

Issue 1269783004: Fix constructor closures in checked mode (Closed) Base URL: https://github.com/dart-lang/sdk.git@master
Patch Set: Created 5 years, 4 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 | no next file » | 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 066494a69c6884c6976480714ad6aafd3bce4b22..f357e7851ec17844f18079355d37c828b3010744 100644
--- a/runtime/vm/parser.cc
+++ b/runtime/vm/parser.cc
@@ -557,6 +557,13 @@ struct ParamList {
AddFinalParameter(token_pos, &Symbols::This(), receiver_type);
}
+ void EraseParameterTypes() {
+ const Type& dynamic_type = Type::ZoneHandle(Type::DynamicType());
+ const int num_parameters = parameters->length();
+ for (int i = 0; i < num_parameters; i++) {
+ (*parameters)[i].type = &dynamic_type;
+ }
+ }
// Make the parameter variables visible/invisible.
// Field initializer parameters are always invisible.
@@ -1342,6 +1349,9 @@ SequenceNode* Parser::ParseConstructorClosure(const Function& func,
bool params_ok = ParseFormalParameters(constructor, &params);
USE(params_ok);
ASSERT(params_ok);
+ // Per language spec, the type of the closure parameters is dynamic.
+ // Replace the types parsed from the constructor.
+ params.EraseParameterTypes();
SetupDefaultsForOptionalParams(&params, default_values);
ASSERT(func.num_fixed_parameters() == params.num_fixed_parameters);
@@ -12864,6 +12874,10 @@ RawFunction* Parser::BuildConstructorClosureFunction(const Function& ctr,
&Type::ZoneHandle(Z, Type::DynamicType()));
ParseFormalParameters(ctr, &params);
+ // Per language spec, the type of the closure parameters is dynamic.
+ // Replace the types parsed from the constructor.
+ params.EraseParameterTypes();
+
Function& closure = Function::Handle(Z);
closure = Function::NewClosureFunction(closure_name,
innermost_function(),
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698