Update various packages based on diagnostics from strict_top_level_inference.
Change-Id: I032d10fd1956b62a9e45ceee9ca2b28c9863d1ce
Tested: diagnostic updates only change
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/401560
Commit-Queue: Devon Carew <devoncarew@google.com>
Reviewed-by: Nate Bosch <nbosch@google.com>
diff --git a/pkg/analysis_server/lib/src/legacy_analysis_server.dart b/pkg/analysis_server/lib/src/legacy_analysis_server.dart
index 5090e68..66b44f1 100644
--- a/pkg/analysis_server/lib/src/legacy_analysis_server.dart
+++ b/pkg/analysis_server/lib/src/legacy_analysis_server.dart
@@ -524,7 +524,7 @@
/// There was an error related to the socket from which requests are being
/// read.
- void error(argument) {}
+ void error(Object argument) {}
/// Return the cached analysis result for the file with the given [path].
/// If there is no cached result, return `null`.
diff --git a/pkg/analysis_server/lib/src/services/completion/postfix/postfix_completion.dart b/pkg/analysis_server/lib/src/services/completion/postfix/postfix_completion.dart
index 9d71e3a..2515696 100644
--- a/pkg/analysis_server/lib/src/services/completion/postfix/postfix_completion.dart
+++ b/pkg/analysis_server/lib/src/services/completion/postfix/postfix_completion.dart
@@ -306,9 +306,12 @@
return processor.findObjectExpression() != null;
}
- static bool _false(_) => false;
+ static bool _false(PostfixCompletionProcessor _) => false;
- static Future<PostfixCompletion?> _null(_, _) async => null;
+ static Future<PostfixCompletion?> _null(
+ PostfixCompletionProcessor _,
+ PostfixCompletionKind _,
+ ) async => null;
}
/// A description of a postfix completion.
diff --git a/pkg/analysis_server/lib/src/utilities/mocks.dart b/pkg/analysis_server/lib/src/utilities/mocks.dart
index 91fa553..0c47555 100644
--- a/pkg/analysis_server/lib/src/utilities/mocks.dart
+++ b/pkg/analysis_server/lib/src/utilities/mocks.dart
@@ -47,7 +47,7 @@
_closed = true;
}
- void expectMsgCount({responseCount = 0, notificationCount = 0}) {
+ void expectMsgCount({int responseCount = 0, int notificationCount = 0}) {
expect(responsesReceived, hasLength(responseCount));
expect(notificationsReceived, hasLength(notificationCount));
}
diff --git a/pkg/build_integration/lib/file_system/multi_root.dart b/pkg/build_integration/lib/file_system/multi_root.dart
index 7b8ad74..18c5a2e 100644
--- a/pkg/build_integration/lib/file_system/multi_root.dart
+++ b/pkg/build_integration/lib/file_system/multi_root.dart
@@ -36,7 +36,7 @@
final List<Uri> roots;
final FileSystem original;
- MultiRootFileSystem(this.markerScheme, List roots, this.original)
+ MultiRootFileSystem(this.markerScheme, List<Uri> roots, this.original)
: roots = roots.map(_normalize).toList();
@override
@@ -116,7 +116,6 @@
Future.error(FileSystemException(uri, 'File not found'));
}
-Uri _normalize(root) {
- Uri uri = root;
+Uri _normalize(Uri uri) {
return uri.path.endsWith('/') ? uri : uri.replace(path: '${uri.path}/');
}
diff --git a/pkg/build_integration/lib/file_system/single_root.dart b/pkg/build_integration/lib/file_system/single_root.dart
index d2067ad8..8c4da22 100644
--- a/pkg/build_integration/lib/file_system/single_root.dart
+++ b/pkg/build_integration/lib/file_system/single_root.dart
@@ -80,7 +80,6 @@
Future<String> readAsString() async => delegate.readAsString();
}
-_normalize(root) {
- Uri uri = root;
+Uri _normalize(Uri uri) {
return uri.path.endsWith('/') ? uri : uri.replace(path: '${uri.path}/');
}
diff --git a/pkg/dart2js_info/bin/src/library_size_split.dart b/pkg/dart2js_info/bin/src/library_size_split.dart
index 7a3f16c..e2faf6e 100644
--- a/pkg/dart2js_info/bin/src/library_size_split.dart
+++ b/pkg/dart2js_info/bin/src/library_size_split.dart
@@ -213,7 +213,7 @@
const _Divider() : super('', 0);
}
-String _pad(value, n, {bool right = false}) {
+String _pad(Object value, int n, {bool right = false}) {
final s = '$value';
if (s.length >= n) return s;
var pad = ' ' * (n - s.length);
diff --git a/pkg/dart2js_info/bin/src/live_code_size_analysis.dart b/pkg/dart2js_info/bin/src/live_code_size_analysis.dart
index 5a7a22b..4d917d7 100644
--- a/pkg/dart2js_info/bin/src/live_code_size_analysis.dart
+++ b/pkg/dart2js_info/bin/src/live_code_size_analysis.dart
@@ -75,7 +75,11 @@
}
}
-Future<void> _liveCodeAnalysis(infoFile, coverageFile, bool verbose) async {
+Future<void> _liveCodeAnalysis(
+ String infoFile,
+ String coverageFile,
+ bool verbose,
+) async {
var info = await infoFromFile(infoFile);
var coverage = jsonDecode(File(coverageFile).readAsStringSync());
diff --git a/pkg/dart2js_info/bin/tools.dart b/pkg/dart2js_info/bin/tools.dart
index 15f575a..787e9e2 100644
--- a/pkg/dart2js_info/bin/tools.dart
+++ b/pkg/dart2js_info/bin/tools.dart
@@ -22,7 +22,7 @@
import 'src/to_devtools_format.dart';
/// Entrypoint to run all dart2js_info tools.
-void main(args) {
+void main(List<String> args) {
var commandRunner =
CommandRunner(
"dart2js_info",
diff --git a/pkg/dart2js_tools/bin/deobfuscate.dart b/pkg/dart2js_tools/bin/deobfuscate.dart
index c1581d0..86c1195 100644
--- a/pkg/dart2js_tools/bin/deobfuscate.dart
+++ b/pkg/dart2js_tools/bin/deobfuscate.dart
@@ -40,7 +40,7 @@
///
/// The .js file must contain a `//# sourceMappingURL=` line at the end, which
/// tells this script how to determine the name of the source-map file.
-main(List<String> args) {
+void main(List<String> args) {
if (args.length != 1) {
print('usage: deobfuscate.dart <stack-trace-file>');
exit(1);
@@ -87,7 +87,7 @@
final green = stdout.hasTerminal ? '\x1b[32m' : '';
final none = stdout.hasTerminal ? '\x1b[0m' : '';
-printPadded(String mapping, String? original, sb) {
+void printPadded(String mapping, String? original, sb) {
var len = mapping.length;
var s = mapping.indexOf('\n');
if (s >= 0) len -= s + 1;
diff --git a/pkg/dart2js_tools/bin/lookup_name.dart b/pkg/dart2js_tools/bin/lookup_name.dart
index 9113b73..8e5b88e 100644
--- a/pkg/dart2js_tools/bin/lookup_name.dart
+++ b/pkg/dart2js_tools/bin/lookup_name.dart
@@ -4,7 +4,7 @@
import 'package:dart2js_tools/src/dart2js_mapping.dart';
import 'package:dart2js_tools/src/util.dart';
-main(List<String> args) {
+void main(List<String> args) {
if (args.length < 2) {
print('usage: read.dart <source-map-file> <name>');
exit(1);
diff --git a/pkg/dart2js_tools/bin/read.dart b/pkg/dart2js_tools/bin/read.dart
index 8b1d609..0604054 100644
--- a/pkg/dart2js_tools/bin/read.dart
+++ b/pkg/dart2js_tools/bin/read.dart
@@ -3,7 +3,7 @@
import 'package:source_maps/source_maps.dart';
-main(List<String> args) {
+void main(List<String> args) {
if (args.length != 1) {
print('usage: read.dart <source-map-file>');
exit(1);
diff --git a/pkg/dart2js_tools/bin/show_inline_data.dart b/pkg/dart2js_tools/bin/show_inline_data.dart
index 8def7f7..7c65867e 100644
--- a/pkg/dart2js_tools/bin/show_inline_data.dart
+++ b/pkg/dart2js_tools/bin/show_inline_data.dart
@@ -11,7 +11,7 @@
///
/// This expands the push/pop operations and checks simple invariants (e.g. that
/// the stack is always empty at the beginning of a function).
-main(List<String> args) {
+void main(List<String> args) {
if (args.length != 1) {
print('usage: show_inline_data.dart <js-file>');
exit(1);
diff --git a/pkg/expect/lib/expect.dart b/pkg/expect/lib/expect.dart
index d098306..8b474ec 100644
--- a/pkg/expect/lib/expect.dart
+++ b/pkg/expect/lib/expect.dart
@@ -78,7 +78,8 @@
return buf.toString();
}
- static _escapeSubstring(StringBuffer buf, String string, int start, int end) {
+ static void _escapeSubstring(
+ StringBuffer buf, String string, int start, int end) {
const hexDigits = "0123456789ABCDEF";
const backslash = 0x5c;
int chunkStart = start; // No escapes since this point.
@@ -310,7 +311,8 @@
/// Checks that the expected and actual values are *not* identical
/// (using `identical`).
- static void notIdentical(var unexpected, var actual, [String reason = ""]) {
+ static void notIdentical(dynamic unexpected, dynamic actual,
+ [String reason = ""]) {
if (!_identical(unexpected, actual)) return;
String msg = _getMessage(reason);
_fail("Expect.notIdentical(expected and actual: <$actual>$msg) fails.");
@@ -370,7 +372,8 @@
'tolerance:<$tolerance>$msg) fails');
}
- static void notEquals(unexpected, actual, [String reason = ""]) {
+ static void notEquals(dynamic unexpected, dynamic actual,
+ [String reason = ""]) {
if (unexpected != actual) return;
String msg = _getMessage(reason);
_fail("Expect.notEquals(unexpected: <$unexpected>, actual:<$actual>$msg) "
@@ -435,8 +438,8 @@
}
}
if (expectedKeys.length != actualKeys.length) {
- _failNotEqual(expectedKeys.length, actualKeys.length,
- "mapEquals", "map.length");
+ _failNotEqual(
+ expectedKeys.length, actualKeys.length, "mapEquals", "map.length");
}
}
@@ -886,7 +889,7 @@
}
/// Used in [Expect] because [Expect.identical] shadows the real [identical].
-bool _identical(a, b) => identical(a, b);
+bool _identical(dynamic a, dynamic b) => identical(a, b);
/// Exception thrown on a failed expectation check.
///
diff --git a/pkg/expect/lib/legacy/async_minitest.dart b/pkg/expect/lib/legacy/async_minitest.dart
index c6b962d..155e5ca 100644
--- a/pkg/expect/lib/legacy/async_minitest.dart
+++ b/pkg/expect/lib/legacy/async_minitest.dart
@@ -253,13 +253,13 @@
_checkThrow<Object>(v, (_) {});
}
-Matcher throwsA(matcher) => (dynamic o) {
+Matcher throwsA(dynamic matcher) => (dynamic o) {
_checkThrow<Object>(o, (error) {
expect(error, matcher);
});
};
-Matcher completion(matcher) => (dynamic o) {
+Matcher completion(dynamic matcher) => (dynamic o) {
Expect.type<Future>(o);
Future future = o;
asyncStart();
diff --git a/pkg/expect/lib/legacy/minitest.dart b/pkg/expect/lib/legacy/minitest.dart
index 63d4b2f..45ac4de 100644
--- a/pkg/expect/lib/legacy/minitest.dart
+++ b/pkg/expect/lib/legacy/minitest.dart
@@ -190,7 +190,7 @@
fail("Expected $actual to be one of $expected.");
});
-_defaultAction() {}
+dynamic _defaultAction() {}
/// One level of group() nesting to track an optional [setUp()] and [tearDown()]
/// function for the group.
diff --git a/pkg/linter/tool/migrate.dart b/pkg/linter/tool/migrate.dart
index 45ea27a..aad9b8f 100644
--- a/pkg/linter/tool/migrate.dart
+++ b/pkg/linter/tool/migrate.dart
@@ -15,7 +15,7 @@
import 'checks/driver.dart';
/// Lists files yet to be migrated to the new element model.
-main(List<String> args) async {
+void main(List<String> args) async {
var parser = ArgParser()
..addFlag('write',
abbr: 'w', help: 'Write updated `analyzer_use_new_elements.txt` file.');
diff --git a/pkg/sourcemap_testing/lib/src/stacktrace_helper.dart b/pkg/sourcemap_testing/lib/src/stacktrace_helper.dart
index 2d80165..430c4d7 100644
--- a/pkg/sourcemap_testing/lib/src/stacktrace_helper.dart
+++ b/pkg/sourcemap_testing/lib/src/stacktrace_helper.dart
@@ -91,7 +91,7 @@
/// function returns `true` if the compilation succeeded.
typedef CompileFunc = Future<bool> Function(String, String);
-List<String> emptyPreamble(input, output) => const <String>[];
+List<String> emptyPreamble(String input, String output) => const <String>[];
String? identityConverter(String? name) => name;
/// Tests the stack trace of [test] using the expectations for [config].
diff --git a/pkg/test_runner/bin/compare_results.dart b/pkg/test_runner/bin/compare_results.dart
index 15a11c2..10ecbf2 100755
--- a/pkg/test_runner/bin/compare_results.dart
+++ b/pkg/test_runner/bin/compare_results.dart
@@ -164,7 +164,7 @@
return judgement;
}
-main(List<String> args) async {
+void main(List<String> args) async {
final parser = ArgParser();
parser.addFlag("changed",
abbr: 'c',
diff --git a/pkg/vm/bin/dump_kernel.dart b/pkg/vm/bin/dump_kernel.dart
index 22b5d8d..0014d5a 100644
--- a/pkg/vm/bin/dump_kernel.dart
+++ b/pkg/vm/bin/dump_kernel.dart
@@ -30,7 +30,7 @@
Dumps kernel binary file with VM-specific metadata.
''';
-main(List<String> arguments) async {
+void main(List<String> arguments) async {
if (arguments.length != 2) {
print(_usage);
exit(1);
diff --git a/pkg/vm/bin/gen_kernel.dart b/pkg/vm/bin/gen_kernel.dart
index 2a4dffa..6b6a180 100644
--- a/pkg/vm/bin/gen_kernel.dart
+++ b/pkg/vm/bin/gen_kernel.dart
@@ -27,7 +27,7 @@
${_argParser.usage}
''';
-main(List<String> arguments) async {
+void main(List<String> arguments) async {
if (arguments.isNotEmpty && arguments.last == '--batch') {
await runBatchModeCompiler();
} else {
diff --git a/pkg/vm_service/example/sample_isolates.dart b/pkg/vm_service/example/sample_isolates.dart
index 98eb667..125e7e4 100644
--- a/pkg/vm_service/example/sample_isolates.dart
+++ b/pkg/vm_service/example/sample_isolates.dart
@@ -27,10 +27,10 @@
}
void startIsolate(int val) {
- Isolate.spawn(isolateEntry, val);
+ Isolate.spawn<int>(isolateEntry, val);
}
-Future isolateEntry(message) async {
+Future isolateEntry(int message) async {
print('starting $message');
await Future.delayed(Duration(seconds: message));
print('ending $message');