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

Unified Diff: test/type_parser.dart

Issue 2502343002: Store named parameters in sorted lists instead of using maps. (Closed)
Patch Set: Remove duplicates from named parameter lists to recover from erroneous inputs Created 4 years, 1 month 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 | « lib/visitor.dart ('k') | testcases/input/named_parameters.dart » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: test/type_parser.dart
diff --git a/test/type_parser.dart b/test/type_parser.dart
index 0dc1875bcd22ceb22c643c026ec40f2f0725d7e8..e933c16af72df9282889e9b83eea065de79a11dc 100644
--- a/test/type_parser.dart
+++ b/test/type_parser.dart
@@ -151,7 +151,7 @@ class DartTypeParser {
case Token.LeftParen:
List<DartType> parameters = <DartType>[];
- Map<String, DartType> namedParameters = <String, DartType>{};
+ List<NamedType> namedParameters = <NamedType>[];
parseParameterList(parameters, namedParameters);
consumeString('=>');
var returnType = parseType();
@@ -161,7 +161,7 @@ class DartTypeParser {
case Token.LeftAngle:
var typeParameters = parseAndPushTypeParameterList();
List<DartType> parameters = <DartType>[];
- Map<String, DartType> namedParameters = <String, DartType>{};
+ List<NamedType> namedParameters = <NamedType>[];
parseParameterList(parameters, namedParameters);
consumeString('=>');
var returnType = parseType();
@@ -175,7 +175,7 @@ class DartTypeParser {
}
void parseParameterList(
- List<DartType> positional, Map<String, DartType> named) {
+ List<DartType> positional, List<NamedType> named) {
int token = scanToken();
assert(token == Token.LeftParen);
token = peekToken();
@@ -184,7 +184,7 @@ class DartTypeParser {
token = scanToken();
if (token == Token.Colon) {
String name = convertTypeToParameterName(type);
- named[name] = parseType();
+ named.add(new NamedType(name, parseType()));
token = scanToken();
} else {
positional.add(type);
@@ -193,6 +193,7 @@ class DartTypeParser {
return fail('Unterminated parameter list');
}
}
+ named.sort();
}
String convertTypeToParameterName(DartType type) {
« no previous file with comments | « lib/visitor.dart ('k') | testcases/input/named_parameters.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698