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

Side by Side Diff: lib/type_environment.dart

Issue 2502343002: Store named parameters in sorted lists instead of using maps. (Closed)
Patch Set: Add testcase 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 unified diff | Download patch
OLDNEW
1 // Copyright (c) 2016, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2016, the Dart project authors. Please see the AUTHORS file
2 // for details. All rights reserved. Use of this source code is governed by a 2 // for details. All rights reserved. Use of this source code is governed by a
3 // BSD-style license that can be found in the LICENSE file. 3 // BSD-style license that can be found in the LICENSE file.
4 library kernel.type_environment; 4 library kernel.type_environment;
5 5
6 import 'ast.dart'; 6 import 'ast.dart';
7 import 'class_hierarchy.dart'; 7 import 'class_hierarchy.dart';
8 import 'core_types.dart'; 8 import 'core_types.dart';
9 import 'type_algebra.dart'; 9 import 'type_algebra.dart';
10 10
(...skipping 188 matching lines...) Expand 10 before | Expand all | Expand 10 after
199 return false; 199 return false;
200 } 200 }
201 for (int i = 0; i < supertype.positionalParameters.length; ++i) { 201 for (int i = 0; i < supertype.positionalParameters.length; ++i) {
202 var supertypeParameter = supertype.positionalParameters[i]; 202 var supertypeParameter = supertype.positionalParameters[i];
203 var subtypeParameter = subtype.positionalParameters[i]; 203 var subtypeParameter = subtype.positionalParameters[i];
204 // Termination: Both types shrink in size. 204 // Termination: Both types shrink in size.
205 if (!isSubtypeOf(supertypeParameter, subtypeParameter)) { 205 if (!isSubtypeOf(supertypeParameter, subtypeParameter)) {
206 return false; 206 return false;
207 } 207 }
208 } 208 }
209 for (String name in supertype.namedParameters.keys) { 209 int subtypeNameIndex = 0;
210 var supertypeParameter = supertype.namedParameters[name]; 210 for (NamedType supertypeParameter in supertype.namedParameters) {
211 var subtypeParameter = subtype.namedParameters[name]; 211 while (subtypeNameIndex < subtype.namedParameters.length &&
212 if (subtypeParameter == null) return false; 212 subtype.namedParameters[subtypeNameIndex].name !=
213 supertypeParameter.name) {
214 ++subtypeNameIndex;
215 }
216 if (subtypeNameIndex == subtype.namedParameters.length) return false;
217 NamedType subtypeParameter = subtype.namedParameters[subtypeNameIndex];
213 // Termination: Both types shrink in size. 218 // Termination: Both types shrink in size.
214 if (!isSubtypeOf(supertypeParameter, subtypeParameter)) { 219 if (!isSubtypeOf(supertypeParameter.type, subtypeParameter.type)) {
215 return false; 220 return false;
216 } 221 }
217 } 222 }
218 return true; 223 return true;
219 } 224 }
220 } 225 }
OLDNEW
« lib/ast.dart ('K') | « lib/type_algebra.dart ('k') | lib/type_propagation/builder.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698