mirror of
https://github.com/dart-lang/sdk
synced 2024-11-02 12:24:24 +00:00
Add an experiment flag for patterns.
Change-Id: I175e4680a0949e52ae05f46c2051c701b55a99cd Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/260500 Reviewed-by: Brian Wilkerson <brianwilkerson@google.com> Reviewed-by: Devon Carew <devoncarew@google.com> Commit-Queue: Paul Berry <paulberry@google.com> Reviewed-by: Johnni Winther <johnniwinther@google.com>
This commit is contained in:
parent
8aded3449e
commit
4f87eacc5e
5 changed files with 59 additions and 11 deletions
|
@ -40,6 +40,9 @@ abstract class Feature {
|
||||||
/// Feature information for macros.
|
/// Feature information for macros.
|
||||||
static final macros = ExperimentalFeatures.macros;
|
static final macros = ExperimentalFeatures.macros;
|
||||||
|
|
||||||
|
/// Feature information for patterns.
|
||||||
|
static final patterns = ExperimentalFeatures.patterns;
|
||||||
|
|
||||||
/// Feature information for records.
|
/// Feature information for records.
|
||||||
static final records = ExperimentalFeatures.records;
|
static final records = ExperimentalFeatures.records;
|
||||||
|
|
||||||
|
|
|
@ -33,6 +33,7 @@ final _knownFeatures = <String, ExperimentalFeature>{
|
||||||
EnableString.non_nullable: ExperimentalFeatures.non_nullable,
|
EnableString.non_nullable: ExperimentalFeatures.non_nullable,
|
||||||
EnableString.nonfunction_type_aliases:
|
EnableString.nonfunction_type_aliases:
|
||||||
ExperimentalFeatures.nonfunction_type_aliases,
|
ExperimentalFeatures.nonfunction_type_aliases,
|
||||||
|
EnableString.patterns: ExperimentalFeatures.patterns,
|
||||||
EnableString.records: ExperimentalFeatures.records,
|
EnableString.records: ExperimentalFeatures.records,
|
||||||
EnableString.set_literals: ExperimentalFeatures.set_literals,
|
EnableString.set_literals: ExperimentalFeatures.set_literals,
|
||||||
EnableString.spread_collections: ExperimentalFeatures.spread_collections,
|
EnableString.spread_collections: ExperimentalFeatures.spread_collections,
|
||||||
|
@ -88,6 +89,9 @@ class EnableString {
|
||||||
/// String to enable the experiment "nonfunction-type-aliases"
|
/// String to enable the experiment "nonfunction-type-aliases"
|
||||||
static const String nonfunction_type_aliases = 'nonfunction-type-aliases';
|
static const String nonfunction_type_aliases = 'nonfunction-type-aliases';
|
||||||
|
|
||||||
|
/// String to enable the experiment "patterns"
|
||||||
|
static const String patterns = 'patterns';
|
||||||
|
|
||||||
/// String to enable the experiment "records"
|
/// String to enable the experiment "records"
|
||||||
static const String records = 'records';
|
static const String records = 'records';
|
||||||
|
|
||||||
|
@ -258,8 +262,18 @@ class ExperimentalFeatures {
|
||||||
releaseVersion: Version.parse('2.13.0'),
|
releaseVersion: Version.parse('2.13.0'),
|
||||||
);
|
);
|
||||||
|
|
||||||
static final records = ExperimentalFeature(
|
static final patterns = ExperimentalFeature(
|
||||||
index: 14,
|
index: 14,
|
||||||
|
enableString: EnableString.patterns,
|
||||||
|
isEnabledByDefault: IsEnabledByDefault.patterns,
|
||||||
|
isExpired: IsExpired.patterns,
|
||||||
|
documentation: 'Patterns',
|
||||||
|
experimentalReleaseVersion: null,
|
||||||
|
releaseVersion: null,
|
||||||
|
);
|
||||||
|
|
||||||
|
static final records = ExperimentalFeature(
|
||||||
|
index: 15,
|
||||||
enableString: EnableString.records,
|
enableString: EnableString.records,
|
||||||
isEnabledByDefault: IsEnabledByDefault.records,
|
isEnabledByDefault: IsEnabledByDefault.records,
|
||||||
isExpired: IsExpired.records,
|
isExpired: IsExpired.records,
|
||||||
|
@ -269,7 +283,7 @@ class ExperimentalFeatures {
|
||||||
);
|
);
|
||||||
|
|
||||||
static final set_literals = ExperimentalFeature(
|
static final set_literals = ExperimentalFeature(
|
||||||
index: 15,
|
index: 16,
|
||||||
enableString: EnableString.set_literals,
|
enableString: EnableString.set_literals,
|
||||||
isEnabledByDefault: IsEnabledByDefault.set_literals,
|
isEnabledByDefault: IsEnabledByDefault.set_literals,
|
||||||
isExpired: IsExpired.set_literals,
|
isExpired: IsExpired.set_literals,
|
||||||
|
@ -279,7 +293,7 @@ class ExperimentalFeatures {
|
||||||
);
|
);
|
||||||
|
|
||||||
static final spread_collections = ExperimentalFeature(
|
static final spread_collections = ExperimentalFeature(
|
||||||
index: 16,
|
index: 17,
|
||||||
enableString: EnableString.spread_collections,
|
enableString: EnableString.spread_collections,
|
||||||
isEnabledByDefault: IsEnabledByDefault.spread_collections,
|
isEnabledByDefault: IsEnabledByDefault.spread_collections,
|
||||||
isExpired: IsExpired.spread_collections,
|
isExpired: IsExpired.spread_collections,
|
||||||
|
@ -289,7 +303,7 @@ class ExperimentalFeatures {
|
||||||
);
|
);
|
||||||
|
|
||||||
static final super_parameters = ExperimentalFeature(
|
static final super_parameters = ExperimentalFeature(
|
||||||
index: 17,
|
index: 18,
|
||||||
enableString: EnableString.super_parameters,
|
enableString: EnableString.super_parameters,
|
||||||
isEnabledByDefault: IsEnabledByDefault.super_parameters,
|
isEnabledByDefault: IsEnabledByDefault.super_parameters,
|
||||||
isExpired: IsExpired.super_parameters,
|
isExpired: IsExpired.super_parameters,
|
||||||
|
@ -299,7 +313,7 @@ class ExperimentalFeatures {
|
||||||
);
|
);
|
||||||
|
|
||||||
static final test_experiment = ExperimentalFeature(
|
static final test_experiment = ExperimentalFeature(
|
||||||
index: 18,
|
index: 19,
|
||||||
enableString: EnableString.test_experiment,
|
enableString: EnableString.test_experiment,
|
||||||
isEnabledByDefault: IsEnabledByDefault.test_experiment,
|
isEnabledByDefault: IsEnabledByDefault.test_experiment,
|
||||||
isExpired: IsExpired.test_experiment,
|
isExpired: IsExpired.test_experiment,
|
||||||
|
@ -310,7 +324,7 @@ class ExperimentalFeatures {
|
||||||
);
|
);
|
||||||
|
|
||||||
static final triple_shift = ExperimentalFeature(
|
static final triple_shift = ExperimentalFeature(
|
||||||
index: 19,
|
index: 20,
|
||||||
enableString: EnableString.triple_shift,
|
enableString: EnableString.triple_shift,
|
||||||
isEnabledByDefault: IsEnabledByDefault.triple_shift,
|
isEnabledByDefault: IsEnabledByDefault.triple_shift,
|
||||||
isExpired: IsExpired.triple_shift,
|
isExpired: IsExpired.triple_shift,
|
||||||
|
@ -320,7 +334,7 @@ class ExperimentalFeatures {
|
||||||
);
|
);
|
||||||
|
|
||||||
static final value_class = ExperimentalFeature(
|
static final value_class = ExperimentalFeature(
|
||||||
index: 20,
|
index: 21,
|
||||||
enableString: EnableString.value_class,
|
enableString: EnableString.value_class,
|
||||||
isEnabledByDefault: IsEnabledByDefault.value_class,
|
isEnabledByDefault: IsEnabledByDefault.value_class,
|
||||||
isExpired: IsExpired.value_class,
|
isExpired: IsExpired.value_class,
|
||||||
|
@ -330,7 +344,7 @@ class ExperimentalFeatures {
|
||||||
);
|
);
|
||||||
|
|
||||||
static final variance = ExperimentalFeature(
|
static final variance = ExperimentalFeature(
|
||||||
index: 21,
|
index: 22,
|
||||||
enableString: EnableString.variance,
|
enableString: EnableString.variance,
|
||||||
isEnabledByDefault: IsEnabledByDefault.variance,
|
isEnabledByDefault: IsEnabledByDefault.variance,
|
||||||
isExpired: IsExpired.variance,
|
isExpired: IsExpired.variance,
|
||||||
|
@ -385,6 +399,9 @@ class IsEnabledByDefault {
|
||||||
/// Default state of the experiment "nonfunction-type-aliases"
|
/// Default state of the experiment "nonfunction-type-aliases"
|
||||||
static const bool nonfunction_type_aliases = true;
|
static const bool nonfunction_type_aliases = true;
|
||||||
|
|
||||||
|
/// Default state of the experiment "patterns"
|
||||||
|
static const bool patterns = false;
|
||||||
|
|
||||||
/// Default state of the experiment "records"
|
/// Default state of the experiment "records"
|
||||||
static const bool records = false;
|
static const bool records = false;
|
||||||
|
|
||||||
|
@ -456,6 +473,9 @@ class IsExpired {
|
||||||
/// Expiration status of the experiment "nonfunction-type-aliases"
|
/// Expiration status of the experiment "nonfunction-type-aliases"
|
||||||
static const bool nonfunction_type_aliases = true;
|
static const bool nonfunction_type_aliases = true;
|
||||||
|
|
||||||
|
/// Expiration status of the experiment "patterns"
|
||||||
|
static const bool patterns = false;
|
||||||
|
|
||||||
/// Expiration status of the experiment "records"
|
/// Expiration status of the experiment "records"
|
||||||
static const bool records = false;
|
static const bool records = false;
|
||||||
|
|
||||||
|
@ -532,6 +552,9 @@ mixin _CurrentState {
|
||||||
bool get nonfunction_type_aliases =>
|
bool get nonfunction_type_aliases =>
|
||||||
isEnabled(ExperimentalFeatures.nonfunction_type_aliases);
|
isEnabled(ExperimentalFeatures.nonfunction_type_aliases);
|
||||||
|
|
||||||
|
/// Current state for the flag "patterns"
|
||||||
|
bool get patterns => isEnabled(ExperimentalFeatures.patterns);
|
||||||
|
|
||||||
/// Current state for the flag "records"
|
/// Current state for the flag "records"
|
||||||
bool get records => isEnabled(ExperimentalFeatures.records);
|
bool get records => isEnabled(ExperimentalFeatures.records);
|
||||||
|
|
||||||
|
|
|
@ -347,9 +347,8 @@ class ResolverVisitor extends ThrowingAstVisitor<void>
|
||||||
definingLibrary.featureSet.isEnabled(Feature.generic_metadata),
|
definingLibrary.featureSet.isEnabled(Feature.generic_metadata),
|
||||||
options = TypeAnalyzerOptions(
|
options = TypeAnalyzerOptions(
|
||||||
nullSafetyEnabled: definingLibrary.isNonNullableByDefault,
|
nullSafetyEnabled: definingLibrary.isNonNullableByDefault,
|
||||||
// TODO(paulberry): set `patternsEnabled` correctly once we have an
|
patternsEnabled:
|
||||||
// experiment flag for patterns.
|
definingLibrary.featureSet.isEnabled(Feature.patterns)) {
|
||||||
patternsEnabled: false) {
|
|
||||||
var analysisOptions =
|
var analysisOptions =
|
||||||
definingLibrary.context.analysisOptions as AnalysisOptionsImpl;
|
definingLibrary.context.analysisOptions as AnalysisOptionsImpl;
|
||||||
|
|
||||||
|
|
|
@ -171,6 +171,14 @@ class ExperimentalFlag {
|
||||||
experimentEnabledVersion: const Version(2, 13),
|
experimentEnabledVersion: const Version(2, 13),
|
||||||
experimentReleasedVersion: const Version(2, 13));
|
experimentReleasedVersion: const Version(2, 13));
|
||||||
|
|
||||||
|
static const ExperimentalFlag patterns = const ExperimentalFlag(
|
||||||
|
name: 'patterns',
|
||||||
|
isEnabledByDefault: false,
|
||||||
|
isExpired: false,
|
||||||
|
enabledVersion: const Version(2, 19),
|
||||||
|
experimentEnabledVersion: const Version(2, 19),
|
||||||
|
experimentReleasedVersion: const Version(2, 19));
|
||||||
|
|
||||||
static const ExperimentalFlag records = const ExperimentalFlag(
|
static const ExperimentalFlag records = const ExperimentalFlag(
|
||||||
name: 'records',
|
name: 'records',
|
||||||
isEnabledByDefault: false,
|
isEnabledByDefault: false,
|
||||||
|
@ -342,6 +350,10 @@ class GlobalFeatures {
|
||||||
GlobalFeature get nonfunctionTypeAliases => _nonfunctionTypeAliases ??=
|
GlobalFeature get nonfunctionTypeAliases => _nonfunctionTypeAliases ??=
|
||||||
_computeGlobalFeature(ExperimentalFlag.nonfunctionTypeAliases);
|
_computeGlobalFeature(ExperimentalFlag.nonfunctionTypeAliases);
|
||||||
|
|
||||||
|
GlobalFeature? _patterns;
|
||||||
|
GlobalFeature get patterns =>
|
||||||
|
_patterns ??= _computeGlobalFeature(ExperimentalFlag.patterns);
|
||||||
|
|
||||||
GlobalFeature? _records;
|
GlobalFeature? _records;
|
||||||
GlobalFeature get records =>
|
GlobalFeature get records =>
|
||||||
_records ??= _computeGlobalFeature(ExperimentalFlag.records);
|
_records ??= _computeGlobalFeature(ExperimentalFlag.records);
|
||||||
|
@ -468,6 +480,11 @@ class LibraryFeatures {
|
||||||
canonicalUri,
|
canonicalUri,
|
||||||
libraryVersion);
|
libraryVersion);
|
||||||
|
|
||||||
|
LibraryFeature? _patterns;
|
||||||
|
LibraryFeature get patterns =>
|
||||||
|
_patterns ??= globalFeatures._computeLibraryFeature(
|
||||||
|
ExperimentalFlag.patterns, canonicalUri, libraryVersion);
|
||||||
|
|
||||||
LibraryFeature? _records;
|
LibraryFeature? _records;
|
||||||
LibraryFeature get records =>
|
LibraryFeature get records =>
|
||||||
_records ??= globalFeatures._computeLibraryFeature(
|
_records ??= globalFeatures._computeLibraryFeature(
|
||||||
|
@ -541,6 +558,8 @@ ExperimentalFlag? parseExperimentalFlag(String flag) {
|
||||||
return ExperimentalFlag.nonNullable;
|
return ExperimentalFlag.nonNullable;
|
||||||
case "nonfunction-type-aliases":
|
case "nonfunction-type-aliases":
|
||||||
return ExperimentalFlag.nonfunctionTypeAliases;
|
return ExperimentalFlag.nonfunctionTypeAliases;
|
||||||
|
case "patterns":
|
||||||
|
return ExperimentalFlag.patterns;
|
||||||
case "records":
|
case "records":
|
||||||
return ExperimentalFlag.records;
|
return ExperimentalFlag.records;
|
||||||
case "set-literals":
|
case "set-literals":
|
||||||
|
@ -590,6 +609,7 @@ final Map<ExperimentalFlag, bool> defaultExperimentalFlags = {
|
||||||
ExperimentalFlag.nonNullable: ExperimentalFlag.nonNullable.isEnabledByDefault,
|
ExperimentalFlag.nonNullable: ExperimentalFlag.nonNullable.isEnabledByDefault,
|
||||||
ExperimentalFlag.nonfunctionTypeAliases:
|
ExperimentalFlag.nonfunctionTypeAliases:
|
||||||
ExperimentalFlag.nonfunctionTypeAliases.isEnabledByDefault,
|
ExperimentalFlag.nonfunctionTypeAliases.isEnabledByDefault,
|
||||||
|
ExperimentalFlag.patterns: ExperimentalFlag.patterns.isEnabledByDefault,
|
||||||
ExperimentalFlag.records: ExperimentalFlag.records.isEnabledByDefault,
|
ExperimentalFlag.records: ExperimentalFlag.records.isEnabledByDefault,
|
||||||
ExperimentalFlag.setLiterals: ExperimentalFlag.setLiterals.isEnabledByDefault,
|
ExperimentalFlag.setLiterals: ExperimentalFlag.setLiterals.isEnabledByDefault,
|
||||||
ExperimentalFlag.spreadCollections:
|
ExperimentalFlag.spreadCollections:
|
||||||
|
|
|
@ -131,6 +131,9 @@ features:
|
||||||
records:
|
records:
|
||||||
help: "Records"
|
help: "Records"
|
||||||
|
|
||||||
|
patterns:
|
||||||
|
help: "Patterns"
|
||||||
|
|
||||||
# Experiment flag only used for testing.
|
# Experiment flag only used for testing.
|
||||||
test-experiment:
|
test-experiment:
|
||||||
help: >-
|
help: >-
|
||||||
|
|
Loading…
Reference in a new issue