Skip to content

Commit

Permalink
Add "named-arguments-anywhere" experiment flag
Browse files Browse the repository at this point in the history
Part of #47451

Change-Id: I049519061d132eb681cc3aa67b1dea5d296e540e
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/216801
Commit-Queue: Chloe Stefantsova <dmitryas@google.com>
Reviewed-by: Johnni Winther <johnniwinther@google.com>
  • Loading branch information
Chloe Stefantsova authored and commit-bot@chromium.org committed Oct 14, 2021
1 parent a666b5a commit 448e441
Show file tree
Hide file tree
Showing 3 changed files with 44 additions and 8 deletions.
41 changes: 33 additions & 8 deletions pkg/analyzer/lib/src/dart/analysis/experiments.g.dart
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,8 @@ final _knownFeatures = <String, ExperimentalFeature>{
EnableString.extension_methods: ExperimentalFeatures.extension_methods,
EnableString.extension_types: ExperimentalFeatures.extension_types,
EnableString.generic_metadata: ExperimentalFeatures.generic_metadata,
EnableString.named_arguments_anywhere:
ExperimentalFeatures.named_arguments_anywhere,
EnableString.non_nullable: ExperimentalFeatures.non_nullable,
EnableString.nonfunction_type_aliases:
ExperimentalFeatures.nonfunction_type_aliases,
Expand Down Expand Up @@ -59,6 +61,9 @@ class EnableString {
/// String to enable the experiment "generic-metadata"
static const String generic_metadata = 'generic-metadata';

/// String to enable the experiment "named-arguments-anywhere"
static const String named_arguments_anywhere = 'named-arguments-anywhere';

/// String to enable the experiment "non-nullable"
static const String non_nullable = 'non-nullable';

Expand Down Expand Up @@ -168,8 +173,18 @@ class ExperimentalFeatures {
releaseVersion: Version.parse('2.14.0'),
);

static final non_nullable = ExperimentalFeature(
static final named_arguments_anywhere = ExperimentalFeature(
index: 8,
enableString: EnableString.named_arguments_anywhere,
isEnabledByDefault: IsEnabledByDefault.named_arguments_anywhere,
isExpired: IsExpired.named_arguments_anywhere,
documentation: 'Named Arguments Anywhere',
experimentalReleaseVersion: null,
releaseVersion: null,
);

static final non_nullable = ExperimentalFeature(
index: 9,
enableString: EnableString.non_nullable,
isEnabledByDefault: IsEnabledByDefault.non_nullable,
isExpired: IsExpired.non_nullable,
Expand All @@ -179,7 +194,7 @@ class ExperimentalFeatures {
);

static final nonfunction_type_aliases = ExperimentalFeature(
index: 9,
index: 10,
enableString: EnableString.nonfunction_type_aliases,
isEnabledByDefault: IsEnabledByDefault.nonfunction_type_aliases,
isExpired: IsExpired.nonfunction_type_aliases,
Expand All @@ -189,7 +204,7 @@ class ExperimentalFeatures {
);

static final set_literals = ExperimentalFeature(
index: 10,
index: 11,
enableString: EnableString.set_literals,
isEnabledByDefault: IsEnabledByDefault.set_literals,
isExpired: IsExpired.set_literals,
Expand All @@ -199,7 +214,7 @@ class ExperimentalFeatures {
);

static final spread_collections = ExperimentalFeature(
index: 11,
index: 12,
enableString: EnableString.spread_collections,
isEnabledByDefault: IsEnabledByDefault.spread_collections,
isExpired: IsExpired.spread_collections,
Expand All @@ -209,7 +224,7 @@ class ExperimentalFeatures {
);

static final test_experiment = ExperimentalFeature(
index: 12,
index: 13,
enableString: EnableString.test_experiment,
isEnabledByDefault: IsEnabledByDefault.test_experiment,
isExpired: IsExpired.test_experiment,
Expand All @@ -220,7 +235,7 @@ class ExperimentalFeatures {
);

static final triple_shift = ExperimentalFeature(
index: 13,
index: 14,
enableString: EnableString.triple_shift,
isEnabledByDefault: IsEnabledByDefault.triple_shift,
isExpired: IsExpired.triple_shift,
Expand All @@ -230,7 +245,7 @@ class ExperimentalFeatures {
);

static final value_class = ExperimentalFeature(
index: 14,
index: 15,
enableString: EnableString.value_class,
isEnabledByDefault: IsEnabledByDefault.value_class,
isExpired: IsExpired.value_class,
Expand All @@ -240,7 +255,7 @@ class ExperimentalFeatures {
);

static final variance = ExperimentalFeature(
index: 15,
index: 16,
enableString: EnableString.variance,
isEnabledByDefault: IsEnabledByDefault.variance,
isExpired: IsExpired.variance,
Expand Down Expand Up @@ -277,6 +292,9 @@ class IsEnabledByDefault {
/// Default state of the experiment "generic-metadata"
static const bool generic_metadata = true;

/// Default state of the experiment "named-arguments-anywhere"
static const bool named_arguments_anywhere = false;

/// Default state of the experiment "non-nullable"
static const bool non_nullable = true;

Expand Down Expand Up @@ -330,6 +348,9 @@ class IsExpired {
/// Expiration status of the experiment "generic-metadata"
static const bool generic_metadata = false;

/// Expiration status of the experiment "named-arguments-anywhere"
static const bool named_arguments_anywhere = false;

/// Expiration status of the experiment "non-nullable"
static const bool non_nullable = false;

Expand Down Expand Up @@ -384,6 +405,10 @@ mixin _CurrentState {
/// Current state for the flag "generic-metadata"
bool get generic_metadata => isEnabled(ExperimentalFeatures.generic_metadata);

/// Current state for the flag "named-arguments-anywhere"
bool get named_arguments_anywhere =>
isEnabled(ExperimentalFeatures.named_arguments_anywhere);

/// Current state for the flag "non-nullable"
bool get non_nullable => isEnabled(ExperimentalFeatures.non_nullable);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ enum ExperimentalFlag {
extensionMethods,
extensionTypes,
genericMetadata,
namedArgumentsAnywhere,
nonNullable,
nonfunctionTypeAliases,
setLiterals,
Expand All @@ -39,6 +40,7 @@ const Version enableEnhancedEnumsVersion = const Version(2, 15);
const Version enableExtensionMethodsVersion = const Version(2, 6);
const Version enableExtensionTypesVersion = const Version(2, 15);
const Version enableGenericMetadataVersion = const Version(2, 14);
const Version enableNamedArgumentsAnywhereVersion = const Version(2, 15);
const Version enableNonNullableVersion = const Version(2, 12);
const Version enableNonfunctionTypeAliasesVersion = const Version(2, 13);
const Version enableSetLiteralsVersion = const Version(2, 0);
Expand Down Expand Up @@ -68,6 +70,8 @@ ExperimentalFlag? parseExperimentalFlag(String flag) {
return ExperimentalFlag.extensionTypes;
case "generic-metadata":
return ExperimentalFlag.genericMetadata;
case "named-arguments-anywhere":
return ExperimentalFlag.namedArgumentsAnywhere;
case "non-nullable":
return ExperimentalFlag.nonNullable;
case "nonfunction-type-aliases":
Expand Down Expand Up @@ -98,6 +102,7 @@ const Map<ExperimentalFlag, bool> defaultExperimentalFlags = {
ExperimentalFlag.extensionMethods: true,
ExperimentalFlag.extensionTypes: false,
ExperimentalFlag.genericMetadata: true,
ExperimentalFlag.namedArgumentsAnywhere: false,
ExperimentalFlag.nonNullable: true,
ExperimentalFlag.nonfunctionTypeAliases: true,
ExperimentalFlag.setLiterals: true,
Expand All @@ -118,6 +123,7 @@ const Map<ExperimentalFlag, bool> expiredExperimentalFlags = {
ExperimentalFlag.extensionMethods: false,
ExperimentalFlag.extensionTypes: false,
ExperimentalFlag.genericMetadata: false,
ExperimentalFlag.namedArgumentsAnywhere: false,
ExperimentalFlag.nonNullable: false,
ExperimentalFlag.nonfunctionTypeAliases: false,
ExperimentalFlag.setLiterals: true,
Expand All @@ -138,6 +144,7 @@ const Map<ExperimentalFlag, Version> experimentEnabledVersion = {
ExperimentalFlag.extensionMethods: const Version(2, 6),
ExperimentalFlag.extensionTypes: const Version(2, 15),
ExperimentalFlag.genericMetadata: const Version(2, 14),
ExperimentalFlag.namedArgumentsAnywhere: const Version(2, 15),
ExperimentalFlag.nonNullable: const Version(2, 12),
ExperimentalFlag.nonfunctionTypeAliases: const Version(2, 13),
ExperimentalFlag.setLiterals: const Version(2, 0),
Expand All @@ -158,6 +165,7 @@ const Map<ExperimentalFlag, Version> experimentReleasedVersion = {
ExperimentalFlag.extensionMethods: const Version(2, 6),
ExperimentalFlag.extensionTypes: const Version(2, 15),
ExperimentalFlag.genericMetadata: const Version(2, 14),
ExperimentalFlag.namedArgumentsAnywhere: const Version(2, 15),
ExperimentalFlag.nonNullable: const Version(2, 10),
ExperimentalFlag.nonfunctionTypeAliases: const Version(2, 13),
ExperimentalFlag.setLiterals: const Version(2, 0),
Expand Down
3 changes: 3 additions & 0 deletions tools/experimental_features.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -125,6 +125,9 @@ features:
enhanced-enums:
help: "Enhanced Enums"

named-arguments-anywhere:
help: "Named Arguments Anywhere"

# Experiment flag only used for testing.
test-experiment:
help: >-
Expand Down

0 comments on commit 448e441

Please sign in to comment.