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

Side by Side Diff: pkg/analyzer/lib/src/generated/error_verifier.dart

Issue 1590533003: fix a nondeterministic error messsage by sorting the field names (Closed) Base URL: git@github.com:dart-lang/sdk.git@master
Patch Set: Created 4 years, 11 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 unified diff | Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2014, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2014, 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 4
5 library analyzer.src.generated.error_verifier; 5 library analyzer.src.generated.error_verifier;
6 6
7 import 'dart:collection'; 7 import 'dart:collection';
8 import "dart:math" as math; 8 import "dart:math" as math;
9 9
10 import 'package:analyzer/dart/element/element.dart'; 10 import 'package:analyzer/dart/element/element.dart';
(...skipping 1270 matching lines...) Expand 10 before | Expand all | Expand 10 after
1281 CompileTimeErrorCode.CONST_NOT_INITIALIZED, 1281 CompileTimeErrorCode.CONST_NOT_INITIALIZED,
1282 constructor.returnType, 1282 constructor.returnType,
1283 [fieldElement.name]); 1283 [fieldElement.name]);
1284 foundError = true; 1284 foundError = true;
1285 } 1285 }
1286 } 1286 }
1287 }); 1287 });
1288 if (notInitFinalFields.isNotEmpty) { 1288 if (notInitFinalFields.isNotEmpty) {
1289 foundError = true; 1289 foundError = true;
1290 AnalysisErrorWithProperties analysisError; 1290 AnalysisErrorWithProperties analysisError;
1291 if (notInitFinalFields.length == 1) { 1291 var names = notInitFinalFields.map((item) => item.name).toList();
Brian Wilkerson 2016/01/15 15:26:04 In non-test code, we type annotate everything.
skybrian 2016/01/15 22:48:06 Done.
1292 names.sort();
1293 if (names.length == 1) {
1292 analysisError = _errorReporter.newErrorWithProperties( 1294 analysisError = _errorReporter.newErrorWithProperties(
1293 StaticWarningCode.FINAL_NOT_INITIALIZED_CONSTRUCTOR_1, 1295 StaticWarningCode.FINAL_NOT_INITIALIZED_CONSTRUCTOR_1,
1294 constructor.returnType, 1296 constructor.returnType,
1295 [notInitFinalFields[0].name]); 1297 names);
1296 } else if (notInitFinalFields.length == 2) { 1298 } else if (notInitFinalFields.length == 2) {
skybrian 2016/01/15 22:48:06 changed to names.length
1297 analysisError = _errorReporter.newErrorWithProperties( 1299 analysisError = _errorReporter.newErrorWithProperties(
1298 StaticWarningCode.FINAL_NOT_INITIALIZED_CONSTRUCTOR_2, 1300 StaticWarningCode.FINAL_NOT_INITIALIZED_CONSTRUCTOR_2,
1299 constructor.returnType, 1301 constructor.returnType,
1300 [notInitFinalFields[0].name, notInitFinalFields[1].name]); 1302 names);
1301 } else { 1303 } else {
1302 analysisError = _errorReporter.newErrorWithProperties( 1304 analysisError = _errorReporter.newErrorWithProperties(
1303 StaticWarningCode.FINAL_NOT_INITIALIZED_CONSTRUCTOR_3_PLUS, 1305 StaticWarningCode.FINAL_NOT_INITIALIZED_CONSTRUCTOR_3_PLUS,
1304 constructor.returnType, [ 1306 constructor.returnType,
1305 notInitFinalFields[0].name, 1307 [names[0], names[1], names.length - 2]);
1306 notInitFinalFields[1].name,
1307 notInitFinalFields.length - 2
1308 ]);
1309 } 1308 }
1310 analysisError.setProperty( 1309 analysisError.setProperty(
1311 ErrorProperty.NOT_INITIALIZED_FIELDS, notInitFinalFields); 1310 ErrorProperty.NOT_INITIALIZED_FIELDS, notInitFinalFields);
1312 _errorReporter.reportError(analysisError); 1311 _errorReporter.reportError(analysisError);
1313 } 1312 }
1314 return foundError; 1313 return foundError;
1315 } 1314 }
1316 1315
1317 /** 1316 /**
1318 * Check the given [executableElement] against override-error codes. The 1317 * Check the given [executableElement] against override-error codes. The
(...skipping 4885 matching lines...) Expand 10 before | Expand all | Expand 10 after
6204 toCheck.add(type.element); 6203 toCheck.add(type.element);
6205 // type arguments 6204 // type arguments
6206 if (type is InterfaceType) { 6205 if (type is InterfaceType) {
6207 InterfaceType interfaceType = type; 6206 InterfaceType interfaceType = type;
6208 for (DartType typeArgument in interfaceType.typeArguments) { 6207 for (DartType typeArgument in interfaceType.typeArguments) {
6209 _addTypeToCheck(typeArgument); 6208 _addTypeToCheck(typeArgument);
6210 } 6209 }
6211 } 6210 }
6212 } 6211 }
6213 } 6212 }
OLDNEW
« 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