From 6c88c6f2ba475fe519bdd7377ac51462b2581dfd Mon Sep 17 00:00:00 2001 From: Robert Nystrom Date: Wed, 27 May 2026 16:54:31 -0700 Subject: [PATCH] Migrate pkg/smith to the new constructor syntax. Change-Id: I5f17f4a7eddd5dd839b2061f5d4a1f33c40703a9 Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/506661 Commit-Queue: Bob Nystrom Auto-Submit: Bob Nystrom Reviewed-by: Paul Berry --- pkg/smith/analysis_options.yaml | 4 ++++ pkg/smith/lib/builder.dart | 4 ++-- pkg/smith/lib/configuration.dart | 22 +++++++++++----------- pkg/smith/lib/test_matrix.dart | 2 +- pkg/smith/pubspec.yaml | 2 +- 5 files changed, 19 insertions(+), 15 deletions(-) diff --git a/pkg/smith/analysis_options.yaml b/pkg/smith/analysis_options.yaml index 055ac10871c..933050fe686 100644 --- a/pkg/smith/analysis_options.yaml +++ b/pkg/smith/analysis_options.yaml @@ -3,3 +3,7 @@ include: package:lints/recommended.yaml analyzer: language: strict-casts: true +linter: + rules: + - unnecessary_const_in_enum_constructor + - unnecessary_type_name_in_constructor diff --git a/pkg/smith/lib/builder.dart b/pkg/smith/lib/builder.dart index 6f277304576..831dbdf811f 100644 --- a/pkg/smith/lib/builder.dart +++ b/pkg/smith/lib/builder.dart @@ -26,7 +26,7 @@ class Step { final bool isTestRunner; final Configuration? testedConfiguration; - Step(this.name, String? script, this.arguments, this.environment, + new(this.name, String? script, this.arguments, this.environment, this.fileSet, this.shards, this.isTestRunner, this.testedConfiguration) : script = script ?? testScriptName; @@ -102,7 +102,7 @@ class Builder { final Runtime? runtime; final Set testedConfigurations; - Builder(this.name, this.description, this.steps, this.system, this.mode, + new(this.name, this.description, this.steps, this.system, this.mode, this.arch, this.sanitizer, this.runtime, this.testedConfigurations); /// Create a [Builder] from its name, a list of 'step templates', the diff --git a/pkg/smith/lib/configuration.dart b/pkg/smith/lib/configuration.dart index 1557b22744e..7dcd305c576 100644 --- a/pkg/smith/lib/configuration.dart +++ b/pkg/smith/lib/configuration.dart @@ -381,7 +381,7 @@ class Configuration { final bool useQemu; - Configuration(this.name, this.architecture, this.compiler, this.mode, + new(this.name, this.architecture, this.compiler, this.mode, this.runtime, this.system, {NnbdMode? nnbdMode, Sanitizer? sanitizer, @@ -439,7 +439,7 @@ class Configuration { /// /// NOTE: All parameters should be required to ensure that cloning factories /// are updated when new class fields are added. - Configuration._cloneHelper( + new _cloneHelper( this.name, this.architecture, this.compiler, @@ -475,7 +475,7 @@ class Configuration { /// /// NOTE: This calls [_cloneHelper] instead of the default constructor to /// ensure it gets updated whenever new fields are added to the class. - factory Configuration.detectHost(Configuration source) => + factory detectHost(Configuration source) => Configuration._cloneHelper( '${source.name}-detect-host-${_detectHostNumber++}', Architecture.host, @@ -740,7 +740,7 @@ enum Architecture { final String name; final bool isSimulator; - const Architecture._(this.name, {this.isSimulator = false}); + new _(this.name, {this.isSimulator = false}); static final List names = _all.keys.toList(); @@ -819,7 +819,7 @@ enum GenSnapshotFormat { final String name; final String fileOption; - const GenSnapshotFormat(this.name, this.fileOption); + new(this.name, this.fileOption); static final _all = Map.fromIterable( values, @@ -903,7 +903,7 @@ enum Compiler { final String name; final List supportedRuntimes; final Mode defaultMode; - const Compiler._(this.name, + new _(this.name, {this.supportedRuntimes = const [Runtime.none], this.defaultMode = Mode.debug}); @@ -948,7 +948,7 @@ enum Mode { } final String name; - const Mode._(this.name); + new _(this.name); bool get isDebug => this == debug; @@ -978,7 +978,7 @@ enum Sanitizer { } final String name; - const Sanitizer._(this.name); + new _(this.name); @override String toString() => name; @@ -1015,7 +1015,7 @@ enum Runtime { /// Whether this runtime is a command-line JavaScript environment. final bool isJSCommandLine; - const Runtime._(this.name, + new _(this.name, {this.isBrowser = false, this.isJSCommandLine = false}); bool get isSafari => name.startsWith("safari"); @@ -1089,7 +1089,7 @@ enum System { /// The root directory name for build outputs on this system. final String outputDirectory; - const System._(this.name, {this.outputDirectory = 'out/'}); + new _(this.name, {this.outputDirectory = 'out/'}); @override String toString() => name; @@ -1123,7 +1123,7 @@ enum NnbdMode { } final String name; - const NnbdMode._(this.name); + new _(this.name); @override String toString() => name; diff --git a/pkg/smith/lib/test_matrix.dart b/pkg/smith/lib/test_matrix.dart index a81a0e3e7f5..acb52c3ef5d 100644 --- a/pkg/smith/lib/test_matrix.dart +++ b/pkg/smith/lib/test_matrix.dart @@ -77,5 +77,5 @@ class TestMatrix { return TestMatrix._(configurations, builders, branches); } - TestMatrix._(this.configurations, this.builders, this.branches); + new _(this.configurations, this.builders, this.branches); } diff --git a/pkg/smith/pubspec.yaml b/pkg/smith/pubspec.yaml index 444539ed0ec..cc381851d2b 100644 --- a/pkg/smith/pubspec.yaml +++ b/pkg/smith/pubspec.yaml @@ -4,7 +4,7 @@ description: Shared code for working with the Dart SDK's tests and test runner. publish_to: none environment: - sdk: '^3.12.0-0' + sdk: '^3.13.0-0' resolution: workspace