Use 'no-' prefix to disable an experiment.
Change-Id: I597a98802f6900d57ed4583c35b20790738e2f3a
Reviewed-on: https://dart-review.googlesource.com/c/88712
Reviewed-by: Paul Berry <paulberry@google.com>
Reviewed-by: Kevin Millikin <kmillikin@google.com>
Commit-Queue: Aske Simon Christensen <askesc@google.com>
diff --git a/pkg/front_end/lib/src/api_prototype/compiler_options.dart b/pkg/front_end/lib/src/api_prototype/compiler_options.dart
index cb41df3..fbf575d 100644
--- a/pkg/front_end/lib/src/api_prototype/compiler_options.dart
+++ b/pkg/front_end/lib/src/api_prototype/compiler_options.dart
@@ -120,12 +120,12 @@
/// directly, while relative URIs are resolved from the [sdkRoot].
// TODO(sigmund): provide also a flag to load this data from a file (like
// libraries.json)
- Map<String, List<Uri>> targetPatches = {};
+ Map<String, List<Uri>> targetPatches = <String, List<Uri>>{};
/// Enable or disable experimental features. Features mapping to `true` are
/// explicitly enabled. Features mapping to `false` are explicitly disabled.
/// Features not mentioned in the map will have their default value.
- Map<ExperimentalFlag, bool> experimentalFlags = {};
+ Map<ExperimentalFlag, bool> experimentalFlags = <ExperimentalFlag, bool>{};
/// The target platform that will consume the compiled code.
///
diff --git a/pkg/front_end/lib/src/fasta/fasta_codes_generated.dart b/pkg/front_end/lib/src/fasta/fasta_codes_generated.dart
index bfea29e..9940a74 100644
--- a/pkg/front_end/lib/src/fasta/fasta_codes_generated.dart
+++ b/pkg/front_end/lib/src/fasta/fasta_codes_generated.dart
@@ -3323,9 +3323,9 @@
commas, for example, --fatal=errors,warnings.
--enable-experiment=<flag>
- --disable-experiment=<flag>
Enable or disable an experimental flag, used to guard features currently
- in development. Multiple experiments can be separated by commas.""");
+ in development. Prefix an experiment name with 'no-' to disable it.
+ Multiple experiments can be separated by commas.""");
// DO NOT EDIT. THIS FILE IS GENERATED. SEE TOP OF FILE.
const Code<Null> codeFastaUsageShort = messageFastaUsageShort;
diff --git a/pkg/front_end/messages.yaml b/pkg/front_end/messages.yaml
index eb90f60..d240e13 100644
--- a/pkg/front_end/messages.yaml
+++ b/pkg/front_end/messages.yaml
@@ -1587,9 +1587,9 @@
commas, for example, --fatal=errors,warnings.
--enable-experiment=<flag>
- --disable-experiment=<flag>
Enable or disable an experimental flag, used to guard features currently
- in development. Multiple experiments can be separated by commas.
+ in development. Prefix an experiment name with 'no-' to disable it.
+ Multiple experiments can be separated by commas.
FastaCLIArgumentRequired:
template: "Expected value after '#name'."
diff --git a/pkg/front_end/tool/_fasta/command_line.dart b/pkg/front_end/tool/_fasta/command_line.dart
index 7728f88..436d523 100644
--- a/pkg/front_end/tool/_fasta/command_line.dart
+++ b/pkg/front_end/tool/_fasta/command_line.dart
@@ -240,7 +240,6 @@
const Map<String, dynamic> optionSpecification = const <String, dynamic>{
"--bytecode": false,
"--compile-sdk": Uri,
- "--disable-experiment": ",",
"--dump-ir": false,
"--enable-experiment": ",",
"--exclude-source": false,
@@ -343,31 +342,25 @@
});
}
- final List<String> enabledExperiments = options["--enable-experiment"];
- final List<String> disabledExperiments = options["--disable-experiment"];
-
- Map<ExperimentalFlag, bool> experimentalFlags = {};
-
- void setExperimentalFlags(List<String> experiments, bool value) {
- if (experiments != null) {
- for (String experiment in experiments) {
- ExperimentalFlag flag = parseExperimentalFlag(experiment);
- if (flag == null) {
- throw new CommandLineProblem.deprecated(
- "Unknown experiment: " + experiment);
- }
- if (experimentalFlags.containsKey(flag)) {
- throw new CommandLineProblem.deprecated(
- "Experiment mentioned more than once: " + experiment);
- }
- experimentalFlags[flag] = value;
- }
+ Map<ExperimentalFlag, bool> experimentalFlags = <ExperimentalFlag, bool>{};
+ for (String experiment in options["--enable-experiment"] ?? <String>[]) {
+ bool value = true;
+ if (experiment.startsWith("no-")) {
+ value = false;
+ experiment = experiment.substring(3);
}
+ ExperimentalFlag flag = parseExperimentalFlag(experiment);
+ if (flag == null) {
+ throw new CommandLineProblem.deprecated(
+ "Unknown experiment: " + experiment);
+ }
+ if (experimentalFlags.containsKey(flag)) {
+ throw new CommandLineProblem.deprecated(
+ "Experiment mentioned more than once: " + experiment);
+ }
+ experimentalFlags[flag] = value;
}
- setExperimentalFlags(enabledExperiments, true);
- setExperimentalFlags(disabledExperiments, false);
-
if (programName == "compile_platform") {
if (arguments.length != 5) {
return throw new CommandLineProblem.deprecated(