Skip to content
This repository was archived by the owner on Feb 25, 2025. It is now read-only.

Commit 0f1b943

Browse files
askeksacommit-bot@chromium.org
authored andcommitted
Use 'no-' prefix to disable an experiment.
Change-Id: I597a98802f6900d57ed4583c35b20790738e2f3a Reviewed-on: https://dart-review.googlesource.com/c/88712 Reviewed-by: Paul Berry <[email protected]> Reviewed-by: Kevin Millikin <[email protected]> Commit-Queue: Aske Simon Christensen <[email protected]>
1 parent de85d16 commit 0f1b943

File tree

4 files changed

+22
-29
lines changed

4 files changed

+22
-29
lines changed

pkg/front_end/lib/src/api_prototype/compiler_options.dart

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -120,12 +120,12 @@ class CompilerOptions {
120120
/// directly, while relative URIs are resolved from the [sdkRoot].
121121
// TODO(sigmund): provide also a flag to load this data from a file (like
122122
// libraries.json)
123-
Map<String, List<Uri>> targetPatches = {};
123+
Map<String, List<Uri>> targetPatches = <String, List<Uri>>{};
124124

125125
/// Enable or disable experimental features. Features mapping to `true` are
126126
/// explicitly enabled. Features mapping to `false` are explicitly disabled.
127127
/// Features not mentioned in the map will have their default value.
128-
Map<ExperimentalFlag, bool> experimentalFlags = {};
128+
Map<ExperimentalFlag, bool> experimentalFlags = <ExperimentalFlag, bool>{};
129129

130130
/// The target platform that will consume the compiled code.
131131
///

pkg/front_end/lib/src/fasta/fasta_codes_generated.dart

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3323,9 +3323,9 @@ const MessageCode messageFastaUsageLong =
33233323
commas, for example, --fatal=errors,warnings.
33243324
33253325
--enable-experiment=<flag>
3326-
--disable-experiment=<flag>
33273326
Enable or disable an experimental flag, used to guard features currently
3328-
in development. Multiple experiments can be separated by commas.""");
3327+
in development. Prefix an experiment name with 'no-' to disable it.
3328+
Multiple experiments can be separated by commas.""");
33293329

33303330
// DO NOT EDIT. THIS FILE IS GENERATED. SEE TOP OF FILE.
33313331
const Code<Null> codeFastaUsageShort = messageFastaUsageShort;

pkg/front_end/messages.yaml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1587,9 +1587,9 @@ FastaUsageLong:
15871587
commas, for example, --fatal=errors,warnings.
15881588
15891589
--enable-experiment=<flag>
1590-
--disable-experiment=<flag>
15911590
Enable or disable an experimental flag, used to guard features currently
1592-
in development. Multiple experiments can be separated by commas.
1591+
in development. Prefix an experiment name with 'no-' to disable it.
1592+
Multiple experiments can be separated by commas.
15931593
15941594
FastaCLIArgumentRequired:
15951595
template: "Expected value after '#name'."

pkg/front_end/tool/_fasta/command_line.dart

Lines changed: 16 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -240,7 +240,6 @@ class ParsedArguments {
240240
const Map<String, dynamic> optionSpecification = const <String, dynamic>{
241241
"--bytecode": false,
242242
"--compile-sdk": Uri,
243-
"--disable-experiment": ",",
244243
"--dump-ir": false,
245244
"--enable-experiment": ",",
246245
"--exclude-source": false,
@@ -343,31 +342,25 @@ ProcessedOptions analyzeCommandLine(
343342
});
344343
}
345344

346-
final List<String> enabledExperiments = options["--enable-experiment"];
347-
final List<String> disabledExperiments = options["--disable-experiment"];
348-
349-
Map<ExperimentalFlag, bool> experimentalFlags = {};
350-
351-
void setExperimentalFlags(List<String> experiments, bool value) {
352-
if (experiments != null) {
353-
for (String experiment in experiments) {
354-
ExperimentalFlag flag = parseExperimentalFlag(experiment);
355-
if (flag == null) {
356-
throw new CommandLineProblem.deprecated(
357-
"Unknown experiment: " + experiment);
358-
}
359-
if (experimentalFlags.containsKey(flag)) {
360-
throw new CommandLineProblem.deprecated(
361-
"Experiment mentioned more than once: " + experiment);
362-
}
363-
experimentalFlags[flag] = value;
364-
}
345+
Map<ExperimentalFlag, bool> experimentalFlags = <ExperimentalFlag, bool>{};
346+
for (String experiment in options["--enable-experiment"] ?? <String>[]) {
347+
bool value = true;
348+
if (experiment.startsWith("no-")) {
349+
value = false;
350+
experiment = experiment.substring(3);
351+
}
352+
ExperimentalFlag flag = parseExperimentalFlag(experiment);
353+
if (flag == null) {
354+
throw new CommandLineProblem.deprecated(
355+
"Unknown experiment: " + experiment);
365356
}
357+
if (experimentalFlags.containsKey(flag)) {
358+
throw new CommandLineProblem.deprecated(
359+
"Experiment mentioned more than once: " + experiment);
360+
}
361+
experimentalFlags[flag] = value;
366362
}
367363

368-
setExperimentalFlags(enabledExperiments, true);
369-
setExperimentalFlags(disabledExperiments, false);
370-
371364
if (programName == "compile_platform") {
372365
if (arguments.length != 5) {
373366
return throw new CommandLineProblem.deprecated(

0 commit comments

Comments
 (0)