From 9443e248ee9ff3514362ff9bce425c1eaffe3f3a Mon Sep 17 00:00:00 2001 From: Nate Bosch Date: Mon, 19 Apr 2021 21:04:38 +0000 Subject: [PATCH] Enable the triple shift experiment Update the golden for a front_end test which adds additional constant evaluation information now that the experiment is enabled. A co19 test will start failing. https://github.com/dart-lang/co19/issues/1062 Change-Id: I18ec586f57deda83f6cd75e476137ab75d50a92f TEST=No new tests. Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/193747 Auto-Submit: Nate Bosch Commit-Queue: Nate Bosch Reviewed-by: Leaf Petersen --- CHANGELOG.md | 6 ++++++ .../lib/src/dart/analysis/experiments.g.dart | 4 ++-- .../experimental_flags_generated.dart | 2 +- .../no_experiments/various.dart.weak.expect | 20 ++++++------------ .../various.dart.weak.outline.expect | 5 +++++ .../various.dart.weak.transformed.expect | 20 ++++++------------ runtime/vm/experimental_features.cc | 4 ++-- runtime/vm/experimental_features.h | 1 + tools/experimental_features.yaml | 21 ++++++++++--------- 9 files changed, 40 insertions(+), 43 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 2b563cd167a..c1377e89e40 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -30,6 +30,12 @@ Updated the Linter to `1.3.0`, which includes: - new lint: `require_trailing_commas`. - new lint: `prefer_null_aware_method_calls`. +### Language + +* Add an unsigned shift right operator `>>>`. Pad with zeroes, ignoring the + sign bit. On the web platform `int.>>>` shifts the low 32 bits interpreted + as an unsigned integer, so `a >>> b` gives the same result as + `a.toUnsigned(32) >>> b` on the VM. ## 2.13.0 diff --git a/pkg/analyzer/lib/src/dart/analysis/experiments.g.dart b/pkg/analyzer/lib/src/dart/analysis/experiments.g.dart index cc7a05d69d1..80b996d72e0 100644 --- a/pkg/analyzer/lib/src/dart/analysis/experiments.g.dart +++ b/pkg/analyzer/lib/src/dart/analysis/experiments.g.dart @@ -182,7 +182,7 @@ class ExperimentalFeatures { isExpired: IsExpired.triple_shift, documentation: 'Triple-shift operator', experimentalReleaseVersion: null, - releaseVersion: null, + releaseVersion: Version.parse('2.14.0'), ); static final value_class = ExperimentalFeature( @@ -240,7 +240,7 @@ class IsEnabledByDefault { static const bool spread_collections = true; /// Default state of the experiment "triple-shift" - static const bool triple_shift = false; + static const bool triple_shift = true; /// Default state of the experiment "value-class" static const bool value_class = false; 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 759b8fb2368..af04e106290 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 @@ -90,7 +90,7 @@ const Map defaultExperimentalFlags = { ExperimentalFlag.nonfunctionTypeAliases: true, ExperimentalFlag.setLiterals: true, ExperimentalFlag.spreadCollections: true, - ExperimentalFlag.tripleShift: false, + ExperimentalFlag.tripleShift: true, ExperimentalFlag.valueClass: false, ExperimentalFlag.variance: false, }; diff --git a/pkg/front_end/testcases/general/constants/no_experiments/various.dart.weak.expect b/pkg/front_end/testcases/general/constants/no_experiments/various.dart.weak.expect index d8569262d40..376dfb47629 100644 --- a/pkg/front_end/testcases/general/constants/no_experiments/various.dart.weak.expect +++ b/pkg/front_end/testcases/general/constants/no_experiments/various.dart.weak.expect @@ -1,19 +1,11 @@ library; -// -// Problems in library: -// -// pkg/front_end/testcases/general/constants/no_experiments/various.dart:5:40: Error: Constant evaluation error: -// const Symbol tripleShiftSymbol = const Symbol(">>>"); -// ^ -// pkg/front_end/testcases/general/constants/no_experiments/various.dart:5:47: Context: The symbol name must be a valid public Dart member name, public constructor name, or library name, optionally qualified, but was '">>>"'. -// const Symbol tripleShiftSymbol = const Symbol(">>>"); -// ^ -// pkg/front_end/testcases/general/constants/no_experiments/various.dart:5:14: Context: While analyzing: -// const Symbol tripleShiftSymbol = const Symbol(">>>"); -// ^ -// import self as self; import "dart:core" as core; +import "dart:_internal" as _in; -static const field core::Symbol* tripleShiftSymbol = invalid-expression "The symbol name must be a valid public Dart member name, public constructor name, or library name, optionally qualified, but was '\">>>\"'."; +static const field core::Symbol* tripleShiftSymbol = #C1; static method main() → dynamic {} + +constants { + #C1 = #>>> +} diff --git a/pkg/front_end/testcases/general/constants/no_experiments/various.dart.weak.outline.expect b/pkg/front_end/testcases/general/constants/no_experiments/various.dart.weak.outline.expect index e41cc764d33..9194ec0b25a 100644 --- a/pkg/front_end/testcases/general/constants/no_experiments/various.dart.weak.outline.expect +++ b/pkg/front_end/testcases/general/constants/no_experiments/various.dart.weak.outline.expect @@ -6,3 +6,8 @@ import "dart:_internal" as _in; static const field core::Symbol* tripleShiftSymbol = const _in::Symbol::•(">>>"); static method main() → dynamic ; + + +Extra constant evaluation status: +Evaluated: ConstructorInvocation @ org-dartlang-testcase:///various.dart:5:40 -> SymbolConstant(#>>>) +Extra constant evaluation: evaluated: 1, effectively constant: 1 diff --git a/pkg/front_end/testcases/general/constants/no_experiments/various.dart.weak.transformed.expect b/pkg/front_end/testcases/general/constants/no_experiments/various.dart.weak.transformed.expect index d8569262d40..376dfb47629 100644 --- a/pkg/front_end/testcases/general/constants/no_experiments/various.dart.weak.transformed.expect +++ b/pkg/front_end/testcases/general/constants/no_experiments/various.dart.weak.transformed.expect @@ -1,19 +1,11 @@ library; -// -// Problems in library: -// -// pkg/front_end/testcases/general/constants/no_experiments/various.dart:5:40: Error: Constant evaluation error: -// const Symbol tripleShiftSymbol = const Symbol(">>>"); -// ^ -// pkg/front_end/testcases/general/constants/no_experiments/various.dart:5:47: Context: The symbol name must be a valid public Dart member name, public constructor name, or library name, optionally qualified, but was '">>>"'. -// const Symbol tripleShiftSymbol = const Symbol(">>>"); -// ^ -// pkg/front_end/testcases/general/constants/no_experiments/various.dart:5:14: Context: While analyzing: -// const Symbol tripleShiftSymbol = const Symbol(">>>"); -// ^ -// import self as self; import "dart:core" as core; +import "dart:_internal" as _in; -static const field core::Symbol* tripleShiftSymbol = invalid-expression "The symbol name must be a valid public Dart member name, public constructor name, or library name, optionally qualified, but was '\">>>\"'."; +static const field core::Symbol* tripleShiftSymbol = #C1; static method main() → dynamic {} + +constants { + #C1 = #>>> +} diff --git a/runtime/vm/experimental_features.cc b/runtime/vm/experimental_features.cc index 1c79061a060..162f8c8d8c8 100644 --- a/runtime/vm/experimental_features.cc +++ b/runtime/vm/experimental_features.cc @@ -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, }; ASSERT(static_cast(feature) < ARRAY_SIZE(kFeatureValues)); return kFeatureValues[static_cast(feature)]; @@ -29,7 +29,7 @@ const char* GetExperimentalFeatureName(ExperimentalFeature feature) { "nonfunction-type-aliases", "non-nullable", "extension-methods", "constant-update-2018", "control-flow-collections", "set-literals", - "spread-collections", + "spread-collections", "triple-shift", }; ASSERT(static_cast(feature) < ARRAY_SIZE(kFeatureNames)); return kFeatureNames[static_cast(feature)]; diff --git a/runtime/vm/experimental_features.h b/runtime/vm/experimental_features.h index 035af246476..0bb9e50968c 100644 --- a/runtime/vm/experimental_features.h +++ b/runtime/vm/experimental_features.h @@ -21,6 +21,7 @@ enum class ExperimentalFeature { control_flow_collections, set_literals, spread_collections, + triple_shift, }; bool GetExperimentalFeatureDefault(ExperimentalFeature feature); diff --git a/tools/experimental_features.yaml b/tools/experimental_features.yaml index 55dfb4d13c4..1881ab64e86 100644 --- a/tools/experimental_features.yaml +++ b/tools/experimental_features.yaml @@ -106,16 +106,6 @@ current-version: '2.14.0' features: - triple-shift: - help: "Triple-shift operator" - validation: | - class A { - operator>>>(int k) => 42; - } - void main() { - if ((A() >>> 1) == 42) print('feature enabled'); - } - variance: help: "Sound variance" @@ -183,3 +173,14 @@ features: help: "Spread Collections" enabledIn: '2.0.0' expired: true + + triple-shift: + help: "Triple-shift operator" + enabledIn: '2.14.0' + validation: | + class A { + operator>>>(int k) => 42; + } + void main() { + if ((A() >>> 1) == 42) print('feature enabled'); + }