From fef2ba30a6870b4bb1b6f6f38aef814038f8253c Mon Sep 17 00:00:00 2001 From: Parker Lougheed Date: Thu, 30 May 2024 14:55:21 +0000 Subject: [PATCH] [dartdev] Avoid unnecessary uses of late Change-Id: I702e5c91e803b06dd1321efe563c104bc00c19d3 Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/368740 Reviewed-by: Derek Xu Reviewed-by: Ben Konyi Commit-Queue: Ben Konyi --- pkg/dartdev/lib/dartdev.dart | 2 +- pkg/dartdev/lib/src/commands/compile.dart | 4 ++-- pkg/dartdev/lib/src/dds_runner.dart | 4 ++-- pkg/dartdev/lib/src/generate_kernel.dart | 2 +- pkg/dartdev/tool/sdk_size.dart | 4 +--- 5 files changed, 7 insertions(+), 9 deletions(-) diff --git a/pkg/dartdev/lib/dartdev.dart b/pkg/dartdev/lib/dartdev.dart index d1466e91b536..2b57c07dc528 100644 --- a/pkg/dartdev/lib/dartdev.dart +++ b/pkg/dartdev/lib/dartdev.dart @@ -71,7 +71,7 @@ class DartdevRunner extends CommandRunner { 'A command-line utility for Dart development'; @override - late final ArgParser argParser; + final ArgParser argParser; final bool verbose; diff --git a/pkg/dartdev/lib/src/commands/compile.dart b/pkg/dartdev/lib/src/commands/compile.dart index bae371d59dab..08cee8b4f885 100644 --- a/pkg/dartdev/lib/src/commands/compile.dart +++ b/pkg/dartdev/lib/src/commands/compile.dart @@ -895,8 +895,8 @@ Sets the verbosity level of the compilation. flagDefaultsTo: true, ); - late final Option defineOption; - late final Option packagesOption; + final Option defineOption; + final Option packagesOption; CompileSubcommandCommand(super.name, super.description, super.verbose, {super.hidden}) diff --git a/pkg/dartdev/lib/src/dds_runner.dart b/pkg/dartdev/lib/src/dds_runner.dart index 71f99f4486e5..749f06259975 100644 --- a/pkg/dartdev/lib/src/dds_runner.dart +++ b/pkg/dartdev/lib/src/dds_runner.dart @@ -50,7 +50,7 @@ class DDSRunner { const devToolsMessagePrefix = 'The Dart DevTools debugger and profiler is available at:'; if (debugDds) { - late StreamSubscription stdoutSub; + late final StreamSubscription stdoutSub; stdoutSub = process.stdout.transform(utf8.decoder).listen((event) { if (event.startsWith(devToolsMessagePrefix)) { final ddsDebuggingUri = event.split(' ').last; @@ -61,7 +61,7 @@ class DDSRunner { } }); } - late StreamSubscription stderrSub; + late final StreamSubscription stderrSub; stderrSub = process.stderr.transform(utf8.decoder).listen((event) { final result = json.decode(event) as Map; final state = result['state']; diff --git a/pkg/dartdev/lib/src/generate_kernel.dart b/pkg/dartdev/lib/src/generate_kernel.dart index 00b4fc024c21..ea906bbfb7a6 100644 --- a/pkg/dartdev/lib/src/generate_kernel.dart +++ b/pkg/dartdev/lib/src/generate_kernel.dart @@ -150,7 +150,7 @@ Future ensureCompilationServerIsRunning( } try { Directory(p.dirname(serverInfoFile.path)).createSync(recursive: true); - late final Process frontendServerProcess; + final Process frontendServerProcess; if (File(sdk.frontendServerAotSnapshot).existsSync()) { frontendServerProcess = await Process.start( sdk.dartAotRuntime, diff --git a/pkg/dartdev/tool/sdk_size.dart b/pkg/dartdev/tool/sdk_size.dart index bf711a7efdb6..d6691779452b 100644 --- a/pkg/dartdev/tool/sdk_size.dart +++ b/pkg/dartdev/tool/sdk_size.dart @@ -11,13 +11,11 @@ import 'dart:io'; import 'package:path/path.dart' as p; -late final String dartSdkPath; +final String dartSdkPath = p.dirname(p.dirname(Platform.resolvedExecutable)); final List fileStats = []; void main(List arguments) { - final vm = Platform.resolvedExecutable; - dartSdkPath = p.dirname(p.dirname(vm)); final version = File(p.join(dartSdkPath, 'version')).readAsStringSync().trim();