From 6a8c81205a724f9ca5d181f1891216a943418335 Mon Sep 17 00:00:00 2001 From: Robert Nystrom Date: Tue, 2 Aug 2022 01:43:14 +0000 Subject: [PATCH] Fix a null safety migration bug in update_errors.dart. It was assigning a List to List 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 Commit-Queue: Bob Nystrom Reviewed-by: Srujan Gaddam Commit-Queue: Srujan Gaddam --- pkg/test_runner/lib/src/update_errors.dart | 4 ++-- pkg/test_runner/test/update_errors_test.dart | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/pkg/test_runner/lib/src/update_errors.dart b/pkg/test_runner/lib/src/update_errors.dart index d0640dfa0a3..cb30f048ced 100644 --- a/pkg/test_runner/lib/src/update_errors.dart +++ b/pkg/test_runner/lib/src/update_errors.dart @@ -29,7 +29,7 @@ String updateErrorExpectations(String source, List errors, } } - List lines = source.split("\n"); + var lines = List.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 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}]"); diff --git a/pkg/test_runner/test/update_errors_test.dart b/pkg/test_runner/test/update_errors_test.dart index 612e69f053e..cf7cb8b58ad 100644 --- a/pkg/test_runner/test/update_errors_test.dart +++ b/pkg/test_runner/test/update_errors_test.dart @@ -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();