Fix a null safety migration bug in update_errors.dart.

It was assigning a List<String> to List<String?> which is allowed due
to (unsound) covariance but would then fail at runtime when null was
assigned to a list element.

Change-Id: Ia893998e8866067b54cfa354b9c4e13d76b6d9ea
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/253303
Auto-Submit: Bob Nystrom <rnystrom@google.com>
Commit-Queue: Bob Nystrom <rnystrom@google.com>
Reviewed-by: Srujan Gaddam <srujzs@google.com>
Commit-Queue: Srujan Gaddam <srujzs@google.com>
This commit is contained in:
Robert Nystrom 2022-08-02 01:43:14 +00:00 committed by Commit Bot
parent d50903739c
commit 6a8c81205a
2 changed files with 3 additions and 3 deletions

View file

@ -29,7 +29,7 @@ String updateErrorExpectations(String source, List<StaticError> errors,
}
}
List<String?> lines = source.split("\n");
var lines = List<String?>.of(source.split("\n"));
// Keep track of the indentation on any existing expectation markers. If
// found, it will try to preserve that indentation.
@ -116,7 +116,7 @@ String updateErrorExpectations(String source, List<StaticError> errors,
error.length != previousLength)) {
// If the error can't fit in a line comment, or no source location is
// specified, use an explicit location.
if (error.column <= 2 || error.length == 0) {
if (error.column <= 2) {
if (error.length == 0) {
result.add("$comment [error column "
"${error.column}]");

View file

@ -400,7 +400,7 @@ x
makeError(line: 1, column: 1, length: 0, cfeError: "Foo"),
], expected: """
x
// [error column 1, length 0]
// [error column 1]
// [cfe] Foo""");
contextMessages();