Chromium Code Reviews| Index: runtime/vm/parser.cc |
| =================================================================== |
| --- runtime/vm/parser.cc (revision 29294) |
| +++ 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 a default value " |
|
hausner
2013/10/25 22:26:38
Should this message use plural, like: may not spec
regis
2013/10/25 22:54:42
The spec uses singular, but I changed it to plural
|
| + "for an optional parameter", |
| + method->name->ToCString()); |
| + } |
| ConsumeToken(); |
| const intptr_t type_pos = TokenPos(); |
| is_redirecting = true; |