diff --git a/pkg/_fe_analyzer_shared/lib/src/experiments/flags.dart b/pkg/_fe_analyzer_shared/lib/src/experiments/flags.dart index d8adfc168095..46af7848d16d 100644 --- a/pkg/_fe_analyzer_shared/lib/src/experiments/flags.dart +++ b/pkg/_fe_analyzer_shared/lib/src/experiments/flags.dart @@ -82,6 +82,14 @@ enum ExperimentalFlag { experimentReleasedVersion: const Version(3, 6), ), + enumShorthands( + name: 'enum-shorthands', + isEnabledByDefault: false, + isExpired: false, + experimentEnabledVersion: defaultLanguageVersion, + experimentReleasedVersion: defaultLanguageVersion, + ), + extensionMethods( name: 'extension-methods', isEnabledByDefault: true, diff --git a/pkg/analyzer/lib/dart/analysis/features.dart b/pkg/analyzer/lib/dart/analysis/features.dart index 3bf4e7bc72b9..24a89a369759 100644 --- a/pkg/analyzer/lib/dart/analysis/features.dart +++ b/pkg/analyzer/lib/dart/analysis/features.dart @@ -37,6 +37,9 @@ abstract class Feature { /// Feature information for enhanced parts. static final enhanced_parts = ExperimentalFeatures.enhanced_parts; + /// Feature information for enum shorthands. + static final enum_shorthands = ExperimentalFeatures.enum_shorthands; + /// Feature information for extension methods. static final extension_methods = ExperimentalFeatures.extension_methods; diff --git a/pkg/analyzer/lib/src/dart/analysis/driver.dart b/pkg/analyzer/lib/src/dart/analysis/driver.dart index 871d941a3990..302c26e4ecde 100644 --- a/pkg/analyzer/lib/src/dart/analysis/driver.dart +++ b/pkg/analyzer/lib/src/dart/analysis/driver.dart @@ -99,7 +99,7 @@ import 'package:meta/meta.dart'; // TODO(scheglov): Clean up the list of implicitly analyzed files. class AnalysisDriver { /// The version of data format, should be incremented on every format change. - static const int DATA_VERSION = 416; + static const int DATA_VERSION = 417; /// The number of exception contexts allowed to write. Once this field is /// zero, we stop writing any new exception contexts in this process. diff --git a/pkg/analyzer/lib/src/dart/analysis/experiments.g.dart b/pkg/analyzer/lib/src/dart/analysis/experiments.g.dart index 819e1cefbab9..d31d3755534d 100644 --- a/pkg/analyzer/lib/src/dart/analysis/experiments.g.dart +++ b/pkg/analyzer/lib/src/dart/analysis/experiments.g.dart @@ -26,6 +26,7 @@ final _knownFeatures = { EnableString.digit_separators: ExperimentalFeatures.digit_separators, EnableString.enhanced_enums: ExperimentalFeatures.enhanced_enums, EnableString.enhanced_parts: ExperimentalFeatures.enhanced_parts, + EnableString.enum_shorthands: ExperimentalFeatures.enum_shorthands, EnableString.extension_methods: ExperimentalFeatures.extension_methods, EnableString.generic_metadata: ExperimentalFeatures.generic_metadata, EnableString.inference_update_1: ExperimentalFeatures.inference_update_1, @@ -88,6 +89,9 @@ class EnableString { /// String to enable the experiment "enhanced-parts" static const String enhanced_parts = 'enhanced-parts'; + /// String to enable the experiment "enum-shorthands" + static const String enum_shorthands = 'enum-shorthands'; + /// String to enable the experiment "extension-methods" static const String extension_methods = 'extension-methods'; @@ -263,8 +267,18 @@ class ExperimentalFeatures { releaseVersion: null, ); - static final extension_methods = ExperimentalFeature( + static final enum_shorthands = ExperimentalFeature( index: 9, + enableString: EnableString.enum_shorthands, + isEnabledByDefault: IsEnabledByDefault.enum_shorthands, + isExpired: IsExpired.enum_shorthands, + documentation: 'Shorter dot syntax for enum values.', + experimentalReleaseVersion: null, + releaseVersion: null, + ); + + static final extension_methods = ExperimentalFeature( + index: 10, enableString: EnableString.extension_methods, isEnabledByDefault: IsEnabledByDefault.extension_methods, isExpired: IsExpired.extension_methods, @@ -274,7 +288,7 @@ class ExperimentalFeatures { ); static final generic_metadata = ExperimentalFeature( - index: 10, + index: 11, enableString: EnableString.generic_metadata, isEnabledByDefault: IsEnabledByDefault.generic_metadata, isExpired: IsExpired.generic_metadata, @@ -285,7 +299,7 @@ class ExperimentalFeatures { ); static final inference_update_1 = ExperimentalFeature( - index: 11, + index: 12, enableString: EnableString.inference_update_1, isEnabledByDefault: IsEnabledByDefault.inference_update_1, isExpired: IsExpired.inference_update_1, @@ -296,7 +310,7 @@ class ExperimentalFeatures { ); static final inference_update_2 = ExperimentalFeature( - index: 12, + index: 13, enableString: EnableString.inference_update_2, isEnabledByDefault: IsEnabledByDefault.inference_update_2, isExpired: IsExpired.inference_update_2, @@ -306,7 +320,7 @@ class ExperimentalFeatures { ); static final inference_update_3 = ExperimentalFeature( - index: 13, + index: 14, enableString: EnableString.inference_update_3, isEnabledByDefault: IsEnabledByDefault.inference_update_3, isExpired: IsExpired.inference_update_3, @@ -317,7 +331,7 @@ class ExperimentalFeatures { ); static final inference_update_4 = ExperimentalFeature( - index: 14, + index: 15, enableString: EnableString.inference_update_4, isEnabledByDefault: IsEnabledByDefault.inference_update_4, isExpired: IsExpired.inference_update_4, @@ -327,7 +341,7 @@ class ExperimentalFeatures { ); static final inference_using_bounds = ExperimentalFeature( - index: 15, + index: 16, enableString: EnableString.inference_using_bounds, isEnabledByDefault: IsEnabledByDefault.inference_using_bounds, isExpired: IsExpired.inference_using_bounds, @@ -338,7 +352,7 @@ class ExperimentalFeatures { ); static final inline_class = ExperimentalFeature( - index: 16, + index: 17, enableString: EnableString.inline_class, isEnabledByDefault: IsEnabledByDefault.inline_class, isExpired: IsExpired.inline_class, @@ -348,7 +362,7 @@ class ExperimentalFeatures { ); static final macros = ExperimentalFeature( - index: 17, + index: 18, enableString: EnableString.macros, isEnabledByDefault: IsEnabledByDefault.macros, isExpired: IsExpired.macros, @@ -358,7 +372,7 @@ class ExperimentalFeatures { ); static final named_arguments_anywhere = ExperimentalFeature( - index: 18, + index: 19, enableString: EnableString.named_arguments_anywhere, isEnabledByDefault: IsEnabledByDefault.named_arguments_anywhere, isExpired: IsExpired.named_arguments_anywhere, @@ -368,7 +382,7 @@ class ExperimentalFeatures { ); static final native_assets = ExperimentalFeature( - index: 19, + index: 20, enableString: EnableString.native_assets, isEnabledByDefault: IsEnabledByDefault.native_assets, isExpired: IsExpired.native_assets, @@ -378,7 +392,7 @@ class ExperimentalFeatures { ); static final non_nullable = ExperimentalFeature( - index: 20, + index: 21, enableString: EnableString.non_nullable, isEnabledByDefault: IsEnabledByDefault.non_nullable, isExpired: IsExpired.non_nullable, @@ -388,7 +402,7 @@ class ExperimentalFeatures { ); static final nonfunction_type_aliases = ExperimentalFeature( - index: 21, + index: 22, enableString: EnableString.nonfunction_type_aliases, isEnabledByDefault: IsEnabledByDefault.nonfunction_type_aliases, isExpired: IsExpired.nonfunction_type_aliases, @@ -398,7 +412,7 @@ class ExperimentalFeatures { ); static final null_aware_elements = ExperimentalFeature( - index: 22, + index: 23, enableString: EnableString.null_aware_elements, isEnabledByDefault: IsEnabledByDefault.null_aware_elements, isExpired: IsExpired.null_aware_elements, @@ -408,7 +422,7 @@ class ExperimentalFeatures { ); static final patterns = ExperimentalFeature( - index: 23, + index: 24, enableString: EnableString.patterns, isEnabledByDefault: IsEnabledByDefault.patterns, isExpired: IsExpired.patterns, @@ -418,7 +432,7 @@ class ExperimentalFeatures { ); static final record_use = ExperimentalFeature( - index: 24, + index: 25, enableString: EnableString.record_use, isEnabledByDefault: IsEnabledByDefault.record_use, isExpired: IsExpired.record_use, @@ -428,7 +442,7 @@ class ExperimentalFeatures { ); static final records = ExperimentalFeature( - index: 25, + index: 26, enableString: EnableString.records, isEnabledByDefault: IsEnabledByDefault.records, isExpired: IsExpired.records, @@ -438,7 +452,7 @@ class ExperimentalFeatures { ); static final sealed_class = ExperimentalFeature( - index: 26, + index: 27, enableString: EnableString.sealed_class, isEnabledByDefault: IsEnabledByDefault.sealed_class, isExpired: IsExpired.sealed_class, @@ -448,7 +462,7 @@ class ExperimentalFeatures { ); static final set_literals = ExperimentalFeature( - index: 27, + index: 28, enableString: EnableString.set_literals, isEnabledByDefault: IsEnabledByDefault.set_literals, isExpired: IsExpired.set_literals, @@ -458,7 +472,7 @@ class ExperimentalFeatures { ); static final spread_collections = ExperimentalFeature( - index: 28, + index: 29, enableString: EnableString.spread_collections, isEnabledByDefault: IsEnabledByDefault.spread_collections, isExpired: IsExpired.spread_collections, @@ -468,7 +482,7 @@ class ExperimentalFeatures { ); static final super_parameters = ExperimentalFeature( - index: 29, + index: 30, enableString: EnableString.super_parameters, isEnabledByDefault: IsEnabledByDefault.super_parameters, isExpired: IsExpired.super_parameters, @@ -478,7 +492,7 @@ class ExperimentalFeatures { ); static final test_experiment = ExperimentalFeature( - index: 30, + index: 31, enableString: EnableString.test_experiment, isEnabledByDefault: IsEnabledByDefault.test_experiment, isExpired: IsExpired.test_experiment, @@ -489,7 +503,7 @@ class ExperimentalFeatures { ); static final triple_shift = ExperimentalFeature( - index: 31, + index: 32, enableString: EnableString.triple_shift, isEnabledByDefault: IsEnabledByDefault.triple_shift, isExpired: IsExpired.triple_shift, @@ -499,7 +513,7 @@ class ExperimentalFeatures { ); static final unnamed_libraries = ExperimentalFeature( - index: 32, + index: 33, enableString: EnableString.unnamed_libraries, isEnabledByDefault: IsEnabledByDefault.unnamed_libraries, isExpired: IsExpired.unnamed_libraries, @@ -509,7 +523,7 @@ class ExperimentalFeatures { ); static final unquoted_imports = ExperimentalFeature( - index: 33, + index: 34, enableString: EnableString.unquoted_imports, isEnabledByDefault: IsEnabledByDefault.unquoted_imports, isExpired: IsExpired.unquoted_imports, @@ -519,7 +533,7 @@ class ExperimentalFeatures { ); static final variance = ExperimentalFeature( - index: 34, + index: 35, enableString: EnableString.variance, isEnabledByDefault: IsEnabledByDefault.variance, isExpired: IsExpired.variance, @@ -529,7 +543,7 @@ class ExperimentalFeatures { ); static final wildcard_variables = ExperimentalFeature( - index: 35, + index: 36, enableString: EnableString.wildcard_variables, isEnabledByDefault: IsEnabledByDefault.wildcard_variables, isExpired: IsExpired.wildcard_variables, @@ -570,6 +584,9 @@ class IsEnabledByDefault { /// Default state of the experiment "enhanced-parts" static const bool enhanced_parts = false; + /// Default state of the experiment "enum-shorthands" + static const bool enum_shorthands = false; + /// Default state of the experiment "extension-methods" static const bool extension_methods = true; @@ -683,6 +700,9 @@ class IsExpired { /// Expiration status of the experiment "enhanced-parts" static const bool enhanced_parts = false; + /// Expiration status of the experiment "enum-shorthands" + static const bool enum_shorthands = false; + /// Expiration status of the experiment "extension-methods" static const bool extension_methods = true; @@ -796,6 +816,9 @@ mixin _CurrentState { /// Current state for the flag "enhanced-parts" bool get enhanced_parts => isEnabled(ExperimentalFeatures.enhanced_parts); + /// Current state for the flag "enum-shorthands" + bool get enum_shorthands => isEnabled(ExperimentalFeatures.enum_shorthands); + /// Current state for the flag "extension-methods" bool get extension_methods => isEnabled(ExperimentalFeatures.extension_methods); diff --git a/pkg/front_end/lib/src/api_prototype/experimental_flags_generated.dart b/pkg/front_end/lib/src/api_prototype/experimental_flags_generated.dart index 4e4a30526208..68aa8aa7498b 100644 --- a/pkg/front_end/lib/src/api_prototype/experimental_flags_generated.dart +++ b/pkg/front_end/lib/src/api_prototype/experimental_flags_generated.dart @@ -142,6 +142,15 @@ class ExperimentalFlag { experimentReleasedVersion: const Version(3, 6), ); + static const ExperimentalFlag enumShorthands = const ExperimentalFlag( + name: 'enum-shorthands', + isEnabledByDefault: false, + isExpired: false, + enabledVersion: defaultLanguageVersion, + experimentEnabledVersion: defaultLanguageVersion, + experimentReleasedVersion: defaultLanguageVersion, + ); + static const ExperimentalFlag extensionMethods = const ExperimentalFlag( name: 'extension-methods', isEnabledByDefault: true, @@ -502,6 +511,12 @@ class GlobalFeatures { GlobalFeature get enhancedParts => _enhancedParts ??= _computeGlobalFeature(ExperimentalFlag.enhancedParts); + GlobalFeature? _enumShorthands; + GlobalFeature get enumShorthands => + _enumShorthands ??= _computeGlobalFeature( + ExperimentalFlag.enumShorthands, + ); + GlobalFeature? _extensionMethods; GlobalFeature get extensionMethods => _extensionMethods ??= _computeGlobalFeature( @@ -733,6 +748,14 @@ class LibraryFeatures { libraryVersion, ); + LibraryFeature? _enumShorthands; + LibraryFeature get enumShorthands => + _enumShorthands ??= globalFeatures._computeLibraryFeature( + ExperimentalFlag.enumShorthands, + canonicalUri, + libraryVersion, + ); + LibraryFeature? _extensionMethods; LibraryFeature get extensionMethods => _extensionMethods ??= globalFeatures._computeLibraryFeature( @@ -972,6 +995,8 @@ class LibraryFeatures { return enhancedEnums; case shared.ExperimentalFlag.enhancedParts: return enhancedParts; + case shared.ExperimentalFlag.enumShorthands: + return enumShorthands; case shared.ExperimentalFlag.extensionMethods: return extensionMethods; case shared.ExperimentalFlag.genericMetadata: @@ -1052,6 +1077,8 @@ ExperimentalFlag? parseExperimentalFlag(String flag) { return ExperimentalFlag.enhancedEnums; case "enhanced-parts": return ExperimentalFlag.enhancedParts; + case "enum-shorthands": + return ExperimentalFlag.enumShorthands; case "extension-methods": return ExperimentalFlag.extensionMethods; case "generic-metadata": @@ -1131,6 +1158,8 @@ final Map defaultExperimentalFlags = { ExperimentalFlag.enhancedEnums.isEnabledByDefault, ExperimentalFlag.enhancedParts: ExperimentalFlag.enhancedParts.isEnabledByDefault, + ExperimentalFlag.enumShorthands: + ExperimentalFlag.enumShorthands.isEnabledByDefault, ExperimentalFlag.extensionMethods: ExperimentalFlag.extensionMethods.isEnabledByDefault, ExperimentalFlag.genericMetadata: @@ -1197,6 +1226,7 @@ const Map sharedExperimentalFlags = { shared.ExperimentalFlag.digitSeparators: ExperimentalFlag.digitSeparators, shared.ExperimentalFlag.enhancedEnums: ExperimentalFlag.enhancedEnums, shared.ExperimentalFlag.enhancedParts: ExperimentalFlag.enhancedParts, + shared.ExperimentalFlag.enumShorthands: ExperimentalFlag.enumShorthands, shared.ExperimentalFlag.extensionMethods: ExperimentalFlag.extensionMethods, shared.ExperimentalFlag.genericMetadata: ExperimentalFlag.genericMetadata, shared.ExperimentalFlag.inferenceUpdate1: ExperimentalFlag.inferenceUpdate1, diff --git a/pkg/front_end/test/spell_checking_list_common.txt b/pkg/front_end/test/spell_checking_list_common.txt index 3bb1646c6535..50b00674e430 100644 --- a/pkg/front_end/test/spell_checking_list_common.txt +++ b/pkg/front_end/test/spell_checking_list_common.txt @@ -2832,6 +2832,7 @@ shorted shorten shortened shorter +shorthands shorting shorts should diff --git a/tools/experimental_features.yaml b/tools/experimental_features.yaml index 3e8fd0e9a103..c0e81b4a68c2 100644 --- a/tools/experimental_features.yaml +++ b/tools/experimental_features.yaml @@ -148,6 +148,9 @@ features: inference-update-4: help: "A bundle of updates to type inference." + enum-shorthands: + help: "Shorter dot syntax for enum values." + # Experiment flag only used for testing. test-experiment: help: >-