Enable the unnamed-libraries experiment by default in 2.19.0

TEST=tests/language/library/unnamed_library_test.dart

Bug: https://github.com/dart-lang/language/issues/1073
Change-Id: I1c7fa7b4ee4450e344a7613525765e4ab590cc8c
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/265381
Reviewed-by: Alexander Aprelev <aam@google.com>
Reviewed-by: Samuel Rawlins <srawlins@google.com>
Reviewed-by: Michael Thomsen <mit@google.com>
Reviewed-by: Leaf Petersen <leafp@google.com>
Commit-Queue: Samuel Rawlins <srawlins@google.com>
This commit is contained in:
Sam Rawlins 2022-10-25 21:10:57 +00:00 committed by Commit Queue
parent f282fcfa35
commit 9896f1c647
10 changed files with 28 additions and 12 deletions

View file

@ -54,6 +54,13 @@
[#49687]: https://github.com/dart-lang/sdk/issues/49687
[#2020]: https://github.com/dart-lang/language/issues/2020
- Add support for **unnamed libraries**. Dart language 2.19 allows a library
directive to be written without a name (`library;`). A library directive can
be used for library-level annotations (such as `@deprecated`) and for
library-level documentation comments, and with this new feature, you don't
have to provide a unique name for each library directive. Instead, a name can
simply be omitted.
### Libraries
#### `dart:core`

View file

@ -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 = 243;
static const int DATA_VERSION = 244;
/// The number of exception contexts allowed to write. Once this field is
/// zero, we stop writing any new exception contexts in this process.

View file

@ -344,7 +344,7 @@ class ExperimentalFeatures {
isExpired: IsExpired.unnamed_libraries,
documentation: 'Unnamed libraries',
experimentalReleaseVersion: null,
releaseVersion: null,
releaseVersion: Version.parse('2.19.0'),
);
static final value_class = ExperimentalFeature(
@ -435,7 +435,7 @@ class IsEnabledByDefault {
static const bool triple_shift = true;
/// Default state of the experiment "unnamed-libraries"
static const bool unnamed_libraries = false;
static const bool unnamed_libraries = true;
/// Default state of the experiment "value-class"
static const bool value_class = false;

View file

@ -2833,13 +2833,13 @@ main() {
void test_unnamedLibraryDirective() {
CompilationUnit unit = parseCompilationUnit("library;",
featureSet: FeatureSets.language_2_18,
errors: [expectedError(ParserErrorCode.EXPERIMENT_NOT_ENABLED, 0, 7)]);
expect(unit, isNotNull);
}
void test_unnamedLibraryDirective_enabled() {
CompilationUnit unit = parseCompilationUnit("library;",
featureSet: FeatureSets.latestWithExperiments);
CompilationUnit unit = parseCompilationUnit("library;");
expect(unit, isNotNull);
}

View file

@ -32,6 +32,11 @@ class FeatureSets {
flags: [],
);
static final FeatureSet language_2_18 = FeatureSet.fromEnableFlags2(
sdkLanguageVersion: Version.parse('2.18.0'),
flags: [],
);
static final FeatureSet language_2_19 = FeatureSet.fromEnableFlags2(
sdkLanguageVersion: Version.parse('2.19.0'),
flags: [],

View file

@ -229,7 +229,7 @@ class ExperimentalFlag {
static const ExperimentalFlag unnamedLibraries = const ExperimentalFlag(
name: 'unnamed-libraries',
isEnabledByDefault: false,
isEnabledByDefault: true,
isExpired: false,
enabledVersion: const Version(2, 19),
experimentEnabledVersion: const Version(2, 19),

View file

@ -18,7 +18,7 @@ namespace dart {
bool GetExperimentalFeatureDefault(ExperimentalFeature feature) {
constexpr bool kFeatureValues[] = {
true, true, true, true, true, true, true,
true, true, true, true, true, true, true, true,
true, true, true, true, true, true, true,
};
ASSERT(static_cast<size_t>(feature) < ARRAY_SIZE(kFeatureValues));
@ -27,6 +27,7 @@ bool GetExperimentalFeatureDefault(ExperimentalFeature feature) {
const char* GetExperimentalFeatureName(ExperimentalFeature feature) {
constexpr const char* kFeatureNames[] = {
"unnamed-libraries",
"nonfunction-type-aliases",
"non-nullable",
"extension-methods",

View file

@ -14,6 +14,7 @@
namespace dart {
enum class ExperimentalFeature {
unnamed_libraries,
nonfunction_type_aliases,
non_nullable,
extension_methods,

View file

@ -2,8 +2,6 @@
// for details. All rights reserved. Use of this source code as governed by a
// BSD-style license that can be found in the LICENSE file.
// SharedOptions=--enable-experiment=unnamed-libraries
/// Doc comment.
@deprecated
library;

View file

@ -135,9 +135,6 @@ features:
patterns:
help: "Patterns"
unnamed-libraries:
help: "Unnamed libraries"
# Experiment flag only used for testing.
test-experiment:
help: >-
@ -296,3 +293,10 @@ features:
void main() {
test([1, 2, 3]);
}
unnamed-libraries:
help: "Unnamed libraries"
enabledIn: '2.19.0'
validation: |
library;
void main() => print('feature enabled');