[analyzer/cfe] Add an experiment flag for sealed class.
Have a separate flag from patterns, even though sealed families are to be shipped with patterns -- keep the work separate for now. Change-Id: Ic3996b81d9a61f2a3b1e5137e7cc32ecc8bdec9e Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/267289 Reviewed-by: Paul Berry <paulberry@google.com> Commit-Queue: Kallen Tu <kallentu@google.com> Reviewed-by: Konstantin Shcheglov <scheglov@google.com> Reviewed-by: Johnni Winther <johnniwinther@google.com> Reviewed-by: Leaf Petersen <leafp@google.com> Reviewed-by: Kevin Moore <kevmoo@google.com>
This commit is contained in:
@@ -52,6 +52,9 @@ abstract class Feature {
|
||||
/// Feature information for spread collections.
|
||||
static final spread_collections = ExperimentalFeatures.spread_collections;
|
||||
|
||||
// Feature information for sealed classes.
|
||||
static final sealed_class = ExperimentalFeatures.sealed_class;
|
||||
|
||||
/// Feature information for set literals.
|
||||
static final set_literals = ExperimentalFeatures.set_literals;
|
||||
|
||||
|
||||
@@ -85,7 +85,7 @@ import 'package:analyzer/src/util/performance/operation_performance.dart';
|
||||
/// TODO(scheglov) Clean up the list of implicitly analyzed files.
|
||||
class AnalysisDriver implements AnalysisDriverGeneric {
|
||||
/// The version of data format, should be incremented on every format change.
|
||||
static const int DATA_VERSION = 247;
|
||||
static const int DATA_VERSION = 248;
|
||||
|
||||
/// The number of exception contexts allowed to write. Once this field is
|
||||
/// zero, we stop writing any new exception contexts in this process.
|
||||
|
||||
@@ -35,6 +35,7 @@ final _knownFeatures = <String, ExperimentalFeature>{
|
||||
ExperimentalFeatures.nonfunction_type_aliases,
|
||||
EnableString.patterns: ExperimentalFeatures.patterns,
|
||||
EnableString.records: ExperimentalFeatures.records,
|
||||
EnableString.sealed_class: ExperimentalFeatures.sealed_class,
|
||||
EnableString.set_literals: ExperimentalFeatures.set_literals,
|
||||
EnableString.spread_collections: ExperimentalFeatures.spread_collections,
|
||||
EnableString.super_parameters: ExperimentalFeatures.super_parameters,
|
||||
@@ -97,6 +98,9 @@ class EnableString {
|
||||
/// String to enable the experiment "records"
|
||||
static const String records = 'records';
|
||||
|
||||
/// String to enable the experiment "sealed-class"
|
||||
static const String sealed_class = 'sealed-class';
|
||||
|
||||
/// String to enable the experiment "set-literals"
|
||||
static const String set_literals = 'set-literals';
|
||||
|
||||
@@ -290,8 +294,18 @@ class ExperimentalFeatures {
|
||||
releaseVersion: null,
|
||||
);
|
||||
|
||||
static final set_literals = ExperimentalFeature(
|
||||
static final sealed_class = ExperimentalFeature(
|
||||
index: 16,
|
||||
enableString: EnableString.sealed_class,
|
||||
isEnabledByDefault: IsEnabledByDefault.sealed_class,
|
||||
isExpired: IsExpired.sealed_class,
|
||||
documentation: 'Sealed class',
|
||||
experimentalReleaseVersion: null,
|
||||
releaseVersion: null,
|
||||
);
|
||||
|
||||
static final set_literals = ExperimentalFeature(
|
||||
index: 17,
|
||||
enableString: EnableString.set_literals,
|
||||
isEnabledByDefault: IsEnabledByDefault.set_literals,
|
||||
isExpired: IsExpired.set_literals,
|
||||
@@ -301,7 +315,7 @@ class ExperimentalFeatures {
|
||||
);
|
||||
|
||||
static final spread_collections = ExperimentalFeature(
|
||||
index: 17,
|
||||
index: 18,
|
||||
enableString: EnableString.spread_collections,
|
||||
isEnabledByDefault: IsEnabledByDefault.spread_collections,
|
||||
isExpired: IsExpired.spread_collections,
|
||||
@@ -311,7 +325,7 @@ class ExperimentalFeatures {
|
||||
);
|
||||
|
||||
static final super_parameters = ExperimentalFeature(
|
||||
index: 18,
|
||||
index: 19,
|
||||
enableString: EnableString.super_parameters,
|
||||
isEnabledByDefault: IsEnabledByDefault.super_parameters,
|
||||
isExpired: IsExpired.super_parameters,
|
||||
@@ -321,7 +335,7 @@ class ExperimentalFeatures {
|
||||
);
|
||||
|
||||
static final test_experiment = ExperimentalFeature(
|
||||
index: 19,
|
||||
index: 20,
|
||||
enableString: EnableString.test_experiment,
|
||||
isEnabledByDefault: IsEnabledByDefault.test_experiment,
|
||||
isExpired: IsExpired.test_experiment,
|
||||
@@ -332,7 +346,7 @@ class ExperimentalFeatures {
|
||||
);
|
||||
|
||||
static final triple_shift = ExperimentalFeature(
|
||||
index: 20,
|
||||
index: 21,
|
||||
enableString: EnableString.triple_shift,
|
||||
isEnabledByDefault: IsEnabledByDefault.triple_shift,
|
||||
isExpired: IsExpired.triple_shift,
|
||||
@@ -342,7 +356,7 @@ class ExperimentalFeatures {
|
||||
);
|
||||
|
||||
static final unnamed_libraries = ExperimentalFeature(
|
||||
index: 21,
|
||||
index: 22,
|
||||
enableString: EnableString.unnamed_libraries,
|
||||
isEnabledByDefault: IsEnabledByDefault.unnamed_libraries,
|
||||
isExpired: IsExpired.unnamed_libraries,
|
||||
@@ -352,7 +366,7 @@ class ExperimentalFeatures {
|
||||
);
|
||||
|
||||
static final value_class = ExperimentalFeature(
|
||||
index: 22,
|
||||
index: 23,
|
||||
enableString: EnableString.value_class,
|
||||
isEnabledByDefault: IsEnabledByDefault.value_class,
|
||||
isExpired: IsExpired.value_class,
|
||||
@@ -362,7 +376,7 @@ class ExperimentalFeatures {
|
||||
);
|
||||
|
||||
static final variance = ExperimentalFeature(
|
||||
index: 23,
|
||||
index: 24,
|
||||
enableString: EnableString.variance,
|
||||
isEnabledByDefault: IsEnabledByDefault.variance,
|
||||
isExpired: IsExpired.variance,
|
||||
@@ -372,7 +386,7 @@ class ExperimentalFeatures {
|
||||
);
|
||||
|
||||
static final views = ExperimentalFeature(
|
||||
index: 24,
|
||||
index: 25,
|
||||
enableString: EnableString.views,
|
||||
isEnabledByDefault: IsEnabledByDefault.views,
|
||||
isExpired: IsExpired.views,
|
||||
@@ -433,6 +447,9 @@ class IsEnabledByDefault {
|
||||
/// Default state of the experiment "records"
|
||||
static const bool records = false;
|
||||
|
||||
/// Default state of the experiment "sealed-class"
|
||||
static const bool sealed_class = false;
|
||||
|
||||
/// Default state of the experiment "set-literals"
|
||||
static const bool set_literals = true;
|
||||
|
||||
@@ -513,6 +530,9 @@ class IsExpired {
|
||||
/// Expiration status of the experiment "records"
|
||||
static const bool records = false;
|
||||
|
||||
/// Expiration status of the experiment "sealed-class"
|
||||
static const bool sealed_class = false;
|
||||
|
||||
/// Expiration status of the experiment "set-literals"
|
||||
static const bool set_literals = true;
|
||||
|
||||
@@ -598,6 +618,9 @@ mixin _CurrentState {
|
||||
/// Current state for the flag "records"
|
||||
bool get records => isEnabled(ExperimentalFeatures.records);
|
||||
|
||||
/// Current state for the flag "sealed-class"
|
||||
bool get sealed_class => isEnabled(ExperimentalFeatures.sealed_class);
|
||||
|
||||
/// Current state for the flag "set-literals"
|
||||
bool get set_literals => isEnabled(ExperimentalFeatures.set_literals);
|
||||
|
||||
|
||||
@@ -187,6 +187,14 @@ class ExperimentalFlag {
|
||||
experimentEnabledVersion: const Version(2, 19),
|
||||
experimentReleasedVersion: const Version(2, 19));
|
||||
|
||||
static const ExperimentalFlag sealedClass = const ExperimentalFlag(
|
||||
name: 'sealed-class',
|
||||
isEnabledByDefault: false,
|
||||
isExpired: false,
|
||||
enabledVersion: const Version(2, 19),
|
||||
experimentEnabledVersion: const Version(2, 19),
|
||||
experimentReleasedVersion: const Version(2, 19));
|
||||
|
||||
static const ExperimentalFlag setLiterals = const ExperimentalFlag(
|
||||
name: 'set-literals',
|
||||
isEnabledByDefault: true,
|
||||
@@ -374,6 +382,10 @@ class GlobalFeatures {
|
||||
GlobalFeature get records =>
|
||||
_records ??= _computeGlobalFeature(ExperimentalFlag.records);
|
||||
|
||||
GlobalFeature? _sealedClass;
|
||||
GlobalFeature get sealedClass =>
|
||||
_sealedClass ??= _computeGlobalFeature(ExperimentalFlag.sealedClass);
|
||||
|
||||
GlobalFeature? _setLiterals;
|
||||
GlobalFeature get setLiterals =>
|
||||
_setLiterals ??= _computeGlobalFeature(ExperimentalFlag.setLiterals);
|
||||
@@ -514,6 +526,11 @@ class LibraryFeatures {
|
||||
_records ??= globalFeatures._computeLibraryFeature(
|
||||
ExperimentalFlag.records, canonicalUri, libraryVersion);
|
||||
|
||||
LibraryFeature? _sealedClass;
|
||||
LibraryFeature get sealedClass =>
|
||||
_sealedClass ??= globalFeatures._computeLibraryFeature(
|
||||
ExperimentalFlag.sealedClass, canonicalUri, libraryVersion);
|
||||
|
||||
LibraryFeature? _setLiterals;
|
||||
LibraryFeature get setLiterals =>
|
||||
_setLiterals ??= globalFeatures._computeLibraryFeature(
|
||||
@@ -595,6 +612,8 @@ ExperimentalFlag? parseExperimentalFlag(String flag) {
|
||||
return ExperimentalFlag.patterns;
|
||||
case "records":
|
||||
return ExperimentalFlag.records;
|
||||
case "sealed-class":
|
||||
return ExperimentalFlag.sealedClass;
|
||||
case "set-literals":
|
||||
return ExperimentalFlag.setLiterals;
|
||||
case "spread-collections":
|
||||
@@ -648,6 +667,7 @@ final Map<ExperimentalFlag, bool> defaultExperimentalFlags = {
|
||||
ExperimentalFlag.nonfunctionTypeAliases.isEnabledByDefault,
|
||||
ExperimentalFlag.patterns: ExperimentalFlag.patterns.isEnabledByDefault,
|
||||
ExperimentalFlag.records: ExperimentalFlag.records.isEnabledByDefault,
|
||||
ExperimentalFlag.sealedClass: ExperimentalFlag.sealedClass.isEnabledByDefault,
|
||||
ExperimentalFlag.setLiterals: ExperimentalFlag.setLiterals.isEnabledByDefault,
|
||||
ExperimentalFlag.spreadCollections:
|
||||
ExperimentalFlag.spreadCollections.isEnabledByDefault,
|
||||
|
||||
@@ -138,6 +138,9 @@ features:
|
||||
views:
|
||||
help: "Views"
|
||||
|
||||
sealed-class:
|
||||
help: "Sealed class"
|
||||
|
||||
# Experiment flag only used for testing.
|
||||
test-experiment:
|
||||
help: >-
|
||||
|
||||
Reference in New Issue
Block a user