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

Unified Diff: runtime/vm/parser.cc

Issue 45833002: Disallow explicit parameter default values in redirecting factory (issue 13662). (Closed) Base URL: http://dart.googlecode.com/svn/branches/bleeding_edge/dart/
Patch Set: Created 7 years, 2 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 | sdk/lib/async/zone.dart » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: runtime/vm/parser.cc
===================================================================
--- runtime/vm/parser.cc (revision 29297)
+++ runtime/vm/parser.cc (working copy)
@@ -444,6 +444,7 @@
num_optional_parameters = 0;
has_optional_positional_parameters = false;
has_optional_named_parameters = false;
+ has_explicit_default_values = false;
has_field_initializer = false;
implicitly_final = false;
skipped = false;
@@ -489,6 +490,7 @@
int num_optional_parameters;
bool has_optional_positional_parameters;
bool has_optional_named_parameters;
+ bool has_explicit_default_values;
bool has_field_initializer;
bool implicitly_final;
bool skipped;
@@ -1478,6 +1480,7 @@
ExpectToken(Token::kCOLON);
}
params->num_optional_parameters++;
+ params->has_explicit_default_values = true; // Also if explicitly NULL.
if (is_top_level_) {
// Skip default value parsing.
SkipExpr();
@@ -3023,6 +3026,12 @@
String& redirection_identifier = String::Handle();
bool is_redirecting = false;
if (method->IsFactory() && (CurrentToken() == Token::kASSIGN)) {
+ // Default parameter values are disallowed in redirecting factories.
+ if (method->params.has_explicit_default_values) {
+ ErrorMsg("redirecting factory '%s' may not specify default values "
+ "for optional parameters",
+ method->name->ToCString());
+ }
ConsumeToken();
const intptr_t type_pos = TokenPos();
is_redirecting = true;
« no previous file with comments | « no previous file | sdk/lib/async/zone.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698